Пример #1
0
 public function __construct($cart_id = null)
 {
     $db = JFactory::getDBO();
     /*$this->def = ObjectModel::getDefinition($this);
     		$this->setDefinitionRetroCompatibility();
     
     		if ($id_lang !== null)
     			$this->id_lang = (Language::getLanguage($id_lang) !== false) ? $id_lang : Configuration::get('PS_LANG_DEFAULT');
     
     		if ($id_shop && $this->isMultishop())
     		{
     			$this->id_shop = (int)$id_shop;
     			$this->get_shop_from_context = false;
     		} */
     if ($this->isMultishop() && !$this->shop_id) {
         $this->shop_id = JeproshopContext::getContext()->shop->shop_id;
     }
     if ($cart_id) {
         // Load object from database if object id is present
         $cache_id = 'jeproshop_model_cart_' . (int) $cart_id . '_' . (int) $this->shop_id;
         if (!JeproshopCache::isStored($cache_id)) {
             $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_cart') . " AS cart WHERE cart.cart_id = " . (int) $cart_id;
             // Get lang informations
             /*if ($id_lang)
             		{
             			$sql->leftJoin($this->def['table'].'_lang', 'b', 'a.'.$this->def['primary'].' = b.'.$this->def['primary'].' AND b.id_lang = '.(int)$id_lang);
             			if ($this->id_shop && !empty($this->def['multilang_shop']))
             				$sql->where('b.id_shop = '.$this->id_shop);
             		} */
             // Get shop informations
             if (JeproshopShopModelShop::isTableAssociated('cart')) {
                 $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_cart_shop') . " AS cart_shop ON(cart.cart_id =";
                 $query .= " = cart_shop.cart_id AND cart_shop.shop_id = " . (int) $this->shop_id . ")";
             }
             $db->setQuery($query);
             $cart_data = $db->loadObject();
             if ($cart_data) {
                 /*if (!$id_lang && isset($this->def['multilang']) && $this->def['multilang'])
                 		{
                 			$sql = 'SELECT * FROM `'.pSQL(_DB_PREFIX_.$this->def['table']).'_lang`
                 					WHERE `'.bqSQL($this->def['primary']).'` = '.(int)$id
                 					.(($this->id_shop && $this->isLangMultishop()) ? ' AND `id_shop` = '.$this->id_shop : '');
                 			if ($object_datas_lang = ObjectModel::$db->executeS($sql))
                 				foreach ($object_datas_lang as $row)
                 					foreach ($row as $key => $value)
                 					{
                 						if (array_key_exists($key, $this) && $key != $this->def['primary'])
                 						{
                 							if (!isset($object_datas[$key]) || !is_array($object_datas[$key]))
                 								$object_datas[$key] = array();
                 							$object_datas[$key][$row['id_lang']] = $value;
                 						}
                 					}
                 		} */
                 JeproshopCache::store($cache_id, $cart_data);
             }
         } else {
             $cart_data = JeproshopCache::retrieve($cache_id);
         }
         if ($cart_data) {
             $this->cart_id = (int) $cart_id;
             foreach ($cart_data as $key => $value) {
                 if (array_key_exists($key, $this)) {
                     $this->{$key} = $value;
                 }
             }
         }
     }
     /*
     if (!is_null($id_lang))
     	$this->id_lang = (int)(Language::getLanguage($id_lang) !== false) ? $id_lang : Configuration::get('PS_LANG_DEFAULT');
     */
     if ($this->customer_id) {
         if (isset(JeproshopContext::getContext()->customer) && JeproshopContext::getContext()->customer->customer_id == $this->customer_id) {
             $customer = JeproshopContext::getContext()->customer;
         } else {
             $customer = new JeproshopCustomerModelCustomer((int) $this->customer_id);
         }
         if ((!$this->secure_key || $this->secure_key == '-1') && $customer->secure_key) {
             $this->secure_key = $customer->secure_key;
             $this->save();
         }
     }
     $this->_taxCalculationMethod = JeproshopGroupModelGroup::getPriceDisplayMethod(JeproshopGroupModelGroup::getCurrent()->group_id);
 }
