コード例 #1
0
ファイル: view.html.php プロジェクト: jeprodev/jeproshop
 public function renderDetails($tpl = NULL)
 {
     $currencyModel = new JeproshopCurrencyModelCurrency();
     $currencies = $currencyModel->getCurrenciesList();
     $zones = JeproshopZoneModelZone::getZones();
     $this->assignRef('currencies', $currencies);
     /*$this->assignRef('zones', $zones); */
     //$this->pagination = $countryModel->getPagination();
     if ($this->getLayout() != 'modal') {
         $this->addToolBar();
         $this->sideBar = JHtmlSidebar::render();
     }
     parent::display($tpl);
 }
コード例 #2
0
ファイル: view.html.php プロジェクト: jeprodev/jeproshop
 public function renderEditForm($tpl = NULL)
 {
     $app = JFactory::getApplication();
     if (!isset($this->context)) {
         $this->context = JeproshopContext::getContext();
     }
     $this->helper = new JeproshopHelper();
     $languages = JeproshopLanguageModelLanguage::getLanguages();
     $this->assignRef('languages', $languages);
     $currencies = JeproshopCurrencyModelCurrency::getStaticCurrencies();
     $this->assignRef('currencies', $currencies);
     $zones = JeproshopZoneModelZone::getZones();
     $this->assignRef('zones', $zones);
     $addressLayout = JeproshopAddressFormatModelAddressFormat::getAddressCountryFormat($this->country->country_id);
     if ($value = $app->input->get('address_layout')) {
         $addressLayout = $value;
     }
     $default_layout = '';
     $default_layout_tab = array(array('firstname', 'lastname'), array('company'), array('vat_number'), array('address1'), array('address2'), array('postcode', 'city'), array('Country:name'), array('phone'), array('phone_mobile'));
     foreach ($default_layout_tab as $line) {
         $default_layout .= implode(' ', $line) . "\r\n";
     }
     $this->assignRef('address_layout', $addressLayout);
     $encodingAddressLayout = urlencode($addressLayout);
     $this->assignRef('encoding_address_layout', $encodingAddressLayout);
     $encodingDefaultLayout = urlencode($default_layout);
     $this->assignRef('encoding_default_layout', $encodingDefaultLayout);
     $displayValidFields = $this->displayValidFields();
     $this->assignRef('display_valid_fields', $displayValidFields);
     $this->addToolBar();
     $this->sideBar = JHtmlSidebar::render();
     parent::display($tpl);
 }
コード例 #3
0
ファイル: tools.php プロジェクト: jeprodev/jeproshop
 /**
  * Return price with currency sign for a given product
  *
  * @param float $price Product price
  * @param object|array $currency Current currency (object, id_currency, NULL => context currency)
  * @return string Price correctly formatted (sign, decimal separator...)
  */
 public static function displayPrice($price, $currency = null, $no_utf8 = false, JeproshopContext $context = null)
 {
     if (!is_numeric($price)) {
         return $price;
     }
     if (!$context) {
         $context = JeproshopContext::getContext();
     }
     if ($currency === null) {
         $currency = $context->currency;
     } elseif (is_int($currency)) {
         // if you modified this function, don't forget to modify the Javascript function formatCurrency (in Tools.js)
         $currency = JeproshopCurrencyModelCurrency::getCurrencyInstance((int) $currency);
     }
     if (is_object($currency)) {
         $c_char = $currency->sign;
         $c_format = $currency->format;
         $c_decimals = (int) $currency->decimals * COM_JEPROSHOP_PRICE_DISPLAY_PRECISION;
         $c_blank = $currency->blank;
     } else {
         return false;
     }
     $blank = $c_blank ? ' ' : '';
     $ret = 0;
     if ($is_negative = $price < 0) {
         $price *= -1;
     }
     $price = JeproshopTools::roundPrice($price, $c_decimals);
     /*
      * If the language is RTL and the selected currency format contains spaces as thousands separator
      * then the number will be printed in reverse since the space is interpreted as separating words.
      * To avoid this we replace the currency format containing a space with the one containing a comma (,) as thousand
      * separator when the language is RTL.
      *
      * TODO: This is not ideal, a currency format should probably be tied to a language, not to a currency.
      */
     if ($c_format == 2 && $context->language->is_rtl == 1) {
         $c_format = 4;
     }
     switch ($c_format) {
         /* X 0,000.00 */
         case 1:
             $ret = $c_char . $blank . number_format($price, $c_decimals, '.', ',');
             break;
             /* 0 000,00 X*/
         /* 0 000,00 X*/
         case 2:
             $ret = number_format($price, $c_decimals, ',', ' ') . $blank . $c_char;
             break;
             /* X 0.000,00 */
         /* X 0.000,00 */
         case 3:
             $ret = $c_char . $blank . number_format($price, $c_decimals, ',', '.');
             break;
             /* 0,000.00 X */
         /* 0,000.00 X */
         case 4:
             $ret = number_format($price, $c_decimals, '.', ',') . $blank . $c_char;
             break;
             /* X 0'000.00  Added for the switzerland currency */
         /* X 0'000.00  Added for the switzerland currency */
         case 5:
             $ret = $c_char . $blank . number_format($price, $c_decimals, '.', "'");
             break;
     }
     if ($is_negative) {
         $ret = '-' . $ret;
     }
     if ($no_utf8) {
         return str_replace('�', chr(128), $ret);
     }
     return $ret;
 }
