function loadCurrencyValue() { $session = JFactory::getSession(); $id_currency_session = $session->get('js_id_currency'); $id_currency = JRequest::getInt('id_currency'); $main_currency = $this->mainCurrency; if ($this->default_frontend_currency) { $main_currency = $this->default_frontend_currency; } if ($session->get('js_id_currency_orig') && $session->get('js_id_currency_orig') != $main_currency) { $id_currency_session = 0; $session->set('js_update_all_price', 1); } if (!$id_currency && $id_currency_session) { $id_currency = $id_currency_session; } $session->set('js_id_currency_orig', $main_currency); if ($id_currency) { $this->cur_currency = $id_currency; } else { $this->cur_currency = $main_currency; } $session->set('js_id_currency', $this->cur_currency); $all_currency = JSFactory::getAllCurrency(); $current_currency = $all_currency[$this->cur_currency]; if (!$current_currency->currency_value) { $current_currency->currency_value = 1; } $this->currency_value = $current_currency->currency_value; $this->currency_code = $current_currency->currency_code; $this->currency_code_iso = $current_currency->currency_code_iso; }
function getBuildQueryOrderListProduct($order, $orderby, &$adv_from) { $order_query = ""; if (!$order) { return $order_query; } $order_original = $order; $jshopConfig = JSFactory::getConfig(); $multyCurrency = count(JSFactory::getAllCurrency()); if ($multyCurrency > 1 && $order == "prod.product_price") { if (strpos($adv_from, "jshopping_currencies") === false) { $adv_from .= " LEFT JOIN `#__jshopping_currencies` AS cr USING (currency_id) "; } if ($jshopConfig->product_list_show_min_price) { $order = "prod.min_price/cr.currency_value"; } else { $order = "prod.product_price/cr.currency_value"; } } if ($order == "prod.product_price" && $jshopConfig->product_list_show_min_price) { $order = "prod.min_price"; } $order_query = " ORDER BY " . $order; if ($orderby) { $order_query .= " " . $orderby; } JPluginHelper::importPlugin('jshoppingproducts'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onBuildQueryOrderListProduct', array($order, $orderby, &$adv_from, &$order_query, $order_original)); return $order_query; }
function getPriceFromCurrency($price, $currency_id = 0, $current_currency_value = 0) { $jshopConfig = JSFactory::getConfig(); if ($currency_id) { $all_currency = JSFactory::getAllCurrency(); $value = $all_currency[$currency_id]->currency_value; if (!$value) { $value = 1; } $pricemaincurrency = $price / $value; } else { $pricemaincurrency = $price; } if (!$current_currency_value) { $current_currency_value = $jshopConfig->currency_value; } return $pricemaincurrency * $current_currency_value; }
function loadpaymentprice($data_order, $products) { JModelLegacy::addIncludePath(JPATH_COMPONENT_SITE . '/models'); $jshopConfig = JSFactory::getConfig(); $jshopConfig->display_price_front_current = $data_order['display_price']; $all_currency = JSFactory::getAllCurrency(); $currency_id = $data_order['currency_id']; if ($currency_id) { $jshopConfig->currency_value = $all_currency[$currency_id]->currency_value; } $id_country = $data_order['d_country']; if (!$id_country) { $id_country = $data_order['country']; } $AllTaxes = JSFactory::getAllTaxes(); $paym_method = JSFactory::getTable('paymentmethod', 'jshop'); $paym_method->load($data_order['payment_method_id']); if ($paym_method->price_type == 2) { $total = 0; foreach ($products as $key => $product) { $tax = floatval($product['product_tax']); $product_price = $product['product_item_price'] * $product['product_quantity']; if ($data_order['display_price']) { $product_price = $product_price + $product_price * $tax / 100; } $total += $product_price; } $cproducts = $this->getCartProductsFromOrderProducts($products); $cart = JSFactory::getModel('cart', 'jshop'); $cart->products = array(); $cart->loadProductsFromArray($cproducts); $cart->loadPriceAndCountProducts(); $shipping_method = JSFactory::getTable('shippingMethod', 'jshop'); $sh_pr_method_id = $shipping_method->getShippingPriceId($data_order['shipping_method_id'], $id_country); $shipping_method_price = JSFactory::getTable('shippingMethodPrice', 'jshop'); $shipping_method_price->load($sh_pr_method_id); $tax = floatval($AllTaxes[$shipping_method_price->shipping_tax_id]); $shipping_price = $data_order['order_shipping']; if ($data_order['display_price']) { $shipping_taxes = $shipping_method_price->calculateShippingTaxList($shipping_price, $cart); foreach ($shipping_taxes as $k => $v) { $shipping_price = $shipping_price + $v; } } $total += $shipping_price; $tax = floatval($AllTaxes[$shipping_method_price->package_tax_id]); $package_price = $data_order['order_package']; if ($data_order['display_price']) { $shipping_taxes = $shipping_method_price->calculatePackageTaxList($package_price, $cart); foreach ($shipping_taxes as $k => $v) { $package_price = $package_price + $v; } } $total += $package_price; $price = $total * $paym_method->price / 100; if ($data_order['display_price']) { $price = getPriceCalcParamsTax($price, $paym_method->tax_id, $cart->products); } } else { $price = $paym_method->price * $jshopConfig->currency_value; $price = getPriceCalcParamsTax($price, $paym_method->tax_id, $cart->products); } extract(js_add_trigger(get_defined_vars(), "before")); return $price; }