コード例 #1
0
ファイル: view.html.php プロジェクト: jeprodev/jeproshop
 public function renderDetails($tpl = null)
 {
     $carrierModel = new JeproshopCarrierModelCarrier();
     $carriers = $carrierModel->getCarriersList();
     $this->assignRef('carriers', $carriers);
     if ($this->getLayout() != 'modal') {
         $this->addToolBar();
         $this->sideBar = JHtmlSidebar::render();
     }
     parent::display($tpl);
 }
コード例 #2
0
ファイル: view.html.php プロジェクト: jeprodev/jeproshop
 private function assignCountries()
 {
     // Select the most appropriate country
     $app = JFactory::getApplication();
     $country_id = $app->input->get('country_id');
     if (isset($country_id) && is_numeric($country_id)) {
         $selectedCountry = (int) $country_id;
     }
     if (!isset($selectedCountry)) {
         $selectedCountry = (int) JeproshopSettingModelSetting::getValue('default_country');
     }
     if (JeproshopSettingModelSetting::getValue('restrict_delivered_countries')) {
         $countries = JeproshopCarrierModelCarrier::getDeliveredCountries($this->context->language->lang_id, true, true);
         print_r($countries);
     } else {
         $countries = JeproshopCountryModelCountry::getCountries($this->context->language->lang_id, true);
     }
     $zones = JeproshopZoneModelZone::getZones();
     $this->assignRef('zones', $zones);
     $this->assignRef('countries', $countries);
     $registrationProcessType = JeproshopSettingModelSetting::getValue('registration_process_type');
     $this->assignRef('registration_process_type', $registrationProcessType);
     $selectedCountry = isset($selectedCountry) ? $selectedCountry : 0;
     $this->assignRef('selected_country', $selectedCountry);
     $vatNumberManagement = JeproshopSettingModelSetting::getValue('vat_number_management');
     $this->assignRef('vat_management', $vatNumberManagement);
 }
コード例 #3
0
ファイル: carrier.php プロジェクト: jeprodev/jeproshop
 public function getTaxRulesGroupId(JeproshopContext $context = null)
 {
     return JeproshopCarrierModelCarrier::getTaxRulesGroupIdByCarrierId((int) $this->carrier_id, $context);
 }
コード例 #4
0
ファイル: cart.php プロジェクト: jeprodev/jeproshop
 /**
  * Get all the ids of the delivery addresses without carriers
  *
  * @param bool $return_collection Return a collection
  *
  * @return array Array of address id or of address object
  */
 public function getDeliveryAddressesWithoutCarriers($return_collection = false)
 {
     $addresses_without_carriers = array();
     foreach ($this->getProducts() as $product) {
         if (!in_array($product->address_delivery_id, $addresses_without_carriers) && !count(JeproshopCarrierModelCarrier::getAvailableCarrierList(new JeproshopProductModelProduct($product->product_id), null, $product->address_delivery_id))) {
             $addresses_without_carriers[] = $product->address_delivery_id;
         }
     }
     if (!$return_collection) {
         return $addresses_without_carriers;
     } else {
         $addresses_instance_without_carriers = array();
         foreach ($addresses_without_carriers as $address_id) {
             $addresses_instance_without_carriers[] = new JeproshopAddressModelAddress($address_id);
         }
         return $addresses_instance_without_carriers;
     }
 }
コード例 #5
0
ファイル: carrier.php プロジェクト: jeprodev/jeproshop
 /**
  * For a given {product, warehouse}, gets the carrier available
  *
  * @param JeproshopProductModelProduct $product The id of the product, or an array with at least the package size and weight
  * @param int $warehouse_id
  * @param int $address_delivery_id
  * @param int $shop_id
  * @param $cart
  * @return array
  */
 public static function getAvailableCarrierList(JeproshopProductModelProduct $product, $warehouse_id, $address_delivery_id = null, $shop_id = null, $cart = null)
 {
     if (is_null($shop_id)) {
         $shop_id = JeproshopContext::getContext()->shop->shop_id;
     }
     if (is_null($cart)) {
         $cart = JeproshopContext::getContext()->cart;
     }
     $address_id = (int) (!is_null($address_delivery_id) && $address_delivery_id != 0 ? $address_delivery_id : $cart->address_delivery_id);
     if ($address_id) {
         $address = new JeproshopAddressModelAddress($address_id);
         $zone_id = JeproshopAddressModelAddress::getZoneIdByAddressId($address->address_id);
         // Check the country of the address is activated
         if (!JeproshopAddressModelAddress::isCountryActiveById($address->address_id)) {
             return array();
         }
     } else {
         $country = new JeproshopCountryModelCountry(JeproshopSettingModelSetting::getValue('default_country'));
         $izone_id = $country->zone_id;
     }
     // Does the product is linked with carriers?
     $query = new DbQuery();
     $query->select('id_carrier');
     $query->from('product_carrier', 'pc');
     $query->innerJoin('carrier', 'c', 'c.id_reference = pc.id_carrier_reference AND c.deleted = 0');
     $query->where('pc.id_product = ' . (int) $product->product_id);
     $query->where('pc.id_shop = ' . (int) $shop_id);
     $cache_id = 'Carrier::getAvailableCarrierList_' . (int) $product->id . '-' . (int) $id_shop;
     if (!Cache::isStored($cache_id)) {
         $carriers_for_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
         Cache::store($cache_id, $carriers_for_product);
     }
     $carriers_for_product = Cache::retrieve($cache_id);
     $carrier_list = array();
     if (!empty($carriers_for_product)) {
         //the product is linked with carriers
         foreach ($carriers_for_product as $carrier) {
             //check if the linked carriers are available in current zone
             if (Carrier::checkCarrierZone($carrier['id_carrier'], $id_zone)) {
                 $carrier_list[] = $carrier['id_carrier'];
             }
         }
         if (empty($carrier_list)) {
             return array();
         }
         //no linked carrier are available for this zone
     }
     // The product is not directly linked with a carrier
     // Get all the carriers linked to a warehouse
     if ($warehouse_id) {
         $warehouse = new JeproshopWarehouseModelWarehouse($warehouse_id);
         $warehouse_carrier_list = $warehouse->getCarriers();
     }
     $available_carrier_list = array();
     $customer = new JeproshopCustomerModelCustomer($cart->customer_id);
     $carriers = JeproshopCarrierModelCarrier::getCarriersForOrder($zone_id, $customer->getGroups(), $cart);
     foreach ($carriers as $carrier) {
         $available_carrier_list[] = $carrier->carrier_id;
     }
     if ($carrier_list) {
         $carrier_list = array_intersect($available_carrier_list, $carrier_list);
     } else {
         $carrier_list = $available_carrier_list;
     }
     if (isset($warehouse_carrier_list)) {
         $carrier_list = array_intersect($carrier_list, $warehouse_carrier_list);
     }
     if ($product->width > 0 || $product->height > 0 || $product->depth > 0 || $product->weight > 0) {
         foreach ($carrier_list as $key => $carrier_id) {
             $carrier = new JeproshopCarrierModelCarrier($carrier_id);
             if ($carrier->max_width > 0 && $carrier->max_width < $product->width || $carrier->max_height > 0 && $carrier->max_height < $product->height || $carrier->max_depth > 0 && $carrier->max_depth < $product->depth || $carrier->max_weight > 0 && $carrier->max_weight < $product->weight) {
                 unset($carrier_list[$key]);
             }
         }
     }
     return $carrier_list;
 }