コード例 #4
0
ファイル: cart.php プロジェクト: jeprodev/jeproshop
 /**
  * This function returns the total cart amount
  *
  * Possible values for $type:
  * JeproshopCartModelCart::ONLY_PRODUCTS
  * JeproshopCartModelCart::ONLY_DISCOUNTS
  * JeproshopCartModelCart::BOTH
  * JeproshopCartModelCart::BOTH_WITHOUT_SHIPPING
  * JeproshopCartModelCart::ONLY_SHIPPING
  * JeproshopCartModelCart::ONLY_WRAPPING
  * JeproshopCartModelCart::ONLY_PRODUCTS_WITHOUT_SHIPPING
  * JeproshopCartModelCart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING
  *
  * @param boolean $withTaxes With or without taxes
  * @param integer $type Total type
  * @param null $products
  * @param null $carrier_id
  * @param boolean $use_cache Allow using cache of the method CartRule::getContextualValue
  * @return float Order total
  */
 public function getOrderTotal($withTaxes = true, $type = JeproshopCartModelCart::BOTH, $products = null, $carrier_id = null, $use_cache = true)
 {
     if (!$this->cart_id) {
         return 0;
     }
     $type = (int) $type;
     $array_type = array(JeproshopCartModelCart::ONLY_PRODUCTS, JeproshopCartModelCart::ONLY_DISCOUNTS, JeproshopCartModelCart::BOTH, JeproshopCartModelCart::BOTH_WITHOUT_SHIPPING, JeproshopCartModelCart::ONLY_SHIPPING, JeproshopCartModelCart::ONLY_WRAPPING, JeproshopCartModelCart::ONLY_PRODUCTS_WITHOUT_SHIPPING, JeproshopCartModelCart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING);
     // Define virtual context to prevent case where the cart is not the in the global context
     $virtual_context = JeproshopContext::getContext()->cloneContext();
     $virtual_context->cart = $this;
     if (!in_array($type, $array_type)) {
         die(Tools::displayError());
     }
     $with_shipping = in_array($type, array(JeproshopCartModelCart::BOTH, JeproshopCartModelCart::ONLY_SHIPPING));
     // if cart rules are not used
     if ($type == JeproshopCartModelCart::ONLY_DISCOUNTS && !JeproshopCartRuleModelCartRule::isFeaturePublished()) {
         return 0;
     }
     // no shipping cost if is a cart with only virtual products
     $virtual = $this->isVirtualCart();
     if ($virtual && $type == JeproshopCartModelCart::ONLY_SHIPPING) {
         return 0;
     }
     if ($virtual && $type == JeproshopCartModelCart::BOTH) {
         $type = JeproshopCartModelCart::BOTH_WITHOUT_SHIPPING;
     }
     if ($with_shipping || $type == JeproshopCartModelCart::ONLY_DISCOUNTS) {
         if (is_null($products) && is_null($carrier_id)) {
             $shipping_fees = $this->getTotalShippingCost(null, (bool) $withTaxes);
         } else {
             $shipping_fees = $this->getPackageShippingCost($carrier_id, (bool) $withTaxes, null, $products);
         }
     } else {
         $shipping_fees = 0;
     }
     if ($type == JeproshopCartModelCart::ONLY_SHIPPING) {
         return $shipping_fees;
     }
     if ($type == JeproshopCartModelCart::ONLY_PRODUCTS_WITHOUT_SHIPPING) {
         $type = JeproshopCartModelCart::ONLY_PRODUCTS;
     }
     $param_product = true;
     if (is_null($products)) {
         $param_product = false;
         $products = $this->getProducts();
     }
     if ($type == JeproshopCartModelCart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING) {
         foreach ($products as $key => $product) {
             if ($product->is_virtual) {
                 unset($products[$key]);
             }
         }
         $type = JeproshopCartModelCart::ONLY_PRODUCTS;
     }
     $order_total = 0;
     if (JeproshopTaxModelTax::taxExcludedOption()) {
         $with_taxes = false;
     }
     foreach ($products as $product) {
         // products refer to the cart details
         if ($virtual_context->shop->shop_id != $product->shop_id) {
             $virtual_context->shop = new JeproshopShopModelShop((int) $product->shop_id);
         }
         if (JeproshopSettingModelSetting::getValue('PS_TAX_ADDRESS_TYPE') == 'address_invoice_id') {
             $address_id = (int) $this->address_invoice_id;
         } else {
             $address_id = (int) $product->address_delivery_id;
         }
         // Get delivery address of the product from the cart
         if (!JeproshopAddressModelAddress::addressExists($address_id)) {
             $address_id = null;
         }
         $null = null;
         if ($this->_taxCalculationMethod == COM_JEPROSHOP_TAX_EXCLUDED) {
             // Here taxes are computed only once the quantity has been applied to the product price
             $price = JeproshopProductModelProduct::getStaticPrice((int) $product->product_id, false, (int) $product->product_attribute_id, 2, null, false, true, $product->cart_quantity, false, (int) $this->customer_id ? (int) $this->customer_id : null, (int) $this->cart_id, $address_id, $null, true, true, $virtual_context);
             $total_ecotax = $product->ecotax * (int) $product->cart_quantity;
             $total_price = $price * (int) $product->cart_quantity;
             if ($withTaxes) {
                 $product_tax_rate = (double) JeproshopTaxModelTax::getProductTaxRate((int) $product->product_id, (int) $address_id, $virtual_context);
                 $product_eco_tax_rate = JeproshopTaxModelTax::getProductEcotaxRate((int) $address_id);
                 $total_price = ($total_price - $total_ecotax) * (1 + $product_tax_rate / 100);
                 $total_ecotax = $total_ecotax * (1 + $product_eco_tax_rate / 100);
                 $total_price = JeproshopTools::roundPrice($total_price + $total_ecotax, 2);
             }
         } else {
             if ($withTaxes) {
                 $price = JeproshopProductModelProduct::getStaticPrice((int) $product->product_id, true, (int) $product->product_attribute_id, 2, null, false, true, $product->cart_quantity, false, (int) $this->customer_id ? (int) $this->customer_id : null, (int) $this->cart_id, (int) $address_id ? (int) $address_id : null, $null, true, true, $virtual_context);
             } else {
                 $price = JeproshopProductModelProduct::getStaticPrice((int) $product->product_id, false, (int) $product->product_attribute_id, 2, null, false, true, $product->cart_quantity, false, (int) $this->customer_id ? (int) $this->customer_id : null, (int) $this->cart_id, (int) $address_id ? (int) $address_id : null, $null, true, true, $virtual_context);
             }
             $total_price = JeproshopTools::roundPrice($price * (int) $product->cart_quantity, 2);
         }
         $order_total += $total_price;
     }
     $order_total_products = $order_total;
     if ($type == JeproshopCartModelCart::ONLY_DISCOUNTS) {
         $order_total = 0;
     }
     // Wrapping Fees
     $wrapping_fees = 0;
     if ($this->gift) {
         $wrapping_fees = JeproshopTools::convertPrice(JeproshopTools::roundPrice($this->getGiftWrappingPrice($withTaxes), 2), JeproshopCurrencyModelCurrency::getCurrencyInstance((int) $this->currency_id));
     }
     if ($type == JeproshopCartModelCart::ONLY_WRAPPING) {
         return $wrapping_fees;
     }
     $order_total_discount = 0;
     if (!in_array($type, array(JeproshopCartModelCart::ONLY_SHIPPING, JeproshopCartModelCart::ONLY_PRODUCTS)) && JeproshopCartRuleModelCartRule::isFeaturePublished()) {
         // First, retrieve the cart rules associated to this "getOrderTotal"
         if ($with_shipping || $type == JeproshopCartModelCart::ONLY_DISCOUNTS) {
             $cart_rules = $this->getCartRules(JeproshopCartRuleModelCartRule::FILTER_ACTION_ALL);
         } else {
             $cart_rules = $this->getCartRules(CartRule::FILTER_ACTION_REDUCTION);
             // Cart Rules array are merged manually in order to avoid doubles
             foreach ($this->getCartRules(JeproshopCartRuleModelCartRule::FILTER_ACTION_GIFT) as $tmp_cart_rule) {
                 $flag = false;
                 foreach ($cart_rules as $cart_rule) {
                     if ($tmp_cart_rule->cart_rule_id == $cart_rule->cart_rule_id) {
                         $flag = true;
                     }
                 }
                 if (!$flag) {
                     $cart_rules[] = $tmp_cart_rule;
                 }
             }
         }
         $id_address_delivery = 0;
         if (isset($products[0])) {
             $id_address_delivery = is_null($products) ? $this->address_delivery_id : $products[0]->address_delivery_id;
         }
         $package = array('id_carrier' => $carrier_id, 'id_address' => $id_address_delivery, 'products' => $products);
         // Then, calculate the contextual value for each one
         foreach ($cart_rules as $cart_rule) {
             // If the cart rule offers free shipping, add the shipping cost
             if (($with_shipping || $type == Cart::ONLY_DISCOUNTS) && $cart_rule['obj']->free_shipping) {
                 $order_total_discount += Tools::ps_round($cart_rule['obj']->getContextualValue($with_taxes, $virtual_context, CartRule::FILTER_ACTION_SHIPPING, $param_product ? $package : null, $use_cache), 2);
             }
             // If the cart rule is a free gift, then add the free gift value only if the gift is in this package
             if ((int) $cart_rule['obj']->gift_product) {
                 $in_order = false;
                 if (is_null($products)) {
                     $in_order = true;
                 } else {
                     foreach ($products as $product) {
                         if ($cart_rule['obj']->gift_product == $product['id_product'] && $cart_rule['obj']->gift_product_attribute == $product['id_product_attribute']) {
                             $in_order = true;
                         }
                     }
                 }
                 if ($in_order) {
                     $order_total_discount += $cart_rule['obj']->getContextualValue($with_taxes, $virtual_context, CartRule::FILTER_ACTION_GIFT, $package, $use_cache);
                 }
             }
             // If the cart rule offers a reduction, the amount is prorated (with the products in the package)
             if ($cart_rule['obj']->reduction_percent > 0 || $cart_rule['obj']->reduction_amount > 0) {
                 $order_total_discount += Tools::ps_round($cart_rule['obj']->getContextualValue($with_taxes, $virtual_context, CartRule::FILTER_ACTION_REDUCTION, $package, $use_cache), 2);
             }
         }
         $order_total_discount = min(JeproshopTools::roundPrice($order_total_discount, 2), $wrapping_fees + $order_total_products + $shipping_fees);
         $order_total -= $order_total_discount;
     }
     if ($type == JeproshopCartModelCart::BOTH) {
         $order_total += $shipping_fees + $wrapping_fees;
     }
     if ($order_total < 0 && $type != JeproshopCartModelCart::ONLY_DISCOUNTS) {
         return 0;
     }
     if ($type == JeproshopCartModelCart::ONLY_DISCOUNTS) {
         return $order_total_discount;
     }
     return JeproshopTools::roundPrice((double) $order_total, 2);
 }
