예제 #1
0
 public function hookextraCarrier($params)
 {
     if (!MondialRelay::isAccountSet()) {
         return '';
     }
     $carrier = false;
     $id_carrier = false;
     $id_mr_method = false;
     $preSelectedRelay = $this->getRelayPointSelected($params['cart']->id);
     $carriersList = MondialRelay::_getCarriers();
     $address = new Address($this->context->cart->id_address_delivery);
     $id_zone = Address::getZoneById((int) $address->id);
     // Check if the defined carrier are ok
     foreach ($carriersList as $k => $row) {
         // For now works only with single shipping !
         if (method_exists($params['cart'], 'carrierIsSelected')) {
             if ($params['cart']->carrierIsSelected($row['id_carrier'], $params['address']->id)) {
                 $id_carrier = $row['id_carrier'];
             }
         }
         $carrier = new Carrier((int) $row['id_carrier']);
         if ((Configuration::get('PS_SHIPPING_METHOD') and $carrier->getMaxDeliveryPriceByWeight($id_zone) === false) || (!Configuration::get('PS_SHIPPING_METHOD') and $carrier->getMaxDeliveryPriceByPrice($id_zone) === false)) {
             unset($carriersList[$k]);
         } else {
             if ($row['range_behavior']) {
                 // Get id zone
                 $id_zone = (isset($this->context->cart->id_address_delivery) and $this->context->cart->id_address_delivery) ? Address::getZoneById((int) $this->context->cart->id_address_delivery) : (int) $this->context->country->id_zone;
                 if (Configuration::get('PS_SHIPPING_METHOD') && !Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $this->context->cart->getTotalWeight(), $id_zone) || !Configuration::get('PS_SHIPPING_METHOD') && (!Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $this->context->cart->getOrderTotal(true, MondialRelay::BOTH_WITHOUT_SHIPPING), $id_zone, $this->context->cart->id_currency) || !Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $this->context->cart->getOrderTotal(true, MondialRelay::BOTH_WITHOUT_SHIPPING), $id_zone, $this->context->cart->id_currency))) {
                     unset($carriersList[$k]);
                 }
             }
         }
     }
     $carrier = MondialRelay::getMethodByIdCarrier($id_carrier);
     $this->context->smarty->assign(array('carriersextra' => $carriersList, 'preSelectedRelay' => isset($preSelectedRelay['MR_selected_num']) ? $preSelectedRelay['MR_selected_num'] : '', 'MR_carrier' => $carrier, 'MR_PS_VERSION' => _PS_VERSION_, 'MR_dlv_mode' => $id_carrier ? $carrier['dlv_mode'] : ''));
     return $this->fetchTemplate('/tpl/', 'checkout_process');
 }
예제 #2
0
 public function hookExtraCarrier($params)
 {
     // TODO : Makes it work with multi-shipping
     if (!MondialRelay::isAccountSet()) {
         return '';
     }
     $id_carrier = false;
     $preSelectedRelay = $this->getRelayPointSelected($this->context->cart->id);
     $carriersList = MondialRelay::_getCarriers();
     $address = new Address($this->context->cart->id_address_delivery);
     $id_zone = Address::getZoneById((int) $address->id);
     // Check if the defined carrier are ok
     foreach ($carriersList as $k => $row) {
         // For now works only with single shipping (>= 1.5 compatibility)
         if (method_exists($this->context->cart, 'carrierIsSelected')) {
             if ($this->context->cart->carrierIsSelected($row['id_carrier'], $params['address']->id)) {
                 $id_carrier = $row['id_carrier'];
             }
         }
         // Temporary carrier for some test
         $carrier = new Carrier((int) $row['id_carrier']);
         if (Configuration::get('PS_SHIPPING_METHOD') && $carrier->getMaxDeliveryPriceByWeight($id_zone) === false || !Configuration::get('PS_SHIPPING_METHOD') && $carrier->getMaxDeliveryPriceByPrice($id_zone) === false) {
             unset($carriersList[$k]);
         } else {
             if ($row['range_behavior']) {
                 // Get id zone
                 $id_zone = isset($this->context->cart->id_address_delivery) && $this->context->cart->id_address_delivery ? Address::getZoneById((int) $this->context->cart->id_address_delivery) : (int) $this->context->country->id_zone;
                 if (Configuration::get('PS_SHIPPING_METHOD') && !Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $this->context->cart->getTotalWeight(), $id_zone) || !Configuration::get('PS_SHIPPING_METHOD') && (!Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $this->context->cart->getOrderTotal(true, MondialRelay::BOTH_WITHOUT_SHIPPING), $id_zone, $this->context->cart->id_currency) || !Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $this->context->cart->getOrderTotal(true, MondialRelay::BOTH_WITHOUT_SHIPPING), $id_zone, $this->context->cart->id_currency))) {
                     unset($carriersList[$k]);
                 }
             }
         }
     }
     $carrier = NULL;
     if (_PS_VERSION_ >= '1.5') {
         $id_carrier = (int) $this->context->cart->id_carrier;
     }
     if ($id_carrier && ($method = MondialRelay::getMethodByIdCarrier($id_carrier))) {
         $carrier = new Carrier((int) $id_carrier);
         // Add dynamically a new field
         $carrier->id_mr_method = $method['id_mr_method'];
         $carrier->mr_dlv_mode = $method['dlv_mode'];
     }
     $this->context->smarty->assign(array('MR_Data' => MRTools::jsonEncode(array('carrier_list' => $carriersList, 'carrier' => $carrier, 'PS_VERSION' => _PS_VERSION_, 'pre_selected_relay' => isset($preSelectedRelay['MR_selected_num']) ? $preSelectedRelay['MR_selected_num'] : 0))));
     return $this->fetchTemplate('/tpl/', 'checkout_process');
 }
