Beispiel #1
0
 /**
  * Extract tax rate data in a format which is
  *
  * @param \Magento\Tax\Service\V1\Data\TaxRate $taxRate
  * @return array
  */
 protected function extractTaxRateData($taxRate)
 {
     $zipRange = $taxRate->getZipRange();
     $formData = ['tax_calculation_rate_id' => $taxRate->getId(), 'tax_country_id' => $taxRate->getCountryId(), 'tax_region_id' => $taxRate->getRegionId(), 'tax_postcode' => $taxRate->getPostcode(), 'code' => $taxRate->getCode(), 'rate' => $taxRate->getPercentageRate(), 'zip_is_range' => false];
     if ($zipRange) {
         $formData['zip_is_range'] = true;
         $formData['zip_from'] = $zipRange->getFrom();
         $formData['zip_to'] = $zipRange->getTo();
     }
     if ($taxRate->getTitles()) {
         $titleData = [];
         foreach ($taxRate->getTitles() as $title) {
             $titleData[] = [$title->getStoreId() => $title->getValue()];
         }
         $formData['title'] = $titleData;
     }
     return $formData;
 }
Beispiel #2
0
 /**
  * Convert a tax rate data object to an array of associated titles
  *
  * @param TaxRateDataObject $taxRate
  * @return array
  */
 public function createTitleArrayFromServiceObject(TaxRateDataObject $taxRate)
 {
     $titles = $taxRate->getTitles();
     $titleData = [];
     if ($titles) {
         foreach ($titles as $title) {
             $titleData[$title->getStoreId()] = $title->getValue();
         }
     }
     return $titleData;
 }