コード例 #5
0
ファイル: currency.php プロジェクト: jeprodev/jeproshop
 public function deleteSelection($selection)
 {
     if (!is_array($selection)) {
         return false;
     }
     $res = array();
     foreach ($selection as $currency_id) {
         $currency = new JeproshopCurrencyModelCurrency((int) $currency_id);
         $res[$currency_id] = $currency->delete();
     }
     foreach ($res as $value) {
         if (!$value) {
             return false;
         }
     }
     return true;
 }
コード例 #6
0
ファイル: cart.php プロジェクト: jeprodev/jeproshop
 /**
  * Return package shipping cost
  *
  * @param integer $carrier_id Carrier ID (default : current carrier)
  * @param boolean $use_tax
  * @param JeproshopCountryModelCountry $default_country
  * @param Array $product_list
  * @param array $product_list List of product concerned by the shipping. If null, all the product of the cart are used to calculate the shipping cost
  *
  * @return float Shipping total
  */
 public function getPackageShippingCost($carrier_id = null, $use_tax = true, JeproshopCountryModelCountry $default_country = null, $product_list = null, $zone_id = null)
 {
     if ($this->isVirtualCart()) {
         return 0;
     }
     if (!$default_country) {
         $default_country = JeproshopContext::getContext()->country;
     }
     $complete_product_list = $this->getProducts();
     if (is_null($product_list)) {
         $products = $complete_product_list;
     } else {
         $products = $product_list;
     }
     if (JeproshopSettingModelSetting::getValue('tax_address_type') == 'address_invoice_id') {
         $address_id = (int) $this->address_invoice_id;
     } elseif (count($product_list)) {
         $prod = current($product_list);
         $address_id = (int) $prod->address_delivery_id;
     } else {
         $address_id = null;
     }
     if (!JeproshopAddressModelAddress::addressExists($address_id)) {
         $address_id = null;
     }
     $cache_id = 'get_package_shipping_cost_' . (int) $this->cart_id . '_' . (int) $address_id . '_' . (int) $carrier_id . '_' . (int) $use_tax . '_' . (int) $default_country->country_id;
     if ($products) {
         foreach ($products as $product) {
             $cache_id .= '_' . (int) $product->product_id . '_' . (int) $product->product_attribute_id;
         }
     }
     if (JeproshopCache::isStored($cache_id)) {
         return JeproshopCache::retrieve($cache_id);
     }
     // Order total in default currency without fees
     $order_total = $this->getOrderTotal(true, JeproshopCartModelCart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING, $product_list);
     // Start with shipping cost at 0
     $shipping_cost = 0;
     // If no product added, return 0
     if (!count($products)) {
         JeproshopCache::store($cache_id, $shipping_cost);
         return $shipping_cost;
     }
     if (!isset($zone_id)) {
         // Get id zone
         if (!$this->isMultiAddressDelivery() && isset($this->address_delivery_id) && $this->address_delivery_id && JeproshopCustomerModelCustomer::customerHasAddress($this->customer_id, $this->address_delivery_id)) {
             $zone_id = JeproshopAddressModelAddress::getZoneIdByAddressId((int) $this->address_delivery_id);
         } else {
             if (!JeproshopValidator::isLoadedObject($default_country, 'country_id')) {
                 $default_country = new Country(JeproshopSettingModelSeting::getValue('PS_COUNTRY_DEFAULT'), JeproshopSettingModelSeting::getValue('PS_LANG_DEFAULT'));
             }
             $zone_id = (int) $default_country->zone_id;
         }
     }
     if ($carrier_id && !$this->isCarrierInRange((int) $carrier_id, (int) $zone_id)) {
         $carrier_id = '';
     }
     if (empty($carrier_id) && $this->isCarrierInRange((int) JeproshopSettingModelSeting::getValue('default_carrier'), (int) $zone_id)) {
         $carrier_id = (int) JeproshopSettingModelSeting::getValue('default_carrier');
     }
     $total_package_without_shipping_tax_inc = $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING, $product_list);
     if (empty($carrier_id)) {
         if ((int) $this->customer_id) {
             $customer = new JeproshopCustomerModelCustomer((int) $this->customer_id);
             $result = JeproshopCarrierModelCarrier::getCarriers((int) JeproshopSettingModelSeting::getValue('default_lang'), true, false, (int) $zone_id, $customer->getGroups());
             unset($customer);
         } else {
             $result = JeproshopCarrierModelCarrier::getCarriers((int) JeproshopSettingModelSeting::getValue('default_lang'), true, false, (int) $zone_id);
         }
         foreach ($result as $k => $row) {
             if ($row->carrier_id == JeproshopSettingModelSeting::getValue('default_carrier')) {
                 continue;
             }
             if (!isset(self::$_carriers[$row->carrier_id])) {
                 self::$_carriers[$row->carrier_id] = new JeproshopCarrierModelCarrier((int) $row->carrier_id);
             }
             $carrier = self::$_carriers[$row->carrier_id];
             // Get only carriers that are compliant with shipping method
             if ($carrier->getShippingMethod() == JeproshopCarrierModelCarrier::WEIGHT_SHIPPING_METHOD && $carrier->getMaxDeliveryPriceByWeight((int) $zone_id) === false || $carrier->getShippingMethod() == JeproshopCarrierModelCarrier::PRICE_SHIPPING_METHOD && $carrier->getMaxDeliveryPriceByPrice((int) $zone_id) === false) {
                 unset($result[$k]);
                 continue;
             }
             // If out-of-range behavior carrier is set on "Deactivated carrier"
             if ($row->range_behavior) {
                 $check_delivery_price_by_weight = JeproshopCarrierModelCarrier::checkDeliveryPriceByWeight($row->carrier_id, $this->getTotalWeight(), (int) $zone_id);
                 $total_order = $total_package_without_shipping_tax_inc;
                 $check_delivery_price_by_price = JeproshopCarrierModelCarrier::checkDeliveryPriceByPrice($row->carrier_id, $total_order, (int) $zone_id, (int) $this->currency_id);
                 // Get only carriers that have a range compatible with cart
                 if ($carrier->getShippingMethod() == JeproshopCarrierModelCarrier::WEIGHT_SHIPPING_METHOD && !$check_delivery_price_by_weight || $carrier->getShippingMethod() == JeproshopCarrierModelCarrier::PRICE_SHIPPING_METHOD && !$check_delivery_price_by_price) {
                     unset($result[$k]);
                     continue;
                 }
             }
             if ($carrier->getShippingMethod() == JeproshopCarrierModelCarrier::WEIGHT_SHIPPING_METHOD) {
                 $shipping = $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), (int) $zone_id);
             } else {
                 $shipping = $carrier->getDeliveryPriceByPrice($order_total, (int) $zone_id, (int) $this->currency_id);
             }
             if (!isset($min_shipping_price)) {
                 $min_shipping_price = $shipping;
             }
             if ($shipping <= $min_shipping_price) {
                 $carrier_id = (int) $row->carrier_id;
                 $min_shipping_price = $shipping;
             }
         }
     }
     if (empty($carrier_id)) {
         $carrier_id = JeproshopSettingModelSeting::getValue('default_carrier');
     }
     if (!isset(self::$_carriers[$carrier_id])) {
         self::$_carriers[$carrier_id] = new JeproshopCarrierModelCarrier((int) $carrier_id, JeproshopSettingModelSeting::getValue('default_lang'));
     }
     $carrier = self::$_carriers[$carrier_id];
     // No valid Carrier or $carrier_id <= 0 ?
     if (!JeproshopValidator::isLoadedObject($carrier, 'carrier_id')) {
         JeproshopCache::store($cache_id, 0);
         return 0;
     }
     if (!$carrier->published) {
         JeproshopCache::store($cache_id, $shipping_cost);
         return $shipping_cost;
     }
     // Free fees if free carrier
     if ($carrier->is_free == 1) {
         JeproshopCache::store($cache_id, 0);
         return 0;
     }
     // Select carrier tax
     if ($use_tax && !JeproshopTaxModelTax::excludedTaxOption()) {
         $address = JeproshopAddressModelAddress::initialize((int) $address_id);
         $carrier_tax = $carrier->getTaxesRate($address);
     }
     $configuration = JeproshopSettingModelSeting::getValueMultiple(array('PS_SHIPPING_FREE_PRICE', 'PS_SHIPPING_HANDLING', 'PS_SHIPPING_METHOD', 'PS_SHIPPING_FREE_WEIGHT'));
     // Free fees
     $free_fees_price = 0;
     if (isset($configuration['PS_SHIPPING_FREE_PRICE'])) {
         $free_fees_price = JeproshopValidator::convertPrice((double) $configuration['PS_SHIPPING_FREE_PRICE'], JeproshopCurrencyModelCurrency::getCurrencyInstance((int) $this->currency_id));
     }
     $orderTotalWithDiscounts = $this->getOrderTotal(true, JeproshopCartModelCart::BOTH_WITHOUT_SHIPPING, null, null, false);
     if ($orderTotalWithDiscounts >= (double) $free_fees_price && (double) $free_fees_price > 0) {
         Cache::store($cache_id, $shipping_cost);
         return $shipping_cost;
     }
     if (isset($configuration['PS_SHIPPING_FREE_WEIGHT']) && $this->getTotalWeight() >= (double) $configuration['PS_SHIPPING_FREE_WEIGHT'] && (double) $configuration['PS_SHIPPING_FREE_WEIGHT'] > 0) {
         JeproshopCache::store($cache_id, $shipping_cost);
         return $shipping_cost;
     }
     // Get shipping cost using correct method
     if ($carrier->range_behavior) {
         if (!isset($zone_id)) {
             // Get id zone
             if (isset($this->address_delivery_id) && $this->address_delivery_id && JeproshopCustomerModelCustomer::customerHasAddress($this->customer_id, $this->address_delivery_id)) {
                 $zone_id = JeproshopAddressModelAddress::getZoneIdByAddressId((int) $this->address_delivery_id);
             } else {
                 $zone_id = (int) $default_country->zone_id;
             }
         }
         if ($carrier->getShippingMethod() == JeproshopCarrierModelCarrier::WEIGHT_SHIPPING_METHOD && !JeproshopCarrierModelCarrier::checkDeliveryPriceByWeight($carrier->id, $this->getTotalWeight(), (int) $zone_id) || $carrier->getShippingMethod() == JeproshopCarrierModelCarrier::PRICE_SHIPPING_METHOD && !JeproshopCarrierModelCarrier::checkDeliveryPriceByPrice($carrier->id, $total_package_without_shipping_tax_inc, $zone_id, (int) $this->currency_id)) {
             $shipping_cost += 0;
         } else {
             if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT) {
                 $shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), $zone_id);
             } else {
                 // by price
                 $shipping_cost += $carrier->getDeliveryPriceByPrice($order_total, $zone_id, (int) $this->currency_id);
             }
         }
     } else {
         if ($carrier->getShippingMethod() == JeproshopCarrierModelCarrier::WEIGHT_SHIPPING_METHOD) {
             $shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), $zone_id);
         } else {
             $shipping_cost += $carrier->getDeliveryPriceByPrice($order_total, $zone_id, (int) $this->currency_id);
         }
     }
     // Adding handling charges
     if (isset($configuration['PS_SHIPPING_HANDLING']) && $carrier->shipping_handling) {
         $shipping_cost += (double) $configuration['PS_SHIPPING_HANDLING'];
     }
     // Additional Shipping Cost per product
     foreach ($products as $product) {
         if (!$product->is_virtual) {
             $shipping_cost += $product->additional_shipping_cost * $product->cart_quantity;
         }
     }
     $shipping_cost = JeproshopValidator::convertPrice($shipping_cost, JeproshopCurrencyModelCurrency::getCurrencyInstance((int) $this->currency_id));
     /*/get external shipping cost from module
             if ($carrier->shipping_external)
             {
                 $module_name = $carrier->external_module_name;
                 $module = Module::getInstanceByName($module_name);
     
                 if (JeproshopValidator::isLoadedObject($module))
                 {
                     if (array_key_exists('carrier_id', $module))
                         $module->carrier_id = $carrier->id;
                     if ($carrier->need_range)
                         if (method_exists($module, 'getPackageShippingCost'))
                             $shipping_cost = $module->getPackageShippingCost($this, $shipping_cost, $products);
                         else
                             $shipping_cost = $module->getOrderShippingCost($this, $shipping_cost);
                     else
                         $shipping_cost = $module->getOrderShippingCostExternal($this);
     
                     // Check if carrier is available
                     if ($shipping_cost === false)
                     {
                         JeproshopCache::store($cache_id, false);
                         return false;
                     }
                 }
                 else
                 {
                     JeproshopCache::store($cache_id, false);
                     return false;
                 }
             } */
     // Apply tax
     if ($use_tax && isset($carrier_tax)) {
         $shipping_cost *= 1 + $carrier_tax / 100;
     }
     $shipping_cost = (double) JeproshopValidator::roundPrice((double) $shipping_cost, 2);
     JeproshopCache::store($cache_id, $shipping_cost);
     return $shipping_cost;
 }