Пример #2
0
 public static function getDefaultPriceDisplayMethod()
 {
     return JeproshopGroupModelGroup::getPriceDisplayMethod((int) JeproshopSettingModelSetting::getValue('customer_group'));
 }
Пример #3
0
 public function initOrderDetails()
 {
     $this->context->controller->init();
     header('Cache-Control: no-cache, must-revalidate');
     header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
     //$this->initContent();
     $app = JFactory::getApplication();
     $order_id = $app->input->get('order_id');
     if (!$order_id || !JeproshopTools::isUnsignedInt($order_id)) {
         $this->errors[] = Tools::displayError('Order ID required');
     } else {
         $order = new JeproshopOrderModelOrder($order_id);
         if (JeproshopTools::isLoadedObject($order, 'order_id') && $order->customer_id == $this->context->customer->customer_id) {
             $order_status_id = (int) $order->getCurrentState();
             $carrier = new JeproshopCarrierModelCarrier((int) $order->carrier_id, (int) $order->lang_id);
             $invoiceAddress = new JeproshopAddressModelAddress((int) $order->address_invoice_id);
             $deliveryAddress = new JeproshopAddressModelAddress((int) $order->address_delivery_id);
             $invoice_address_fields = JeproshopAddressFormatModelAddressFormat::getOrderedAddressFields($invoiceAddress->country_id);
             $delivery_address_fields = JeproshopAddressFormatModelAddressFormat::getOrderedAddressFields($deliveryAddress->country_id);
             $invoiceAddressFormatValues = JeproshopAddressFormatModelAddressFormat::getFormattedAddressFieldsValues($invoiceAddress, $invoice_address_fields);
             $deliveryAddressFormatValues = JeproshopAddressFormatModelAddressFormat::getFormattedAddressFieldsValues($deliveryAddress, $delivery_address_fields);
             if ($order->total_discounts > 0) {
                 $oldTotal = (double) ($order->total_paid - $order->total_discounts);
                 $this->assignRef('old_total', $oldTotal);
             }
             $products = $order->getProducts();
             /* DEPRECATED: customizedDatas @since 1.5 */
             $customizedDatas = JeproshopProductModelProduct::getAllCustomizedDatas((int) $order->cart_id);
             JeproshopProductModelProduct::addCustomizationPrice($products, $customizedDatas);
             JeproshopOrderReturnModelOrderReturn::addReturnedQuantity($products, $order->order_id);
             $customer = new JeproshopCustomerModelCustomer($order->customer_id);
             $this->assignRef('order', $order);
             $isReturnable = (int) $order->isReturnable();
             $this->assignRef('return_allowed', $isReturnable);
             $this->assignRef('currency', new JeproshopCurrencyModelCurrency($order->currency_id));
             $order_status_id = (int) $order_status_id;
             $this->assignRef('order_status_id', $order_status_id);
             $invoiceAllowed = (int) JeproshopSettingModelSetting::getValue('invoice_allowed');
             $this->assignRef('invoice_allowed', $invoiceAllowed);
             $invoice = JeproshopOrderStatusModelOrderStatus::invoiceAvailable($order_status_id) && count($order->getInvoicesCollection());
             $this->assignRef('invoice', $invoice);
             $this->assignRef('order_history', $order->getHistory($this->context->language->lang_id, false, true));
             $this->assignRef('products', $products);
             $this->assignRef('discounts', $order->getCartRules());
             $this->assignRef('carrier', $carrier);
             $this->assignRef('invoice_address', $invoiceAddress);
             $this->assignRef('invoice_status', JeproshopTools::isLoadedObject($invoiceAddress, 'address_id') && $invoiceAddress->state_id ? new JeproshopStatusModelStatus($invoiceAddress->state_id) : false);
             $this->assignRef('delivery_address', $deliveryAddress);
             $this->assignRef('invoice_address_fields', $invoice_address_fields);
             $this->assignRef('delivery_address_fields', $delivery_address_fields);
             $this->assignRef('invoice_address_format_values', $invoiceAddressFormatValues);
             $this->assignRef('delivery_address_format_values', $deliveryAddressFormatValues);
             $this->assignRef('delivery_status', JeproshopTools::isLoadedObject($deliveryAddress, 'address_id') && $deliveryAddress->state_id ? new JeproshopStatusModelStatus($deliveryAddress->state_id) : false);
             $this->assignRef('messages', JeproshopCustomerMessageModelCustomerMessage::getMessagesByOrderId((int) $order->order_id, false));
             $files = JeproshopProductModelProduct::CUSTOMIZE_FILE;
             $this->assignRef('CUSTOMIZE_FILE', $files);
             $text_fields = JeproshopProductModelProduct::CUSTOMIZE_TEXT_FIELD;
             $this->assignRef('CUSTOMIZE_TEXT_FIELD', $text_fields);
             //$this->assignRef('isRecyclable', JeproshopSettingModelSetting::getValue('PS_RECYCLABLE_PACK'));
             $this->assignRef('use_tax', JeproshopSettingModelSetting::getValue('use_tax'));
             $group_use_tax = JeproshopGroupModelGroup::getPriceDisplayMethod($customer->default_group_id) == COM_JEPROSHOP_TAX_INCLUDED;
             $this->assignRef('group_use_tax', $group_use_tax);
             $this->assignRef('display_price', JeproshopSettingModelSetting::getValue('display_price'));
             /* DEPRECATED: customizedDatas @since 1.5 */
             $this->assignRef('customizedDatas', $customizedDatas);
             $reordering_allowed = (int) JeproshopSettingModelSetting::getValue('enable_history_reordering');
             $this->assignRef('reordering_allowed', $reordering_allowed);
             /*
                             $this->context->smarty->assign(array(
                                 'deliveryState' => (Validate::isLoadedObject($addressDelivery) && $addressDelivery->state_id) ? new State($addressDelivery->id_state) : false,
                                 'is_guest' => false,
                                 'messages' => CustomerMessage::getMessagesByOrderId((int)($order->id), false),
                                 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE,
                                 'CUSTOMIZE_TEXT_FIELD' => Product::CUSTOMIZE_TEXT_FIELD,
                                 'isRecyclable' => Configuration::get('PS_RECYCLABLE_PACK'),
                                 'use_tax' => Configuration::get('PS_TAX'),
                                 'group_use_tax' => (Group::getPriceDisplayMethod($customer->default_group_id) == PS_TAX_INC),
                                 /* DEPRECATED: customizedDatas @since 1.5 * /
                                 'customizedDatas' => $customizedDatas,
                                 /* DEPRECATED: customizedDatas @since 1.5 * /
             
                             )); */
             if ($carrier->url && $order->shipping_number) {
                 $this->assignRef('followup', str_replace('@', $order->shipping_number, $carrier->url));
             }
             /*               $this->context->smarty->assign('HOOK_ORDERDETAILDISPLAYED', Hook::exec('displayOrderDetail', array('order' => $order)));
                             Hook::exec('actionOrderDetail', array('carrier' => $carrier, 'order' => $order)); */
             unset($carrier, $addressInvoice, $addressDelivery);
         } else {
             $this->errors[] = Tools::displayError('This order cannot be found.');
         }
         unset($order);
     }
     //$this->setTemplate(_PS_THEME_DIR_.'order-detail.tpl');
 }
