src/WooCommerce/Invoice/Creator.php
protected function getVatRateLookupMetadataByTaxClass($taxClassId)
    {
        // '' denotes the 'standard'tax class, use 'standard' in meta data, ''
        // when searching.
        if ($taxClassId === '') {
            $taxClassId = 'standard';
        }
        $result = array(
            Meta::VatClassId => sanitize_title($taxClassId),
            // Vat class name is the non-sanitized version of the id
            // and thus does not convey more information: don't add.
            Meta::VatRateLookup => array(),
            Meta::VatRateLookupLabel => array(),
        );
        if ($taxClassId === 'standard') {
            $taxClassId = '';
        }

        // Find applicable vat rates. We use WC_Tax::find_rates() to find them.
        $args = array(
            'tax_class' => $taxClassId,
            'country' => $this->invoice[Tag::Customer][Tag::CountryCode],
            'city' => isset($this->invoice[Tag::Customer][Tag::City]) ? $this->invoice[Tag::Customer][Tag::City] : '',
            'postcode' => isset($this->invoice[Tag::Customer][Tag::PostalCode]) ? $this->invoice[Tag::Customer][Tag::PostalCode] : '',
        );
        $taxRates = WC_Tax::find_rates($args);
        foreach ($taxRates as $taxRate) {
            $result[Meta::VatRateLookup][] = $taxRate['rate'];
            $result[Meta::VatRateLookupLabel][] = $taxRate['label'];
        }
        return $result;
    }
protected function getVatRateLookupMetadataByTaxClass($taxClassId)
    {
        // '' denotes the 'standard'tax class, use 'standard' in meta data, ''
        // when searching.
        if ($taxClassId === '') {
            $taxClassId = 'standard';
        }
        $result = array(
            Meta::VatClassId => sanitize_title($taxClassId),
            // Vat class name is the non-sanitized version of the id
            // and thus does not convey more information: don't add.
            Meta::VatRateLookup => array(),
            Meta::VatRateLookupLabel => array(),
        );
        if ($taxClassId === 'standard') {
            $taxClassId = '';
        }

        // Find applicable vat rates. We use WC_Tax::find_rates() to find them.
        $args = array(
            'tax_class' => $taxClassId,
            'country' => $this->invoice[Tag::Customer][Tag::CountryCode],
            'city' => isset($this->invoice[Tag::Customer][Tag::City]) ? $this->invoice[Tag::Customer][Tag::City] : '',
            'postcode' => isset($this->invoice[Tag::Customer][Tag::PostalCode]) ? $this->invoice[Tag::Customer][Tag::PostalCode] : '',
        );
        $taxRates = WC_Tax::find_rates($args);
        foreach ($taxRates as $taxRate) {
            $result[Meta::VatRateLookup][] = $taxRate['rate'];
            $result[Meta::VatRateLookupLabel][] = $taxRate['label'];
        }
        return $result;
    }
protected function getVatRateLookupMetadataByTaxClass ( $ taxClassId ) { // '' denotes the 'standard'tax class, use 'standard' in meta data, '' // when searching. if ( $ taxClassId === '' ) { $ taxClassId = 'standard' ; } $ result = array ( Meta :: VatClassId => sanitize_title ( $ taxClassId ) , // Vat class name is the non-sanitized version of the id // and thus does not convey more information: don't add. Meta :: VatRateLookup => array ( ) , Meta :: VatRateLookupLabel => array ( ) , ) ; if ( $ taxClassId === 'standard' ) { $ taxClassId = '' ; } // Find applicable vat rates. We use WC_Tax::find_rates() to find them. $ args = array ( 'tax_class' => $ taxClassId , 'country' => $ this -> invoice [ Tag :: Customer ] [ Tag :: CountryCode ] , 'city' => isset ( $ this -> invoice [ Tag :: Customer ] [ Tag :: City ] ) ? $ this -> invoice [ Tag :: Customer ] [ Tag :: City ] : '' , 'postcode' => isset ( $ this -> invoice [ Tag :: Customer ] [ Tag :: PostalCode ] ) ? $ this -> invoice [ Tag :: Customer ] [ Tag :: PostalCode ] : '' , ) ; $ taxRates = WC_Tax :: find_rates ( $ args ) ; foreach ( $ taxRates as $ taxRate ) { $ result [ Meta :: VatRateLookup ] [ ] = $ taxRate [ 'rate' ] ; $ result [ Meta :: VatRateLookupLabel ] [ ] = $ taxRate [ 'label' ] ; } return $ result ; }
Looks up and returns vat rate metadata for product lines.

A product has a tax class. A tax class can have multiple tax rates,
depending on the region of the customer. As we don't have that data here,
this method will only return metadata if only 1 rate was found.

@param string $taxClassId
The tax class of the product. For the default tax class it can be
'standard' or empty.

@return array
An array with keys:
- Meta::VatClassId: string
- Meta::VatRateLookup: float[]
- Meta::VatRateLookupLabel: string[]
Looks up and returns vat rate metadata for product lines .