コード例 #7
0
ファイル: view.html.php プロジェクト: jeprodev/jeproshop
 public function renderAddForm($tpl = null)
 {
     //print_r(JeproshopCustomerModelCustomer::searchByName('je'));
     $context = JeproshopContext::getContext();
     if ($context->shop->getShopContext() != JeproshopShopModelShop::CONTEXT_SHOP && JeproshopShopModelShop::isFeaturePublished()) {
         $context->controller->has_errors = true;
         $this->l('You have to select a shop before creating new orders.');
     }
     $app = JFactory::getApplication();
     $cart_id = (int) $app->input->get('cart_id');
     $cart = new JeproshopCartModelCart((int) $cart_id);
     if ($cart_id && !JeproshopTools::isLoadedObject($cart, 'cart_id')) {
         $context->controller->has_errors = true;
         $this->l('This cart does not exists');
     }
     if ($cart_id && JeproshopTools::isLoadedObject($cart, 'cart_id') && !$cart->customer_id) {
         $context->controller->has_errors = true;
         $this->l('The cart must have a customer');
     }
     if ($context->controller->has_errors) {
         return false;
     }
     /*parent::renderForm();
             unset($this->toolbar_btn['save']);
             $this->addJqueryPlugin(array('autocomplete', 'fancybox', 'typewatch'));
     */
     $defaults_order_statues = array('cheque' => (int) JeproshopSettingModelSetting::getValue('order_status_cheque'), 'bank_wire' => (int) JeproshopSettingModelSetting::getValue('order_status_bank_wire'), 'cash_on_delivery' => (int) JeproshopSettingModelSetting::getValue('order_status_preparation'), 'other' => (int) JeproshopSettingModelSetting::getValue('order_status_payment'));
     $payment_modules = array();
     /*  foreach (PaymentModule::getInstalledPaymentModules() as $p_module)
                 $payment_modules[] = Module::getInstanceById((int)$p_module['id_module']);
     */
     $recyclable_pack = (int) JeproshopSettingModelSetting::getValue('offer_recycled_wrapping');
     $this->assignRef('recyclable_pack', $recyclable_pack);
     $gift_wrapping = (int) JeproshopSettingModelSetting::getValue('offer_gift_wrapping');
     $this->assignRef('gift_wrapping', $gift_wrapping);
     $this->assignRef('cart', $cart);
     $this->assignRef('cart_id', $cart_id);
     $currencies = JeproshopCurrencyModelCurrency::getCurrenciesByShopId(JeproshopContext::getContext()->shop->shop_id);
     $this->assignRef('currencies', $currencies);
     $languages = JeproshopLanguageModelLanguage::getLanguages(true, JeproshopContext::getContext()->shop->shop_id);
     $this->assignRef('languages', $languages);
     $this->assignRef('payment_modules', $payment_modules);
     $order_statues = JeproshopOrderStatusModelOrderStatus::getOrderStatus((int) JeproshopContext::getContext()->language->lang_id);
     $this->assignRef('order_statues', $order_statues);
     $this->assignRef('defaults_order_statues', $defaults_order_statues);
     /*    'show_toolbar' => $this->show_toolbar,
               'toolbar_btn' => $this->toolbar_btn,
               'toolbar_scroll' => $this->toolbar_scroll,
               'title' => array($this->l('Orders'), $this->l('Create order'))
           ));* /
           $this->content .= $this->createTemplate('form.tpl')->fetch(); */
     $this->addToolBar();
     $this->sideBar = JHtmlSideBar::render();
     parent::display($tpl);
 }