コード例 #6
0
ファイル: view.html.php プロジェクト: jeprodev/jeproshop
 protected function getCarrierList()
 {
     $carrier_list = JeproshopCarrierModelCarrier::getCarriers($this->context->language->lang_id, false, false, false, null, JeproshopCarrierModelCarrier::JEPROSHOP_ALL_CARRIERS);
     if ($this->product) {
         $carrier_selected_list = $this->product->getCarriers();
         foreach ($carrier_list as &$carrier) {
             foreach ($carrier_selected_list as $carrier_selected) {
                 if ($carrier_selected->reference_id == $carrier->reference_id) {
                     $carrier->selected = true;
                     continue;
                 }
             }
         }
     }
     return $carrier_list;
 }
コード例 #7
0
ファイル: tax.php プロジェクト: jeprodev/jeproshop
 /**
  * Returns the carrier tax rate
  *
  * @param $carrier_id
  * @param $address_id
  * @return float $tax_rate
  */
 public static function getCarrierTaxRate($carrier_id, $address_id = null)
 {
     $address = JeproshopAddressModelAddress::initialize($address_id);
     $tax_rules_id = (int) JeproshopCarrierModelCarrier::getTaxRulesGroupIdByCarrierId((int) $carrier_id);
     $tax_manager = JeproshopTaxManagerFactory::getManager($address, $tax_rules_id);
     $tax_calculator = $tax_manager->getTaxCalculator();
     return $tax_calculator->getTotalRate();
 }
コード例 #8
0
ファイル: view.html.php プロジェクト: jeprodev/jeproshop
 /**
  * Assign template vars related to countries display
  */
 protected function assignCountries()
 {
     $context = JeproshopContext::getContext();
     $app = JFactory::getApplication();
     $country_id = $app->input->get('country_id');
     // Get selected country
     if (isset($country_id) && !is_null($country_id) && is_numeric($country_id)) {
         $selected_country = (int) $country_id;
     } else {
         if (isset($this->address) && isset($this->address->country_id) && !empty($this->address->country_id) && is_numeric($this->address->country_id)) {
             $selected_country = (int) $this->address->country_id;
         } else {
             if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
                 // get all countries as language (xy) or language-country (wz-XY)
                 $array = array();
                 preg_match("#(?<=-)\\w\\w|\\w\\w(?!-)#", $_SERVER['HTTP_ACCEPT_LANGUAGE'], $array);
                 if (!JeproshopTools::isLanguageIsoCode($array[0]) || !($selected_country = JeproshopCountryModelCountry::getByIso($array[0]))) {
                     $selected_country = (int) JeproshopSettingModelSetting::getValue('default_country');
                 }
             } else {
                 $selected_country = (int) JeproshopSettingModelSetting::getValue('default_country');
             }
         }
     }
     // Generate countries list
     if (JeproshopSettingModelSetting::getValue('restrict_delivered_countries')) {
         $countries = JeproshopCarrierModelCarrier::getDeliveredCountries($context->language->lang_id, true, true);
     } else {
         $countries = JeproshopCountryModelCountry::getCountries($context->language->lang_id, true);
     }
     // @todo use helper
     $list = '';
     foreach ($countries as $country) {
         $selected = $country->country_id == $selected_country ? 'selected="selected"' : '';
         $list .= '<option value="' . (int) $country->country_id . '" ' . $selected . '>' . htmlentities(ucfirst($country->name)) . '</option>';
     }
     // Assign vars
     $this->assignRef('countries_list', $list);
     $this->assignRef('countries', $countries);
 }