예제 #3
0
 public function hookExtraCarrier($params)
 {
     /*  TODO : Makes it work with multi-shipping */
     if (!MondialRelay::isAccountSet()) {
         return '';
     }
     $id_carrier = false;
     $preSelectedRelay = $this->getRelayPointSelected($this->context->cart->id);
     $carriersList = MondialRelay::_getCarriers();
     $address = new Address($this->context->cart->id_address_delivery);
     $country = new Country($address->id_country);
     $id_zone = Address::getZoneById((int) $address->id);
     /*  Check if the defined carrier are ok */
     foreach ($carriersList as $k => $row) {
         /*  For now works only with single shipping (>= 1.5 compatibility) */
         if (method_exists($this->context->cart, 'carrierIsSelected')) {
             if ($this->context->cart->carrierIsSelected($row['id_carrier'], $params['address']->id)) {
                 $id_carrier = $row['id_carrier'];
             }
         }
         /*  Temporary carrier for some test */
         $carrier = new Carrier((int) $row['id_carrier']);
         if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT && $carrier->getMaxDeliveryPriceByWeight($id_zone) === false || $carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE && $carrier->getMaxDeliveryPriceByPrice($id_zone) === false) {
             unset($carriersList[$k]);
         } else {
             if ($row['range_behavior']) {
                 /*  Get id zone */
                 $id_zone = isset($this->context->cart->id_address_delivery) && $this->context->cart->id_address_delivery ? Address::getZoneById((int) $this->context->cart->id_address_delivery) : (int) $this->context->country->id_zone;
                 if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT && !Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $this->context->cart->getTotalWeight(), $id_zone) || $carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE && (!Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $this->context->cart->getOrderTotal(true, MondialRelay::BOTH_WITHOUT_SHIPPING), $id_zone, $this->context->cart->id_currency) || !Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $this->context->cart->getOrderTotal(true, MondialRelay::BOTH_WITHOUT_SHIPPING), $id_zone, $this->context->cart->id_currency))) {
                     unset($carriersList[$k]);
                 }
             }
         }
     }
     $carrier = null;
     if ($id_carrier && ($method = MondialRelay::getMethodByIdCarrier($id_carrier))) {
         $carrier = new Carrier((int) $id_carrier);
         /*  Add dynamically a new field */
         $carrier->id_mr_method = $method['id_mr_method'];
         $carrier->mr_dlv_mode = $method['dlv_mode'];
     }
     if (Configuration::get('PS_SSL_ENABLED') || !empty($_SERVER['HTTPS']) && Tools::strtolower($_SERVER['HTTPS']) != 'off') {
         $ssl = 'true';
     } else {
         $ssl = 'false';
     }
     $this->context->smarty->assign(array('address' => $address, 'account_shop' => $this->account_shop, 'country' => $country, 'ssl' => $ssl, 'MR_Data' => MRTools::jsonEncode(array('carrier_list' => $carriersList, 'carrier' => $carrier, 'PS_VERSION' => _PS_VERSION_, 'pre_selected_relay' => isset($preSelectedRelay['MR_selected_num']) ? $preSelectedRelay['MR_selected_num'] : -1))));
     if (Configuration::get('MONDIAL_RELAY_MODE') == 'widget') {
         return $this->fetchTemplate('/views/templates/front/', 'checkout_process_widget');
     } else {
         return $this->fetchTemplate('/views/templates/front/', 'checkout_process');
     }
 }