Пример #4
0
 public function __construct($order_id = null, $lang_id = null)
 {
     //parent::__construct();
     $db = JFactory::getDBO();
     if ($lang_id !== NULL) {
         $this->lang_id = JeproshopLanguageModelLanguage::getLanguage($lang_id) ? (int) $lang_id : JeproshopSettingModelSetting::getValue('default_lang');
     }
     if ($this->isMultiShop() && !$this->shop_id) {
         $this->shop_id = JeproshopContext::getContext()->shop->shop_id;
     }
     if ($order_id) {
         $cache_id = 'jeproshop_order_model_' . $order_id . '_' . $lang_id . '_' . $this->shop_id;
         if (!JeproshopCache::isStored($cache_id)) {
             $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_orders') . " AS ord ";
             $where = "";
             /** get language information **/
             if ($lang_id) {
                 $query .= "LEFT JOIN " . $db->quoteName('#__jeproshop_product_lang') . " AS product_lang ";
                 $query .= "ON (product.product_id = product_lang.product_id AND product_lang.lang_id = " . (int) $lang_id . ") ";
                 if ($this->shop_id && !empty($this->multiLangShop)) {
                     $where = " AND product_lang.shop_id = " . $this->shop_id;
                 }
             }
             /** Get shop information **/
             if (JeproshopShopModelShop::isTableAssociated('order')) {
                 $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_order_shop') . " AS order_shop ON (";
                 $query .= "ord.order_id = order_shop.order_id AND order_shop.shop_id = " . (int) $this->shop_id . ")";
             }
             $query .= " WHERE ord.order_id = " . (int) $order_id . $where;
             $db->setQuery($query);
             $order_data = $db->loadObject();
             if ($order_data) {
                 if (!$lang_id && isset($this->multiLang) && $this->multiLang) {
                     $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_product_lang');
                     $query .= " WHERE product_id = " . (int) $order_id;
                     $db->setQuery($query);
                     $order_lang_data = $db->loadObjectList();
                     if ($order_lang_data) {
                         foreach ($order_lang_data as $row) {
                             foreach ($row as $key => $value) {
                                 if (array_key_exists($key, $this) && $key != 'order_id') {
                                     if (!isset($order_data->{$key}) || !is_array($order_data->{$key})) {
                                         $order_data->{$key} = array();
                                     }
                                     $order_data->{$key}[$row->lang_id] = $value;
                                 }
                             }
                         }
                     }
                 }
                 JeproshopCache::store($cache_id, $order_data);
             }
         } else {
             $order_data = JeproshopCache::retrieve($cache_id);
         }
         if ($order_data) {
             $order_data->product_id = $order_id;
             foreach ($order_data as $key => $value) {
                 if (array_key_exists($key, $this)) {
                     $this->{$key} = $value;
                 }
             }
         }
     }
     if ($this->customer_id) {
         $customer = new JeproshopCustomerModelCustomer((int) $this->customer_id);
         $this->_taxCalculationMethod = JeproshopGroupModelGroup::getPriceDisplayMethod((int) $customer->default_group_id);
     }
 }
