private function _getCart($id_customer, $id_address_billing, $id_address_shipping, $productsNode, $currency, $shipping_method)
 {
     $cart = new Cart();
     $cart->id_customer = $id_customer;
     $cart->id_address_invoice = $id_address_billing;
     $cart->id_address_delivery = $id_address_shipping;
     $cart->id_currency = Currency::getIdByIsoCode((string) $currency == '' ? 'EUR' : (string) $currency);
     $cart->id_lang = Configuration::get('PS_LANG_DEFAULT');
     $cart->recyclable = 0;
     $cart->secure_key = md5(uniqid(rand(), true));
     $actual_configuration = unserialize(Configuration::get('SHOPPING_FLUX_SHIPPING_MATCHING'));
     $carrier_to_load = isset($actual_configuration[base64_encode(Tools::safeOutput($shipping_method))]) ? (int) $actual_configuration[base64_encode(Tools::safeOutput($shipping_method))] : (int) Configuration::get('SHOPPING_FLUX_CARRIER');
     $carrier = Carrier::getCarrierByReference($carrier_to_load);
     //manage case PS_CARRIER_DEFAULT is deleted
     $carrier = is_object($carrier) ? $carrier : new Carrier($carrier_to_load);
     $cart->id_carrier = $carrier->id;
     $cart->add();
     foreach ($productsNode->Product as $product) {
         $skus = explode('_', $product->SKU);
         $added = $cart->updateQty((int) $product->Quantity, (int) $skus[0], isset($skus[1]) ? $skus[1] : null);
         if ($added < 0 || $added === false) {
             return false;
         }
     }
     $cart->update();
     return $cart;
 }
Esempio n. 2
0
 private function getSettings()
 {
     $settings_data = self::getSettingsData();
     foreach ($settings_data as $name => $setting) {
         $this->{$setting} = $this->getSetting($name, $this->{$setting});
     }
     $carriers_ids = Configuration::getMultiple(array(self::CARRIER_10_ID, self::CARRIER_12_ID, self::CARRIER_CLASSIC_ID, self::CARRIER_SAME_DAY_ID, self::CARRIER_B2C_ID, self::CARRIER_INTERNATIONAL_ID, self::CARRIER_BULGARIA_ID, self::CARRIER_10_COD_ID, self::CARRIER_12_COD_ID, self::CARRIER_CLASSIC_COD_ID, self::CARRIER_SAME_DAY_COD_ID, self::CARRIER_B2C_COD_ID, self::CARRIER_INTERNATIONAL_COD_ID, self::CARRIER_BULGARIA_COD_ID));
     $ps_14 = version_compare(_PS_VERSION_, '1.5', '<');
     $all_dpd_carriers = array(array('id_carrier' => isset($carriers_ids[self::CARRIER_10_ID]) ? $carriers_ids[self::CARRIER_10_ID] : '', 'id_service' => 'active_services_10'), array('id_carrier' => isset($carriers_ids[self::CARRIER_12_ID]) ? $carriers_ids[self::CARRIER_12_ID] : '', 'id_service' => 'active_services_12'), array('id_carrier' => isset($carriers_ids[self::CARRIER_CLASSIC_ID]) ? $carriers_ids[self::CARRIER_CLASSIC_ID] : '', 'id_service' => 'active_services_classic'), array('id_carrier' => isset($carriers_ids[self::CARRIER_SAME_DAY_ID]) ? $carriers_ids[self::CARRIER_SAME_DAY_ID] : '', 'id_service' => 'active_services_same_day'), array('id_carrier' => isset($carriers_ids[self::CARRIER_B2C_ID]) ? $carriers_ids[self::CARRIER_B2C_ID] : '', 'id_service' => 'active_services_b2c'), array('id_carrier' => isset($carriers_ids[self::CARRIER_INTERNATIONAL_ID]) ? $carriers_ids[self::CARRIER_INTERNATIONAL_ID] : '', 'id_service' => 'active_services_international'), array('id_carrier' => isset($carriers_ids[self::CARRIER_BULGARIA_ID]) ? $carriers_ids[self::CARRIER_BULGARIA_ID] : '', 'id_service' => 'active_services_bulgaria'), array('id_carrier' => isset($carriers_ids[self::CARRIER_10_COD_ID]) ? $carriers_ids[self::CARRIER_10_COD_ID] : '', 'id_service' => 'is_cod_carrier_10'), array('id_carrier' => isset($carriers_ids[self::CARRIER_12_COD_ID]) ? $carriers_ids[self::CARRIER_12_COD_ID] : '', 'id_service' => 'is_cod_carrier_12'), array('id_carrier' => isset($carriers_ids[self::CARRIER_CLASSIC_COD_ID]) ? $carriers_ids[self::CARRIER_CLASSIC_COD_ID] : '', 'id_service' => 'is_cod_carrier_classic'), array('id_carrier' => isset($carriers_ids[self::CARRIER_SAME_DAY_COD_ID]) ? $carriers_ids[self::CARRIER_SAME_DAY_COD_ID] : '', 'id_service' => 'is_cod_carrier_same_day'), array('id_carrier' => isset($carriers_ids[self::CARRIER_B2C_COD_ID]) ? $carriers_ids[self::CARRIER_B2C_COD_ID] : '', 'id_service' => 'is_cod_b2c'), array('id_carrier' => isset($carriers_ids[self::CARRIER_INTERNATIONAL_COD_ID]) ? $carriers_ids[self::CARRIER_INTERNATIONAL_COD_ID] : '', 'id_service' => 'is_cod_international'), array('id_carrier' => isset($carriers_ids[self::CARRIER_BULGARIA_COD_ID]) ? $carriers_ids[self::CARRIER_BULGARIA_COD_ID] : '', 'id_service' => 'is_cod_bulgaria'));
     foreach ($all_dpd_carriers as $dpd_carrier) {
         if ($dpd_carrier['id_carrier']) {
             if ($ps_14) {
                 $id_carrier = (int) DpdGroupCarrier::getIdCarrierByReference((int) $dpd_carrier['id_carrier']);
                 $carrier = new Carrier((int) $id_carrier);
             } else {
                 $carrier = Carrier::getCarrierByReference((int) $dpd_carrier['id_carrier']);
             }
             if (Validate::isLoadedObject($carrier)) {
                 $this->{$dpd_carrier}['id_service'] = $carrier->active && !$carrier->deleted ? 1 : 0;
             } else {
                 $this->{$dpd_carrier}['id_service'] = 0;
             }
         }
     }
 }
Esempio n. 3
0
 public static function getCarrierByReference($reference)
 {
     if (version_compare(_PS_VERSION_, '1.5', '<')) {
         $id_carrier = (int) DpdPolandCarrier::getIdCarrierByReference($reference);
         $carrier = new Carrier((int) $id_carrier);
     } else {
         $carrier = Carrier::getCarrierByReference((int) $reference);
     }
     return $carrier;
 }
Esempio n. 4
0
 public static function deleteCarrier($carrier_type)
 {
     $id_carrier = (int) Configuration::get($carrier_type);
     if (!$id_carrier) {
         return true;
     }
     if (version_compare(_PS_VERSION_, '1.5', '<')) {
         $id_carrier = (int) DpdGroupCarrier::getIdCarrierByReference((int) $id_carrier);
         $carrier = new Carrier((int) $id_carrier);
     } else {
         $carrier = Carrier::getCarrierByReference($id_carrier);
     }
     if (!Validate::isLoadedObject($carrier)) {
         return true;
     }
     if ($carrier->deleted) {
         return true;
     }
     $carrier->deleted = 1;
     return (bool) $carrier->save();
 }