コード例 #8
0
ファイル: view.html.php プロジェクト: jeprodev/jeproshop
 private function initPriceForm()
 {
     if ($this->context == null) {
         $this->context = JeproshopContext::getContext();
     }
     if ($this->product->product_id) {
         $shops = JeproshopShopModelShop::getShops();
         $countries = JeproshopCountryModelCountry::getStaticCountries($this->context->language->lang_id);
         $groups = JeproshopGroupModelGroup::getStaticGroups($this->context->language->lang_id);
         $currencies = JeproshopCurrencyModelCurrency::getStaticCurrencies();
         $attributes = $this->product->getAttributesGroups((int) $this->context->language->lang_id);
         $combinations = array();
         if (count($attributes)) {
             foreach ($attributes as $attribute) {
                 $combinations[$attribute->product_attribute_id] = new JObject();
                 $combinations[$attribute->product_attribute_id]->product_attribute_id = $attribute->product_attribute_id;
                 if (!isset($combinations[$attribute->product_attribute_id]->attributes)) {
                     $combinations[$attribute->product_attribute_id]->attributes = '';
                 }
                 if (isset($combinations[$attribute->product_attribute_id])) {
                     $combinations[$attribute->product_attribute_id]->attributes .= $attribute->attribute_name . ' - ';
                     $combinations[$attribute->product_attribute_id]->price = JeproshopTools::displayPrice(JeproshopTools::convertPrice(JeproshopProductModelProduct::getStaticPrice((int) $this->product->product_id, false, $attribute->product_attribute_id), $this->context->currency), $this->context->currency);
                 }
             }
             foreach ($combinations as $combination) {
                 if (isset($combination->attributes)) {
                     $combination->attributes = rtrim($combination->attributes, ' - ');
                 }
             }
         }
         $specificPriceModificationForm = $this->displaySpecificPriceModificationForm($this->context->currency, $shops, $currencies, $countries, $groups);
         $this->assignRef('specific_price_modification_form', $specificPriceModificationForm);
         $this->assignRef('ecotax_tax_excluded', $this->product->ecotax);
         //$this->applyTaxToEcotax();
         $this->assignRef('shops', $shops);
         /*$admin_one_shop = count($this->context->employee->getAssociatedShops()) == 1;
           $this->assignRef('admin_one_shop', $admin_one_shop); */
         $this->assignRef('currencies', $currencies);
         $this->assignRef('currency', $this->context->currency);
         $this->assignRef('countries', $countries);
         $this->assignRef('groups', $groups);
         $this->assignRef('combinations', $combinations);
         $multiShop = JeproshopShopModelShop::isFeaturePublished();
         $this->assignRef('multi_shop', $multiShop);
     } else {
         JError::raiseWarnig(JText::_('COM_JEPROSHOP_YOU_MUST_SAVE_THIS_PRODUCT_BEFORE_ADDING_SPECIFIC_PRICING_MESSAGE'));
         $this->product->tax_rules_group_id = JeproshopProductModelProduct::getTaxRulesMostUsedGroupId();
         $this->assignRef('ecotax_tax_excluded', 0);
     }
     $use_tax = JeproshopSettingModelSetting::getValue('use_tax');
     $this->assignRef('use_tax', $use_tax);
     $use_ecotax = JeproshopSettingModelSetting::getValue('use_eco_tax');
     $this->assignRef('use_ecotax', $use_ecotax);
     $tax_rules_groups = JeproshopTaxRulesGroupModelTaxRulesGroup::getTaxRulesGroups(true);
     $this->assignRef('tax_rules_groups', $tax_rules_groups);
     $taxesRatesByGroup = JeproshopTaxRulesGroupModelTaxRulesGroup::getAssociatedTaxRatesByCountryId($this->context->country->country_id);
     $this->assignRef('taxesRatesByGroup', $taxesRatesByGroup);
     $ecotaxTaxRate = JeproshopTaxModelTax::getProductEcotaxRate();
     $this->assignRef('ecotaxTaxRate', $ecotaxTaxRate);
     $tax_exclude_tax_option = JeproshopTaxModelTax::taxExcludedOption();
     $this->assignRef('tax_exclude_tax_option', $tax_exclude_tax_option);
     $this->product->price = JeproshopTools::convertPrice($this->product->price, $this->context->currency, true, $this->context);
     if ($this->product->unit_price_ratio != 0) {
         $unit_price = JeproshopTools::roundPrice($this->product->price / $this->product->unit_price_ratio, 2);
     } else {
         $unit_price = 0;
     }
     $this->assignRef('unit_price', $unit_price);
 }