Пример #5
0
 public static function initPricesComputation($customer_id = null)
 {
     if ($customer_id) {
         $customer = new JeproshopCustomerModelCustomer((int) $customer_id);
         if (!JeproshopTools::isLoadedObject($customer, 'customer_id')) {
             die(Tools::displayError());
         }
         self::$_taxCalculationMethod = JeproshopGroupModelGroup::getPriceDisplayMethod((int) $customer->default_group_id);
         $cur_cart = JeproshopContext::getContext()->cart;
         $address_id = 0;
         if (JeproshopTools::isLoadedObject($cur_cart, 'cart_id')) {
             $address_id = (int) $cur_cart->{JeproshopSettingModelSetting::getValue('tax_address_type')};
         }
         $address_info = JeproshopAddressModelAddress::getCountryAndState($address_id);
         if (self::$_taxCalculationMethod != COM_JEPROSHOP_TAX_EXCLUDED && !empty($address_info->vat_number) && $address_info->country_id != JeproshopSettingModelSetting::getValue('country_vat_number') && JeproshopSettingModelSetting::getValue('vat_number_management')) {
             self::$_taxCalculationMethod = COM_JEPROSHOP_TAX_EXCLUDED;
         }
     } else {
         self::$_taxCalculationMethod = JeproshopGroupModelGroup::getPriceDisplayMethod(JeproshopGroupModelGroup::getCurrent()->group_id);
     }
 }
