Esempio n. 1
0
    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);
    }
Esempio n. 2
0
 public static function getShippingTabConfiguration($id_ebay_profile)
 {
     $ebay = new Ebay();
     $shipping_national = EbayShipping::getNationalShippings($id_ebay_profile);
     if (!is_array($shipping_national) || count($shipping_national) == 0) {
         return array('indicator' => 'wrong', 'indicatorBig' => 'wrong', 'message' => $ebay->l('You must at least configure one domestic shipping service', 'ebayvalidatortab'));
     }
     $shipping_international = EbayShipping::getInternationalShippings($id_ebay_profile);
     if (!EbayShipping::internationalShippingsHaveZone($shipping_international)) {
         return array('indicator' => 'wrong', 'indicatorBig' => 'wrong', 'message' => $ebay->l('Your international shipping must at least have one zone configured', 'ebayvalidatortab'));
     }
     if (count($shipping_international) == 0) {
         return array('indicator' => 'success', 'indicatorBig' => 'mind', 'message' => $ebay->l('You could benefit to configure international shipping services', 'ebayvalidatortab'));
     }
     return array('indicator' => 'success');
 }
Esempio n. 3
0
 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);
 }
Esempio n. 4
0
 /**
  * Display form for the shipping screen
  *
  **/
 private function _displayFormShipping()
 {
     $configKeys = array('EBAY_PAYPAL_EMAIL', 'EBAY_CATEGORY_LOADED', 'EBAY_SECURITY_TOKEN', 'EBAY_DELIVERY_TIME', 'EBAY_ZONE_NATIONAL', 'EBAY_ZONE_INTERNATIONAL', 'PS_LANG_DEFAULT');
     // Load prestashop ebay's configuration
     $configs = Configuration::getMultiple($configKeys);
     // Check if the module is configured
     if (!isset($configs['EBAY_PAYPAL_EMAIL']) || $configs['EBAY_PAYPAL_EMAIL'] === false) {
         return $this->display(dirname(__FILE__), '/views/templates/hook/error_paypal_email.tpl');
     }
     $nb_shipping_zones_excluded = DB::getInstance()->getValue('SELECT COUNT(*) FROM ' . _DB_PREFIX_ . 'ebay_shipping_zone_excluded');
     if (!$nb_shipping_zones_excluded) {
         $this->_loadEbayExcludedLocations();
     }
     $module_filters = version_compare(_PS_VERSION_, '1.4.5', '>=') ? Carrier::CARRIERS_MODULE : 2;
     //INITIALIZE CACHE
     $psCarrierModule = Carrier::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::safeOutput(Tools::getValue('controller'));
     } else {
         $url_vars['tab'] = Tools::safeOutput(Tools::getValue('tab'));
     }
     $this->smarty->assign(array('eBayCarrier' => $this->_getCarriers(), 'psCarrier' => Carrier::getCarriers($configs['PS_LANG_DEFAULT']), 'psCarrierModule' => $psCarrierModule, 'existingNationalCarrier' => EbayShipping::getNationalShippings(), 'existingInternationalCarrier' => $this->_getExistingInternationalCarrier(), 'deliveryTime' => $configs['EBAY_DELIVERY_TIME'], 'prestashopZone' => Zone::getZones(), 'excludeShippingLocation' => $this->_cacheEbayExcludedLocation(), 'internationalShippingLocations' => $this->_getInternationalShippingLocations(), 'deliveryTimeOptions' => $this->_getDeliveryTimeOptions(), 'formUrl' => $this->_getUrl($url_vars), 'ebayZoneNational' => isset($configs['EBAY_ZONE_NATIONAL']) ? $configs['EBAY_ZONE_NATIONAL'] : false, 'ebayZoneInternational' => isset($configs['EBAY_ZONE_INTERNATIONAL']) ? $configs['EBAY_ZONE_INTERNATIONAL'] : false, 'ebay_token' => $configs['EBAY_SECURITY_TOKEN']));
     return $this->display(dirname(__FILE__), '/views/templates/hook/shipping.tpl');
 }