function getContent() { $configKeys = array('EBAY_SECURITY_TOKEN', 'PS_LANG_DEFAULT'); // Load prestashop ebay's configuration $configs = Configuration::getMultiple($configKeys); $profile_configs = $this->ebay_profile->getMultiple(array('EBAY_DELIVERY_TIME', 'EBAY_ZONE_NATIONAL', 'EBAY_ZONE_INTERNATIONAL')); // Check if the module is configured if (!$this->ebay_profile->getConfiguration('EBAY_PAYPAL_EMAIL')) { $template_vars = array('error_form_shipping' => 'true'); return $this->display('error_paypal_email.tpl', $template_vars); } $nb_shipping_zones_excluded = DB::getInstance()->getValue('SELECT COUNT(*) FROM ' . _DB_PREFIX_ . 'ebay_shipping_zone_excluded WHERE `id_ebay_profile` = ' . (int) $this->ebay_profile->id); if (!$nb_shipping_zones_excluded) { EbayShippingZoneExcluded::loadEbayExcludedLocations($this->ebay_profile->id); } $module_filters = version_compare(_PS_VERSION_, '1.4.5', '>=') ? Carrier::CARRIERS_MODULE : 2; //INITIALIZE CACHE $psCarrierModule = $this->ebay_profile->getCarriers($configs['PS_LANG_DEFAULT'], false, false, false, null, $module_filters); $url_vars = array('id_tab' => '3', 'section' => 'shipping'); if (version_compare(_PS_VERSION_, '1.5', '>')) { $url_vars['controller'] = Tools::getValue('controller'); } else { $url_vars['tab'] = Tools::getValue('tab'); } $zones = Zone::getZones(true); foreach ($zones as &$zone) { $zone['carriers'] = Carrier::getCarriers($this->context->language->id, false, false, $zone['id_zone']); } $template_vars = array('eBayCarrier' => EbayShippingService::getCarriers($this->ebay_profile->ebay_site_id), 'psCarrier' => $this->ebay_profile->getCarriers($configs['PS_LANG_DEFAULT']), 'psCarrierModule' => $psCarrierModule, 'existingNationalCarrier' => EbayShipping::getNationalShippings($this->ebay_profile->id), 'existingInternationalCarrier' => EbayShippingInternationalZone::getExistingInternationalCarrier($this->ebay_profile->id), 'deliveryTime' => $profile_configs['EBAY_DELIVERY_TIME'], 'prestashopZone' => Zone::getZones(), 'excludeShippingLocation' => EbayShippingZoneExcluded::cacheEbayExcludedLocation($this->ebay_profile->id), 'internationalShippingLocations' => EbayShippingLocation::getInternationalShippingLocations(), 'deliveryTimeOptions' => EbayDeliveryTimeOptions::getDeliveryTimeOptions(), 'formUrl' => $this->_getUrl($url_vars), 'ebayZoneNational' => isset($profile_configs['EBAY_ZONE_NATIONAL']) ? $profile_configs['EBAY_ZONE_NATIONAL'] : false, 'ebayZoneInternational' => isset($profile_configs['EBAY_ZONE_INTERNATIONAL']) ? $profile_configs['EBAY_ZONE_INTERNATIONAL'] : false, 'ebay_token' => $configs['EBAY_SECURITY_TOKEN'], 'id_ebay_profile' => $this->ebay_profile->id, 'newPrestashopZone' => $zones); return $this->display('shipping.tpl', $template_vars); }
private static function _getShippingDetailsForProduct($product, $ebay_profile) { $national_ship = array(); $international_ship = array(); //Get National Informations : service, costs, additional costs, priority $service_priority = 1; foreach (EbayShipping::getNationalShippings($ebay_profile->id, $product->id) as $carrier) { $national_ship[$carrier['ebay_carrier']] = array('servicePriority' => $service_priority, 'serviceAdditionalCosts' => $carrier['extra_fee'], 'serviceCosts' => EbaySynchronizer::_getShippingPriceForProduct($product, $carrier['id_zone'], $carrier['ps_carrier'])); $service_priority++; } //Get International Informations $service_priority = 1; foreach (EbayShipping::getInternationalShippings($ebay_profile->id, $product->id) as $carrier) { $international_ship[$carrier['ebay_carrier']] = array('servicePriority' => $service_priority, 'serviceAdditionalCosts' => $carrier['extra_fee'], 'serviceCosts' => EbaySynchronizer::_getShippingPriceForProduct($product, $carrier['id_zone'], $carrier['ps_carrier']), 'locationsToShip' => EbayShippingInternationalZone::getIdEbayZonesByIdEbayShipping($ebay_profile->id, $carrier['id_ebay_shipping'])); $service_priority++; } return array('excludedZone' => EbayShippingZoneExcluded::getExcluded($ebay_profile->id), 'nationalShip' => $national_ship, 'internationalShip' => $international_ship); }
public static function cacheEbayExcludedLocation($id_ebay_profile) { $ebay_excluded_zones = EbayShippingZoneExcluded::getAll($id_ebay_profile); $all = array(); $excluded = array(); $regions = array(); foreach ($ebay_excluded_zones as $key => $zone) { if (!in_array($zone['region'], $regions)) { $regions[] = $zone['region']; } $all[$zone['region']]['country'][] = array('location' => $zone['location'], 'description' => $zone['description'], 'excluded' => $zone['excluded']); } foreach ($ebay_excluded_zones as $key => $zone) { if (in_array($zone['location'], $regions)) { $all[$zone['location']]['description'] = $zone['description']; } } unset($all['Worldwide']); foreach ($all as $key => $value) { if (!isset($value['description'])) { $all[$key]['description'] = $key; } } //get real excluded location foreach (EbayShippingZoneExcluded::getExcluded($id_ebay_profile) as $zone) { $excluded[] = $zone['location']; } return array('all' => $all, 'excluded' => $excluded); }
private function _loadEbayExcludedLocations() { $ebay_request = new EbayRequest(); $excluded_locations = $ebay_request->getExcludeShippingLocations(); foreach ($excluded_locations as &$excluded_location) { foreach ($excluded_location as &$field) { $field = pSQL($field); } $excluded_location['excluded'] = 0; } if (version_compare(_PS_VERSION_, '1.5', '>')) { Db::getInstance()->insert('ebay_shipping_zone_excluded', $excluded_locations); } else { foreach ($excluded_locations as $location) { EbayShippingZoneExcluded::insert($location); } } }