Пример #6
0
 /**
  * Assign price and tax to the template
  */
 protected function assignPriceAndTax()
 {
     $customer_id = isset($this->context->customer) ? (int) $this->context->customer->customer_id : 0;
     $group_id = (int) JeproshopGroupModelGroup::getCurrent()->group_id;
     $country_id = (int) $customer_id ? JeproshopCustomerModelCustomer::getCurrentCountry($customer_id) : JeproshopSettingModelSetting::getValue('default_country');
     $group_reduction = JeproshopGroupReductionModelGroupReduction::getValueForProduct($this->product->product_id, $group_id);
     if ($group_reduction === false) {
         $group_reduction = JeproshopGroupModelGroup::getReduction((int) $this->context->cookie->customer_id) / 100;
     }
     // Tax
     $tax = (double) $this->product->getTaxesRate(new JeproshopAddressModelAddress((int) $this->context->cart->{JeproshopSettingModelSetting::getValue('tax_address_type')}));
     $this->assignRef('tax_rate', $tax);
     $product_price_with_tax = JeproshopProductModelProduct::getStaticPrice($this->product->product_id, true, null, 6);
     if (JeproshopProductModelProduct::$_taxCalculationMethod == COM_JEPROSHOP_TAX_INCLUDED) {
         $product_price_with_tax = JeproshopTools::roundPrice($product_price_with_tax, 2);
     }
     $product_price_without_eco_tax = (double) $product_price_with_tax - $this->product->ecotax;
     $ecotax_rate = (double) JeproshopTaxModelTax::getProductEcotaxRate($this->context->cart->{JeproshopSettingModelSetting::getValue('tax_address_type')});
     $ecotax_tax_amount = JeproshopTools::roundPrice($this->product->ecotax, 2);
     if (JeproshopProductModelProduct::$_taxCalculationMethod == COM_JEPROSHOP_TAX_INCLUDED && (int) JeproshopSettingModelSetting::getValue('use_tax')) {
         $ecotax_tax_amount = JeproshopTools::roundPrice($ecotax_tax_amount * (1 + $ecotax_rate / 100), 2);
     }
     $currency_id = (int) $this->context->cookie->currency_id;
     $product_id = (int) $this->product->product_id;
     $shop_id = $this->context->shop->shop_id;
     $quantity_discounts = JeproshopSpecificPriceModelSpecificPrice::getQuantityDiscounts($product_id, $shop_id, $currency_id, $country_id, $group_id, null, true, (int) $this->context->customer->customer_id);
     foreach ($quantity_discounts as &$quantity_discount) {
         if ($quantity_discount->product_attribute_id) {
             $combination = new JeproshopCombinationModelCombination((int) $quantity_discount->product_attribute_id);
             $attributes = $combination->getAttributesName((int) $this->context->language->lang_id);
             foreach ($attributes as $attribute) {
                 $quantity_discount->attributes = $attribute->name . ' - ';
             }
             $quantity_discount->attributes = rtrim($quantity_discount->attributes, ' - ');
         }
         if ((int) $quantity_discount->currency_id == 0 && $quantity_discount->reduction_type == 'amount') {
             $quantity_discount->reduction = JeproshopTools::convertPriceFull($quantity_discount->reduction, null, JeproshopContext::getContext()->currency);
         }
     }
     $product_price = $this->product->getPrice(JeproshopProductModelProduct::$_taxCalculationMethod == COM_JEPROSHOP_TAX_INCLUDED, false);
     $address = new JeproshopAddressModelAddress($this->context->cart->{JeproshopSettingModelSetting::getValue('tax_address_type')});
     $quantity_discounts = $this->formatQuantityDiscounts($quantity_discounts, $product_price, (double) $tax, $ecotax_tax_amount);
     $this->assignRef('quantity_discounts', $quantity_discounts);
     $this->assignRef('ecotax_tax_included', $ecotax_tax_amount);
     $ecotax_tax_excluded = JeproshopTools::roundPrice($this->product->ecotax, 2);
     $this->assignRef('ecotax_tax_excluded', $ecotax_tax_excluded);
     $this->assignRef('ecotaxTax_rate', $ecotax_rate);
     $display_price = JeproshopSettingModelSetting::getValue('display_price');
     $this->assignRef('display_price', $display_price);
     $product_price_without_eco_tax = (double) $product_price_without_eco_tax;
     $this->assignRef('product_price_without_ecotax', $product_price_without_eco_tax);
     $this->assignRef('group_reduction', $group_reduction);
     $no_tax = JeproshopTaxModelTax::taxExcludedOption() || !$this->product->getTaxesRate($address);
     $this->assignRef('no_tax', $no_tax);
     $ecotax = !count($this->errors) && $this->product->ecotax > 0 ? JeproshopTools::convertPrice((double) $this->product->ecotax) : 0;
     $this->assignRef('ecotax', $ecotax);
     $tax_enabled = JeproshopSettingModelSetting::getValue('use_tax');
     $this->assignRef('tax_enabled', $tax_enabled);
     $customer_group_without_tax = JeproshopGroupModelGroup::getPriceDisplayMethod($this->context->customer->default_group_id);
     $this->assignRef('customer_group_without_tax', $customer_group_without_tax);
 }
