function calculateSum(&$cart)
 {
     $jshopConfig = JSFactory::getConfig();
     if ($this->getGlobalConfigPriceNull($cart)) {
         return 0;
     }
     $price = $this->shipping_stand_price;
     $package = $this->package_stand_price;
     $prices = array('shipping' => $price, 'package' => $package);
     $extensions = JSFactory::getShippingExtList($this->shipping_method_id);
     foreach ($extensions as $extension) {
         if (isset($extension->exec->version) && $extension->exec->version == 2) {
             $prices = $extension->exec->getPrices($cart, $this->getParams(), $prices, $extension, $this);
             $price = $prices['shipping'];
         } else {
             $price = $extension->exec->getPrice($cart, $this->getParams(), $price, $extension, $this);
             $prices = array('shipping' => $price, 'package' => $package);
         }
     }
     $prices['shipping'] = $prices['shipping'] * $jshopConfig->currency_value;
     $prices['shipping'] = getPriceCalcParamsTax($prices['shipping'], $this->shipping_tax_id, $cart->products);
     $prices['package'] = $prices['package'] * $jshopConfig->currency_value;
     $prices['package'] = getPriceCalcParamsTax($prices['package'], $this->package_tax_id, $cart->products);
     return $prices;
 }
Exemplo n.º 2
0
 function edit()
 {
     $jshopConfig = JSFactory::getConfig();
     $sh_pr_method_id = JRequest::getInt('sh_pr_method_id');
     $shipping_id_back = JRequest::getInt("shipping_id_back");
     $db = JFactory::getDBO();
     $sh_method_price = JSFactory::getTable('shippingMethodPrice', 'jshop');
     $sh_method_price->load($sh_pr_method_id);
     $sh_method_price->prices = $sh_method_price->getPrices();
     if ($jshopConfig->tax) {
         $taxes = JSFactory::getModel("taxes");
         $all_taxes = $taxes->getAllTaxes();
         $list_tax = array();
         foreach ($all_taxes as $tax) {
             $list_tax[] = JHTML::_('select.option', $tax->tax_id, $tax->tax_name . ' (' . $tax->tax_value . '%)', 'tax_id', 'tax_name');
         }
         $list_tax[] = JHTML::_('select.option', -1, _JSHOP_PRODUCT_TAX_RATE, 'tax_id', 'tax_name');
         $lists['taxes'] = JHTML::_('select.genericlist', $list_tax, 'shipping_tax_id', 'class="inputbox"', 'tax_id', 'tax_name', $sh_method_price->shipping_tax_id);
         $lists['package_taxes'] = JHTML::_('select.genericlist', $list_tax, 'package_tax_id', 'class="inputbox"', 'tax_id', 'tax_name', $sh_method_price->package_tax_id);
     }
     $shippings = JSFactory::getModel("shippings");
     $countries = JSFactory::getModel("countries");
     $actived = $sh_method_price->shipping_method_id;
     if (!$actived) {
         $actived = $shipping_id_back;
     }
     $lists['shipping_methods'] = JHTML::_('select.genericlist', $shippings->getAllShippings(0), 'shipping_method_id', 'class = "inputbox" size = "1"', 'shipping_id', 'name', $actived);
     $lists['countries'] = JHTML::_('select.genericlist', $countries->getAllCountries(0), 'shipping_countries_id[]', 'class = "inputbox" size = "10", multiple = "multiple"', 'country_id', 'name', $sh_method_price->getCountries());
     if ($jshopConfig->admin_show_delivery_time) {
         $_deliveryTimes = JSFactory::getModel("deliveryTimes");
         $all_delivery_times = $_deliveryTimes->getDeliveryTimes();
         $all_delivery_times0 = array();
         $all_delivery_times0[0] = new stdClass();
         $all_delivery_times0[0]->id = '0';
         $all_delivery_times0[0]->name = _JSHOP_NONE;
         $lists['deliverytimes'] = JHTML::_('select.genericlist', array_merge($all_delivery_times0, $all_delivery_times), 'delivery_times_id', 'class = "inputbox"', 'id', 'name', $sh_method_price->delivery_times_id);
     }
     $currency = JSFactory::getTable('currency', 'jshop');
     $currency->load($jshopConfig->mainCurrency);
     $extensions = JSFactory::getShippingExtList($actived);
     $view = $this->getView("shippingsprices", 'html');
     $view->setLayout("edit");
     $view->assign('sh_method_price', $sh_method_price);
     $view->assign('lists', $lists);
     $view->assign('shipping_id_back', $shipping_id_back);
     $view->assign('currency', $currency);
     $view->assign('extensions', $extensions);
     $view->assign('config', $jshopConfig);
     $view->assign('etemplatevar', '');
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onBeforeEditShippingsPrices', array(&$view));
     $view->displayEdit();
 }