Пример #1
0
 /**
  * Process entered data for the shipping screen
  */
 private function _postProcessShipping()
 {
     //Update excluded location
     if (Tools::getValue('excludeLocationHidden')) {
         Db::getInstance()->Execute('UPDATE ' . _DB_PREFIX_ . 'ebay_shipping_zone_excluded SET excluded = 0');
         if ($exclude_locations = Tools::getValue('excludeLocation')) {
             $where = '0 || ';
             foreach ($exclude_locations as $location => $on) {
                 //build update $where
                 $where .= 'location = "' . pSQL($location) . '" || ';
             }
             $where .= ' 0';
             if (version_compare(_PS_VERSION_, '1.5', '>')) {
                 DB::getInstance()->update('ebay_shipping_zone_excluded', array('excluded' => 1), $where);
             } else {
                 Db::getInstance()->autoExecute(_DB_PREFIX_ . 'ebay_shipping_zone_excluded', array('excluded' => 1), 'UPDATE', $where);
             }
         }
     }
     //Update global information about shipping (delivery time, ...)
     $this->setConfiguration('EBAY_DELIVERY_TIME', Tools::getValue('deliveryTime'));
     $this->setConfiguration('EBAY_ZONE_INTERNATIONAL', Tools::getValue('internationalZone'));
     $this->setConfiguration('EBAY_ZONE_NATIONAL', Tools::getValue('nationalZone'));
     //Update Shipping Method for National Shipping (Delete And Insert)
     EbayShipping::truncate();
     if ($ebay_carriers = Tools::getValue('ebayCarrier')) {
         $ps_carriers = Tools::getValue('psCarrier');
         $extra_fees = Tools::getValue('extrafee');
         foreach ($ebay_carriers as $key => $ebay_carrier) {
             EbayShipping::insert($ebay_carrier, $ps_carriers[$key], $extra_fees[$key]);
         }
     }
     Db::getInstance()->Execute('TRUNCATE ' . _DB_PREFIX_ . 'ebay_shipping_international_zone');
     if ($ebay_carriers_international = Tools::getValue('ebayCarrier_international')) {
         $ps_carriers_international = Tools::getValue('psCarrier_international');
         $extra_fees_international = Tools::getValue('extrafee_international');
         $international_shipping_locations = Tools::getValue('internationalShippingLocation');
         $international_excluded_shipping_locations = Tools::getValue('internationalExcludedShippingLocation');
         foreach ($ebay_carriers_international as $key => $ebay_carrier_international) {
             EbayShipping::insert($ebay_carrier_international, $ps_carriers_international[$key], $extra_fees_international[$key], true);
             $last_id = EbayShipping::getLastShippingId();
             if (isset($international_shipping_locations[$key])) {
                 foreach (array_keys($international_shipping_locations[$key]) as $id_ebay_zone) {
                     EbayShippingInternationalZone::insert($last_id, $id_ebay_zone);
                 }
             }
         }
     }
 }
Пример #2
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);
 }
Пример #3
0
    function postProcess()
    {
        //Update excluded location
        if (Tools::getValue('excludeLocationHidden')) {
            Db::getInstance()->Execute('UPDATE ' . _DB_PREFIX_ . 'ebay_shipping_zone_excluded 
				SET excluded = 0
				WHERE `id_ebay_profile` = ' . (int) $this->ebay_profile->id);
            if ($exclude_locations = Tools::getValue('excludeLocation')) {
                $locations = array_keys($exclude_locations);
                $where = 'location IN ("' . implode('","', array_map('pSQL', $locations)) . '")';
                $where .= ' AND `id_ebay_profile` = ' . (int) $this->ebay_profile->id;
                if (version_compare(_PS_VERSION_, '1.5', '>')) {
                    DB::getInstance()->update('ebay_shipping_zone_excluded', array('excluded' => 1), $where);
                } else {
                    Db::getInstance()->autoExecute(_DB_PREFIX_ . 'ebay_shipping_zone_excluded', array('excluded' => 1), 'UPDATE', $where);
                }
            }
        }
        //Update global information about shipping (delivery time, ...)
        $this->ebay_profile->setConfiguration('EBAY_DELIVERY_TIME', Tools::getValue('deliveryTime'));
        //Update Shipping Method for National Shipping (Delete And Insert)
        EbayShipping::truncate($this->ebay_profile->id);
        if ($ebay_carriers = Tools::getValue('ebayCarrier')) {
            $ps_carriers = Tools::getValue('psCarrier');
            $extra_fees = Tools::getValue('extrafee');
            foreach ($ebay_carriers as $key => $ebay_carrier) {
                if (!empty($ebay_carrier) && !empty($ps_carriers[$key])) {
                    //Get id_carrier and id_zone from ps_carrier
                    $infos = explode('-', $ps_carriers[$key]);
                    EbayShipping::insert($this->ebay_profile->id, $ebay_carrier, $infos[0], $extra_fees[$key], $infos[1]);
                }
            }
        }
        Db::getInstance()->Execute('DELETE FROM ' . _DB_PREFIX_ . 'ebay_shipping_international_zone
			WHERE `id_ebay_profile` = ' . (int) $this->ebay_profile->id);
        if ($ebay_carriers_international = Tools::getValue('ebayCarrier_international')) {
            $ps_carriers_international = Tools::getValue('psCarrier_international');
            $extra_fees_international = Tools::getValue('extrafee_international');
            $international_shipping_locations = Tools::getValue('internationalShippingLocation');
            $international_excluded_shipping_locations = Tools::getValue('internationalExcludedShippingLocation');
            foreach ($ebay_carriers_international as $key => $ebay_carrier_international) {
                if (!empty($ebay_carrier_international) && !empty($ps_carriers_international[$key]) && isset($international_shipping_locations[$key])) {
                    $infos = explode('-', $ps_carriers_international[$key]);
                    EbayShipping::insert($this->ebay_profile->id, $ebay_carrier_international, $infos[0], $extra_fees_international[$key], $infos[1], true);
                    $last_id = EbayShipping::getLastShippingId($this->ebay_profile->id);
                    foreach (array_keys($international_shipping_locations[$key]) as $id_ebay_zone) {
                        EbayShippingInternationalZone::insert($this->ebay_profile->id, $last_id, $id_ebay_zone);
                    }
                }
            }
        }
    }