Пример #7
0
 public function __construct($cart_id = null, $lang_id = null)
 {
     $db = JFactory::getDBO();
     if (!is_null($lang_id)) {
         $this->lang_id = (int) (JeproshopLanguageModelLanguage::getLanguage($lang_id) !== false) ? $lang_id : JeproshopSettingModelSetting::getValue('default_lang');
     }
     if ($cart_id) {
         //Load object from database if object
         $cache_id = 'jeproshop_cart_model_cart_' . $cart_id . '_' . $lang_id;
         if (!JeproshopCache::isStored($cache_id)) {
             $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_cart') . " AS cart WHERE " . $db->quoteName('cart_id') . " = " . (int) $lang_id;
             $db->setQuery($query);
             $cartData = $db->loadObject();
             if ($cartData) {
                 JeproshopCache::store($cache_id, $cartData);
             }
         } else {
             $cartData = JeproshopCache::retrieve($cache_id);
         }
         if ($cartData) {
             $this->cart_id = (int) $cart_id;
             foreach ($cartData as $key => $value) {
                 if (array_key_exists($key, $this)) {
                     $this->{$key} = $value;
                 }
             }
         }
         print_r($cartData);
     }
     if ($this->customer_id) {
         if (isset(JeproshopContext::getContext()->customer) && JeproshopContext::getContext()->customer->customer_id == $this->customer_id) {
             $customer = JeproshopContext::getContext()->customer;
         } else {
             $customer = new JeproshopCustomerModelCustomer((int) $this->customer_id);
         }
         if ((!$this->secure_key || $this->secure_key == '-1') && $customer->secure_key) {
             $this->secure_key = $customer->secure_key;
             $this->save();
         }
     }
     $this->_taxCalculationMethod = JeproshopGroupModelGroup::getPriceDisplayMethod(JeproshopGroupModelGroup::getCurrent()->group_id);
 }