コード例 #9
0
ファイル: product.php プロジェクト: jeprodev/jeproshop
 /**
  * Post treatment for suppliers
  */
 public function processSuppliers()
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDBO();
     $product = new JeproshopProductModelProduct((int) $app->input->get('product_id'));
     if (JeproshopTools::isLoadedObject($product, 'product_id')) {
         // Get all id_product_attribute
         $attributes = $product->getAttributesResume($this->context->language->lang_id);
         if (empty($attributes)) {
             $attribute = new JObject();
             $attribute->set('product_attribute_id', 0);
             $attribute->set('attribute_designation', '');
             $attributes[] = $attribute;
         }
         // Get all available suppliers
         $suppliers = JeproshopSupplierModelSupplier::getSuppliers();
         // Get already associated suppliers
         $associated_suppliers = JeproshopProductSupplierModelProductSupplier::getSupplierCollection($product->product_id);
         $input = JRequest::get('post');
         $product_data = $input['supplier'];
         $suppliers_to_associate = array();
         $new_default_supplier = 0;
         if (isset($product_data['default_supplier'])) {
             $new_default_supplier = (int) $product_data['default_supplier'];
         }
         // Get new associations
         foreach ($suppliers as $supplier) {
             if (isset($product_data['check_supplier_' . $supplier->supplier_id])) {
                 $suppliers_to_associate[] = $supplier->supplier_id;
             }
         }
         // Delete already associated suppliers if needed
         foreach ($associated_suppliers as $key => $associated_supplier) {
             if (!in_array($associated_supplier->supplier_id, $suppliers_to_associate)) {
                 $associated_supplier->delete();
                 unset($associated_suppliers[$key]);
             }
         }
         // Associate suppliers
         foreach ($suppliers_to_associate as $supplier_id) {
             $to_add = true;
             foreach ($associated_suppliers as $as) {
                 if ($supplier_id == $as->supplier_id) {
                     $to_add = false;
                 }
             }
             if ($to_add) {
                 $product_supplier = new JeproshopProductSupplierModelProductSupplier();
                 $product_supplier->product_id = $product->product_id;
                 $product_supplier->product_attribute_id = 0;
                 $product_supplier->supplier_id = $supplier_id;
                 if ($this->context->currency->currency_id) {
                     $product_supplier->currency_id = (int) $this->context->currency->currency_id;
                 } else {
                     $product_supplier->currency_id = (int) JeproshopSettingModelSetting::getValue('default_currency');
                 }
                 $product_supplier->save();
                 $associated_suppliers[] = $product_supplier;
             }
         }
         // Manage references and prices
         foreach ($attributes as $attribute) {
             foreach ($associated_suppliers as $supplier) {
                 if ($product_data['supplier_reference_' . $product->product_id . '_' . $attribute->product_attribute_id . '_' . $supplier->supplier_id] || $product_data['product_price_' . $product->product_id . '_' . $attribute->product_attribute_id . '_' . $supplier->supplier_id] && $product_data['product_price_currency_' . $product->product_id . '_' . $attribute->product_attribute_id . '_' . $supplier->supplier_id]) {
                     $reference = JFactory::getDBO()->quote($app->input->get('supplier_reference_' . $product->product_id . '_' . $attribute->product_attribute_id . '_' . $supplier->supplier_id, ''));
                     $price = (double) str_replace(array(' ', ','), array('', '.'), $app->input->get('product_price_' . $product->product_id . '_' . $attribute->product_attribute_id . '_' . $supplier->supplier_id, 0));
                     $price = JeproshopTools::roundPrice($price, 6);
                     $currency_id = (int) $app->input->get('product_price_currency_' . $product->product_id . '_' . $attribute->product_attribute_id . '_' . $supplier->supplier_id, 0);
                     if ($currency_id <= 0 || (!($result = JeproshopCurrencyModelCurrency::getCurrency($currency_id)) || empty($result))) {
                         $this->context->controller->has_errors = JText::_('The selected currency is not valid' . __FILE__ . 'on line ' . __LINE__);
                     }
                     // Save product-supplier data
                     $product_supplier_id = (int) JeproshopProductSupplierModelProductSupplier::getIdByProductAndSupplier($product->product_id, $attribute->product_attribute_id, $supplier->supplier_id);
                     if (!$product_supplier_id) {
                         $product->addSupplierReference($supplier->supplier_id, (int) $attribute->product_attribute_id, $reference, (double) $price, (int) $currency_id);
                         if ($product->supplier_id == $supplier->supplier_id) {
                             if ((int) $attribute->product_attribute_id > 0) {
                                 $data = new JObject();
                                 $data->set('supplier_reference', $db->quote($reference));
                                 $data->set('wholesale_price', (double) JeproshopTools::convertPrice($price, $currency_id));
                                 $where = " combination.product_id = " . (int) $product->product_id . " AND combination.product_attribute_id = " . (int) $attribute->product_attribute_id;
                                 JeproshopCombinationModelCombination::updateMultishopTable($data, $where);
                             } else {
                                 $product->wholesale_price = (double) Tools::convertPrice($price, $currency_id);
                                 //converted in the default currency
                                 $product->supplier_reference = $db->quote($reference);
                                 $product->update();
                             }
                         }
                     } else {
                         $product_supplier = new JeproshopProductSupplierModelProductSupplier($product_supplier_id);
                         $product_supplier->currency_id = (int) $currency_id;
                         $product_supplier->product_supplier_price_te = (double) $price;
                         $product_supplier->product_supplier_reference = $db->quote($reference);
                         $product_supplier->update();
                     }
                 } elseif ($app->input->get('supplier_reference_' . $product->product_id . '_' . $attribute->product_attribute_id . '_' . $supplier->supplier_id)) {
                     //int attribute with default values if possible
                     if ((int) $attribute->product_attribute_id > 0) {
                         $product_supplier = new JeproshopProductSupplierModelProductSupplier();
                         $product_supplier->product_id = $product->product_id;
                         $product_supplier->product_attribute_id = (int) $attribute->product_attribute_id;
                         $product_supplier->supplier_id = $supplier->supplier_id;
                         $product_supplier->save();
                     }
                 }
             }
         }
         /*
         			// Manage default supplier for product
         			if ($new_default_supplier != $product->supplier_id)	{
         				$product->supplier_id = $new_default_supplier;
         				$query = "UPDATE " . $db->quoteName('#__jeproshop_product') . " SET " . $db->quoteName('supplier_id') . " = " . (int)$new_default_supplier;
         				$query .= " WHERE " . $db->quoteName('product_id') . " = " . (int)$product->product_id;
         		
         				$db->setQuery($query);
         				$db->query();
         			} */
     }
 }
