예제 #1
0
 /**
  * @param ShopgatePluginPrestashop $module
  * @return array
  */
 public static function getShopgateSettings($module)
 {
     $result = array();
     /**
      * customer groups
      */
     $result['customer_groups'] = ShopgateSettings::getCustomerGroups($module);
     /**
      * product tax
      */
     $result['tax']['product_tax_classes'] = ShopgateSettings::getProductTaxClasses($module);
     /**
      * customer tax classes
      */
     $result['tax']['customer_tax_classes'] = array(array('key' => 'default', 'is_default' => true));
     if (version_compare(_PS_VERSION_, '1.4.0.4', '<=')) {
         $result['tax']['tax_rates'] = ShopgateSettings::getTaxRatesOldVersions($module);
         $result['tax']['tax_rules'] = ShopgateSettings::getTaxRulesOldVersions($result['tax']['product_tax_classes'], $result['tax']['customer_tax_classes'], $result['tax']['tax_rates']);
     } else {
         $result['tax']['tax_rates'] = ShopgateSettings::getTaxRates($module);
         $result['tax']['tax_rules'] = ShopgateSettings::getTaxRules($module);
     }
     /**
      * allowed_shipping_countries and allowed_address_countries
      */
     $result['allowed_shipping_countries'] = array();
     $result['allowed_address_countries'] = array();
     $countryResultItems = array();
     $addressResultItems = array();
     foreach (ShopgateShipping::getDeliveryCountries($module->context->language->id, true, true) as $country) {
         if (is_array($country['states'])) {
             $resultStates = array();
             foreach ($country['states'] as $state) {
                 $resultStates[] = $state['iso_code'];
             }
         } else {
             $resultStates = array(ShopgateShipping::CARRIER_CODE_ALL);
         }
         $countryResultItems[$country['iso_code']] = $resultStates;
     }
     foreach ($countryResultItems as $country => $state) {
         $item = array('country' => $country, 'state' => $state);
         $result['allowed_shipping_countries'][] = $item;
     }
     foreach (Country::getCountries($module->context->language->id, true) as $country) {
         if (is_array($country['states'])) {
             $resultStates = array();
             foreach ($country['states'] as $state) {
                 $resultStates[] = $state['iso_code'];
             }
         } else {
             $resultStates = array(ShopgateShipping::CARRIER_CODE_ALL);
         }
         $addressResultItems[$country['iso_code']] = $resultStates;
     }
     foreach ($addressResultItems as $country => $state) {
         $item = array('country' => $country, 'state' => $state);
         $result['allowed_address_countries'][] = $item;
     }
     return $result;
 }