Пример #8
0
 public function renderView($tpl = null)
 {
     if (!$this->loadObject(true)) {
         return;
     }
     if (!isset($this->context)) {
         $this->context = JeproshopContext::getContext();
     }
     $customer = new JeproshopCustomerModelCustomer($this->cart->customer_id);
     $currency = new JeproshopCurrencyModelCurrency($this->cart->currency_id);
     $this->context->cart = $this->cart;
     $this->context->currency = $currency;
     $this->context->customer = $customer;
     //$this->toolbar_title = sprintf($this->l('Cart #%06d'), $this->context->cart->cart_id);
     $products = $this->cart->getProducts();
     $customized_datas = JeproshopProductModelProduct::getAllCustomizedDatas((int) $this->cart->cart_id);
     JeproshopProductModelProduct::addCustomizationPrice($products, $customized_datas);
     $summary = $this->cart->getSummaryDetails();
     /* Display order information */
     $order_id = (int) JeproshopOrderModelOrder::getOrderIdByCartId($this->cart->cart_id);
     $order = new JeproshopOrderModelOrder($order_id);
     if (JeproshopTools::isLoadedObject($order, 'order_id')) {
         $tax_calculation_method = $order->getTaxCalculationMethod();
         $shop_id = (int) $order->shop_id;
     } else {
         $shop_id = (int) $this->cart->shop_id;
         $tax_calculation_method = JeproshopGroupModelGroup::getPriceDisplayMethod(JeproshopGroupModelGroup::getCurrent()->group_id);
     }
     if ($tax_calculation_method == COM_JEPROSHOP_TAX_EXCLUDED) {
         $total_products = $summary->total_products;
         $total_discounts = $summary->total_discounts_tax_exc;
         $total_wrapping = $summary->total_wrapping_tax_exc;
         $total_price = $summary->total_price_without_tax;
         $total_shipping = $summary->total_shipping_tax_exc;
     } else {
         $total_products = $summary->total_products_wt;
         $total_discounts = $summary->total_discounts;
         $total_wrapping = $summary->total_wrapping;
         $total_price = $summary->total_price;
         $total_shipping = $summary->total_shipping;
     }
     foreach ($products as $k => &$product) {
         if ($tax_calculation_method == COM_JEPROSHOP_TAX_EXCLUDED) {
             $product->product_price = $product->price;
             $product->product_total = $product->total;
         } else {
             $product->product_price = $product->price_wt;
             $product->product_total = $product->total_wt;
         }
         $image = array();
         $db = JFactory::getDBO();
         if (isset($product->product_attribute_id) && (int) $product->product_attribute_id) {
             $query = "SELECT " . $db->quoteName('image_id') . " FROM " . $db->quoteName('#__jeproshop_product_attribute_image') . " WHERE product_attribute_id = " . (int) $product->product_attribute_id;
             $db->setQuery($query);
             $image = $db->loadObject();
         }
         if (!isset($image->image_id)) {
             $query = "SELECT " . $db->quoteName('image_id') . " FROM " . $db->quoteName('#__jeproshop_image') . " WHERE " . $db->quoteName('product_id') . " = " . (int) $product->product_id . " AND cover = 1 ";
             $db->setQuery($query);
             $image = $db->loadObject();
         }
         $product_obj = new JeproshopProductModelProduct($product->product_id);
         $product->qty_in_stock = JeproshopStockAvailableModelStockAvailable::getQuantityAvailableByProduct($product->product_id, isset($product->product_attribute_id) ? $product->product_attribute_id : null, (int) $shop_id);
         $image_product = new JeproshopImageModelImage($image->image_id);
         $product->image = isset($image->image_id) ? JeproshopImageManager::thumbnail(COM_JEPROSHOP_IMAGE_DIR . 'products/' . $image_product->getExistingImagePath() . '.jpg', 'product_mini_' . (int) $product->product_id . (isset($product->product_attribute_id) ? '_' . (int) $product->product_attribute_id : '') . '.jpg', 45, 'jpg') : '--';
     }
     /*$helper = new HelperKpi();
       $helper->id = 'box-kpi-cart';
       $helper->icon = 'icon-shopping-cart';
       $helper->color = 'color1';
       $helper->title = $this->l('Total Cart', null, null, false);
       $helper->subtitle = sprintf($this->l('Cart #%06d', null, null, false), $cart->id);
       $helper->value = Tools::displayPrice($total_price, $currency);
       $kpi = $helper->generate(); */
     //$this->assignRef('kpi', $kpi);
     $this->assignRef('products', $products);
     $discounts = $this->cart->getCartRules();
     $this->assignRef('discounts', $discounts);
     $this->assignRef('order', $order);
     $this->assignRef('currency', $currency);
     $this->assignRef('customer', $customer);
     $customerStats = $customer->getStats();
     $this->assignRef('customer_stats', $customerStats);
     $this->assignRef('total_products', $total_products);
     $this->assignRef('total_discounts', $total_discounts);
     $this->assignRef('total_wrapping', $total_wrapping);
     $this->assignRef('total_price', $total_price);
     $this->assignRef('total_shipping', $total_shipping);
     $this->assignRef('customized_datas', $customized_datas);
     if ($this->getLayout() != 'modal') {
         $this->addToolBar();
         $this->sideBar = JHtmlSidebar::render();
     }
     parent::display($tpl);
 }