コード例 #10
0
ファイル: controller.php プロジェクト: jeprodev/jeproshop
 public function initialize()
 {
     if (self::$initialized) {
         return;
     }
     self::$initialized = true;
     $app = JFactory::getApplication();
     $context = JeproshopContext::getContext();
     $view = $app->input->get('view', 'default');
     $viewClass = $this->getView($view, JFactory::getDocument()->getType());
     if (JeproshopTools::usingSecureMode()) {
         $this->ssl_enabled = true;
     }
     if (isset($context->cookie->account_created)) {
         $accountCreated = true;
         $viewClass->assignRef('account_created', $accountCreated);
         $context->cookie->account_created = 0;
     }
     JeproshopTools::setCookieLanguage($context->cookie);
     $cart_id = (int) $this->recoverCart();
     if ($cart_id) {
         $context->cookie->cart_id = $cart_id;
     }
     if ($this->authenticated && !$context->customer->isLogged($this->guest_allowed)) {
         $app->redirect('index.php?option=com_jeproshop&view=authentication');
         // todo add retun option
     }
     if (JeproshopSettingModelSetting::getValue('enable_geolocation')) {
         $defaultCountry = $this->geolocationManagement($context->country);
         if ($defaultCountry && JeproshopTools::isLoadedObject($defaultCountry, 'country_id')) {
             $context->country = $defaultCountry;
         }
     }
     $currency = JeproshopTools::setCurrency($context->cookie);
     $logout = $app->input->get('logout');
     $myLogout = $app->input->get('mylogout');
     if (isset($logout) || $context->customer->logged && JeproshopCustomerModelCustomer::isBanned($context->cutomer->customer_id)) {
         $context->customer->logout();
         //$app->input->get('')
     } elseif (isset($myLogout)) {
         $context->customer->mylogout();
     }
     if ((int) $context->cookie->cart_id) {
         $cart = new JeproshopCartModelCart($context->cookie->cart_id);
         if ($cart->orderExists()) {
             $context->cookie->cart_id = null;
             $context->cookie->check_selling_condition = false;
         } elseif ((int) JeproshopSettingModelSetting::getValue('enable_geolocation') && !in_array(strtoupper($context->cookie->iso_code_country), explode(';', JeproshopSettingModelSetting::getValue('allowed_countries'))) && $cart->numberOfProducts() && (int) JeproshopSettingModelSetting::getValue('geolocation_behavior') != -1 && !self::isInWhiteListForGeolocation() && !in_array($_SERVER['SERVER_NAME'], array('localhost', '127.0.0.1'))) {
             $context->cookie->cart_id = null;
             $cart = null;
         } elseif ($context->cookie->customer_id != $cart->customer_id || $context->cookie->lang_id != $cart->lang_id || $currency->currency_id != $cart->currency_id) {
             if ($context->cookie->customer_id) {
                 $cart->customer_id = (int) $context->cookie->customer_id;
             }
             $cart->lang_id = (int) $context->cookie->lang_id;
             $cart->currency_id = (int) $currency->currency_id;
             $cart->update();
         }
         if (isset($cart) && (!isset($cart->address_delivery_id) || $cart->address_delivery_id == 0 || !isset($cart->address_invoice_id) || $cart->address_invoice_id) && $context->cookie->customer_id) {
             $toUpdate = false;
             if (!isset($cart->address_delivery_id) || $cart->address_delivery_id == 0) {
                 $toUpdate = true;
                 $cart->address_delivery_id = (int) JeproshopAddressModelAddress::getCustomerFirstAddressId($cart->customer_id);
             }
             if (!isset($cart->address_invoice_id) || $cart->address_invoice_id == 0) {
                 $toUpdate = true;
                 $cart->address_invoice_id = (int) JeproshopAddressModelAddress::getCustomerFirstAddressId($cart->customer_id);
             }
             if ($toUpdate) {
                 $cart->update();
             }
         }
     }
     if (!isset($cart) || $cart->cart_id) {
         $cart = new JeproshopCartModelCart();
         $cart->lang_id = (int) $context->cookie->lang_id;
         $cart->currency_id = (int) $context->cookie->currency_id;
         $cart->guest_id = (int) $context->cookie->guest_id;
         $cart->shop_group_id = (int) $context->shop->shop_group_id;
         $cart->shop_id = $context->shop->shop_id;
         if ($context->cookie->customer_id) {
             $cart->customer_id = (int) $context->cookie->id_customer;
             $cart->address_delivery_id = (int) JeproshopAddressModelAddress::getCustomerFirstAddressId($cart->customer_id);
             $cart->address_invoice_id = $cart->address_delivery_id;
         } else {
             $cart->address_delivery_id = 0;
             $cart->address_invoice_id = 0;
         }
         // Needed if the merchant want to give a free product to every visitors
         $context->cart = $cart;
         JeproshopCartRuleModelCartRule::autoAddToCart($context);
     } else {
         $context->cart = $cart;
     }
     JeproshopProductModelProduct::initPricesComputation();
     $display_tax_label = $context->country->display_tax_label;
     if (isset($cart->{JeproshopSettingModelSetting::getValue('tax_address_type')}) && $cart->{JeproshopSettingModelSetting::getValue('tax_address_type')}) {
         $info = JeproshopAddressModelAddress::getCountryAndState($cart->{JeproshopSettingModelSetting::getValue('tax_address_type')});
         $country = new JeproshopCountryModelCountry((int) $info->country_id);
         $context->country = $country;
         if (JeproshopTools::isLoadedObject($country, 'country_id')) {
             $display_tax_label = $country->display_tax_label;
         }
     }
     $languages = JeproshopLanguageModelLanguage::getLanguages(true);
     $meta_language = array();
     foreach ($languages as $lang) {
         $meta_language[] = $lang->iso_code;
     }
     $compared_products = array();
     $comparatorMaxItem = JeproshopSettingModelSetting::getValue('comparator_max_item');
     if ($comparatorMaxItem && isset($context->cookie->compare_id)) {
         $compared_products = JeproshopProductComparedModelProductCompared::getComparedProducts($context->cookie->compare_id);
     }
     $mobileDevice = $context->getMobileDevice();
     $viewClass->assignRef('mobile_device', $mobileDevice);
     $viewClass->assignRef('cart', $cart);
     $viewClass->assignRef('currency', $currency);
     $viewClass->assignRef('display_tax_label', $display_tax_label);
     $isLogged = (bool) $context->customer->isLogged();
     $viewClass->assignRef('is_logged', $isLogged);
     $isGuest = (bool) $context->customer->isGuest();
     $viewClass->assignRef('is_guest', $isGuest);
     $priceRoundMode = JeproshopSettingModelSetting::getValue('price_round_mode');
     $viewClass->assignRef('price_round_mode', $priceRoundMode);
     $useTax = JeproshopSettingModelSetting::getValue('use_tax');
     $viewClass->assignRef('use_taxes', $useTax);
     $showTax = (int) JeproshopSettingModelSetting::getValue('display_tax') == 1 && JeproshopSettingModelSetting::getValue('use_tax');
     $viewClass->assignRef('show_tax', $showTax);
     $catalogMode = (bool) JeproshopSettingModelSetting::getValue('catalog_mode') || !JeproshopGroupModelGroup::getCurrent()->show_prices;
     $viewClass->assignRef('catalog_mode', $catalogMode);
     $enableB2bMode = (bool) JeproshopSettingModelSetting::getValue('enable_b2b_mode');
     $viewClass->assignRef('enable_b2b_mode', $enableB2bMode);
     $stockManagement = JeproshopSettingModelSetting::getValue('stock_management');
     $viewClass->assignRef('stock_management', $stockManagement);
     $metaLanguages = implode(',', $meta_language);
     $viewClass->assignRef('meta_languages', $metaLanguages);
     $viewClass->assignRef('languages', $languages);
     $numberOfProducts = $cart->numberOfProducts();
     $viewClass->assignRef('cart_quantities', $numberOfProducts);
     $currencies = JeproshopCurrencyModelCurrency::getCurrencies();
     $viewClass->assignRef('currencies', $currencies);
     $comparatorMaxItem = JeproshopSettingModelSetting::getValue('comparator_max_item');
     $viewClass->assignRef('comparator_max_item', $comparatorMaxItem);
     $quickView = (bool) JeproshopSettingModelSetting::getValue('quick_view');
     $viewClass->assignRef('quick_view', $quickView);
     $restrictedCountryMode = false;
     $viewClass->assignRef('restricted_country_mode', $restrictedCountryMode);
     $displayPrice = JeproshopProductModelProduct::getTaxCalculationMethod((int) $context->cookie->customer_id);
     $viewClass->assignRef('display_price', $displayPrice);
     /*$viewClass->assignRef('');
       $viewClass->assignRef('');
       $viewClass->assignRef('');*/
     $viewClass->assignRef('compared_products', $compared_products);
     /*$viewClass->assignRef('comparator_max_item', $comparatorMaxItem); */
 }