public function getTaxesRate(JeproshopAddressModelAddress $address = null) { if (!$address || $address->country_id) { $address = JeproshopAddressModelAddress::initialize(); } $tax_manager = JeproshopTaxManagerFactory::getManager($address, $this->tax_rules_group_id); $tax_calculator = $tax_manager->getTaxCalculator(); return $tax_calculator->getTotalRate(); }
private function displaySpecificPriceModificationForm($default_currency, $shops, $currencies, $countries, $groups) { $content = ''; if (!$this->product) { return null; } $specificPrices = JeproshopSpecificPriceModelSpecificPrice::getSpecificPricesByProductId((int) $this->product->product_id); $specificPricePriorities = JeproshopSpecificPriceModelSpecificPrice::getPriority((int) $this->product->product_id); $app = JFactory::getApplication(); $taxRate = $this->product->getTaxesRate(JeproshopAddressModelAddress::initialize()); $tmp = array(); foreach ($shops as $shop) { $tmp[$shop->shop_id] = $shop; } $shops = $tmp; $tmp = array(); foreach ($currencies as $currency) { $tmp[$currency->currency_id] = $currency; } $currencies = $tmp; $tmp = array(); foreach ($countries as $country) { $tmp[$country->country_id] = $country; } $countries = $tmp; $tmp = array(); foreach ($groups as $group) { $tmp[$group->group_id] = $group; } $groups = $tmp; $content .= '<table class="table table-striped" ><thead><tr><th>' . JText::_('COM_JEPROSHOP_RULES_LABEL'); $content .= '</th><th>' . JText::_('COM_JEPROSHOP_COMBINATION_LABEL') . '</th>'; $multi_shop = JeproshopShopModelShop::isFeaturePublished(); if ($multi_shop) { $content .= '<th>' . JText::_('COM_JEPROSHOP_SHOP_LABEL') . '</th>'; } $content .= '<th>' . JText::_('COM_JEPROSHOP_CURRENCY_LABEL') . '</th><th>'; $content .= JText::_('COM_JEPROSHOP_COUNTRY_LABEL') . '</th><th>' . JText::_('COM_JEPROSHOP_GROUP_LABEL'); $content .= '</th><th>' . JText::_('COM_JEPROSHOP_CUSTOMER_LABEL') . '</th><th>'; $content .= JText::_('COM_JEPROSHOP_FIXED_PRICE_LABEL') . '</th><th>' . JText::_('COM_JEPROSHOP_IMPACT_LABEL'); $content .= '</th><th>' . JText::_('COM_JEPROSHOP_PERIOD_LABEL') . '</th><th>' . JText::_('COM_JEPROSHOP_FROM_LABEL'); $content .= '</th><th>' . JText::_('COM_JEPROSHOP_ACTIONS_LABEL') . '</th></tr></thead><tbody>'; if (!is_array($specificPrices) || !count($specificPrices)) { $content .= '<tr><td class="text-center" colspan="13" ><i class="icon-warning-sign"></i> '; $content .= JText::_('COM_JEPROSHOP_NO_SPECIFIC_PRICES_MESSAGE') . '</td></tr>'; } else { $i = 0; foreach ($specificPrices as $specificPrice) { $currentSpecificCurrency = $currencies[$specificPrice->currency_id ? $specificPrice->currency_id : $default_currency->currency_id]; if ($specificPrice->reduction_type == 'percentage') { $impact = '- ' . $specificPrice->reduction * 100 . ' %'; } elseif ($specificPrice->reduction > 0) { $impact = '- ' . JeproshopTools::displayPrice(Tools::ps_round($specificPrice->reduction, 2), $currentSpecificCurrency); } else { $impact = '--'; } if ($specificPrice->from == '0000-00-00 00:00:00' && $specificPrice->to == '0000-00-00 00:00:00') { $period = JText::_('COM_JEPROSHOP_UNLIMITED_LABEL'); } else { $period = JText::_('COM_JEPROSHOP_FROM_LABEL') . ' ' . ($specificPrice->from != '0000-00-00 00:00:00' ? $specificPrice['from'] : '0000-00-00 00:00:00') . '<br />' . $this->l('To') . ' ' . ($specificPrice['to'] != '0000-00-00 00:00:00' ? $specificPrice['to'] : '0000-00-00 00:00:00'); } if ($specificPrice->product_attribute_id) { $combination = new JeproshopCombinationModelCombination((int) $specificPrice->product_attribute_id); $attributes = $combination->getAttributesName((int) $this->context->language->lang_id); $attributes_name = ''; foreach ($attributes as $attribute) { $attributes_name .= $attribute->name . ' - '; } $attributes_name = rtrim($attributes_name, ' - '); } else { $attributes_name = JText::_('COM_JEPROSHOP_ALL_COMBINATIONS_LABEL'); } $rule = new JeproshopSpecificPriceRuleModelSpecificPriceRule((int) $specificPrice->specific_price_rule_id); $rule_name = $rule->specific_price_rule_id ? $rule->name : '--'; if ($specificPrice->customer_id) { $customer = new JeproshopCustomerModelCustomer((int) $specificPrice->customer_id); if (JeproshopTools::isLoadedObject($customer, 'customer_id')) { $customer_full_name = $customer->firstname . ' ' . $customer->lastname; } unset($customer); } if (!$specificPrice->shop_id || in_array($specificPrice->shop_id, JeoroshopShopModelShop::getContextListShopID())) { $content .= '<tr class="row_' . ($i % 2 ? '0' : '1') . '"><td>' . $rule_name . '</td><td>' . $attributes_name . '</td>'; $can_delete_specific_prices = true; if (JeproshopShopModelShop::isFeaturePublished()) { $sp_shop_id = $specificPrice->shop_id; $can_delete_specific_prices = count($this->context->employee->getAssociatedShops()) > 1 && !$sp_shop_id || $sp_shop_id; $content .= '<td>' . ($sp_shop_id ? $shops[$sp_shop_id]['name'] : JText::_('COM_JEPROSHOP_ALL_SHOPS_LABEL')) . '</td>'; } $price = JeproshopTools::roundPrice($specificPrice->price, 2); $fixed_price = $price == JeproshopTools::roundPrice($this->product->price, 2) || $specificPrice->price == -1 ? '--' : JeproshopTools::displayPrice($price, $current_specific_currency); $content .= '<td>' . ($specificPrice->currency_id ? $currencies[$specificPrice->currency_id]->name : JText::_('COM_JEPROSHOP_ALL_CURRENCIES_LABEL')) . '</td>'; $content .= '<td>' . ($specificPrice->country_id ? $countries[$specificPrice->country_id]->name : JText::_('COM_JEPROSHOP_ALL_COUNTRIES_LABEL')) . '</td>'; $content .= '<td>' . ($specificPrice->group_id ? $groups[$specificPrice->group_id]->name : JText::_('COM_JEPROSHOP_ALL_GROUPS_LABEL')) . '</td>'; $content .= '<td title="' . JText::_('COM_JEPROSHOP_ID_LABEL') . ' ' . $specificPrice->customer_id . '">' . (isset($customer_full_name) ? $customer_full_name : JText::_('COM_JEPROSHOP_ALL_CUSTOMERS_LABEL')) . '</td>'; $content .= '<td>' . $fixed_price . '</td><td>' . $impact . '</td><td>' . $period . '</td><td>' . $specificPrice->from_quantity . '</th>'; $content .= '<td>' . (!$rule->specific_price_rule_id && $can_delete_specific_prices ? '<a class="btn btn-default" name="delete_link" href="' . JRoute::_('index.php?option=com_jeproshop&view=price&product_id=' . (int) $app->input->get('product_id') . '&task=delete_specific_price&specific_price_id=' . (int) $specificPrice->specific_price_id . '&' . JSession::getFormToken() . '=1') . '"><i class="icon-trash"></i></a>' : '') . '</td>'; $content .= '</tr>'; $i++; unset($customer_full_name); } } } $content .= '</tbody></table>'; // Not use id_customer if ($specificPricePriorities[0] == 'customer_id') { unset($specificPricePriorities[0]); } // Reindex array starting from 0 $specificPricePriorities = array_values($specificPricePriorities); $content .= '<div class="panel"><div class="panel-title" >' . JText::_('Priority management') . '</div><div class="panel-content well" ><div class="alert alert-info">'; $content .= JText::_('Sometimes one customer can fit into multiple price rules. Priorities allow you to define which rule applies to the customer.') . '</div>'; $content .= '<div class="input-group" ><select id="jform_specific_price_priority_1" name="price_field[specific_price_priority[]]" class="middle_size" ><option value="shop_id"'; $content .= ($specificPricePriorities[0] == 'shop_id' ? ' selected="selected"' : '') . '>' . JText::_('COM_JEPROSHOP_SHOP_LABEL') . '</option><option value="currency_id"'; $content .= ($specificPricePriorities[0] == 'currency_id' ? ' selected="selected"' : '') . '>' . JText::_('COM_JEPROSHOP_CURRENCY_LABEL') . '</option><option value="country_id"'; $content .= ($specificPricePriorities[0] == 'country_id' ? ' selected="selected"' : '') . '>' . JText::_('COM_JEPROSHOP_COUNTRY_LABEL') . '</option><option value="group_id"'; $content .= ($specificPricePriorities[0] == 'group_id' ? ' selected="selected"' : '') . '>' . JText::_('COM_JEPROSHOP_GROUP_LABEL') . '</option></select> <span class="'; $content .= 'input-group-addon"><i class="icon-chevron-right"></i></span> <select name="price_field[specific_price_priority[]]" class="middle_size" ><option value="shop_id"'; $content .= ($specificPricePriorities[1] == 'shop_id' ? ' selected="selected"' : '') . '>' . JText::_('COM_JEPROSHOP_SHOP_LABEL') . '</option><option value="currency_id"'; $content .= ($specificPricePriorities[1] == 'currency_id' ? ' selected="selected"' : '') . '>' . JText::_('COM_JEPROSHOP_CURRENCY_LABEL') . '</option><option value="country_id"'; $content .= ($specificPricePriorities[1] == 'country_id' ? ' selected="selected"' : '') . '>' . JText::_('COM_JEPROSHOP_COUNTRY_LABEL') . '</option><option value="group_id"'; $content .= ($specificPricePriorities[1] == 'group_id' ? ' selected="selected"' : '') . '>' . JText::_('COM_JEPROSHOP_GROUP_LABEL') . '</option></select> <span class="'; $content .= 'input-group-addon"><i class="icon-chevron-right"></i></span> <select name="price_field[specific_price_priority[]]" class="middle_size" ><option value="shop_id"'; $content .= ($specificPricePriorities[2] == 'shop_id' ? ' selected="selected"' : '') . '>' . JText::_('COM_JEPROSHOP_SHOP_LABEL') . '</option><option value="currency_id"'; $content .= ($specificPricePriorities[2] == 'currency_id' ? ' selected="selected"' : '') . '>' . JText::_('COM_JEPROSHOP_CURRENCY_LABEL') . '</option><option value="country_id"'; $content .= ($specificPricePriorities[2] == 'country_id' ? ' selected="selected"' : '') . '>' . JText::_('COM_JEPROSHOP_COUNTRY_LABEL') . '</option><option value="group_id"'; $content .= ($specificPricePriorities[2] == 'group_id' ? ' selected="selected"' : '') . '>' . JText::_('COM_JEPROSHOP_GROUP_LABEL') . '</option></select><span class="'; $content .= 'input-group-addon"><i class="icon-chevron-right"></i></span> <select name="price_field[specific_price_priority[]]" class="middle_size" ><option value="shop_id"'; $content .= ($specificPricePriorities[3] == 'shop_id' ? ' selected="selected"' : '') . '>' . JText::_('COM_JEPROSHOP_SHOP_LABEL') . '</option><option value="currency_id"'; $content .= ($specificPricePriorities[3] == 'currency_id' ? ' selected="selected"' : '') . '>' . JText::_('COM_JEPROSHOP_CURRENCY_LABEL') . '</option><option value="country_id"'; $content .= ($specificPricePriorities[3] == 'country_id' ? ' selected="selected"' : '') . '>' . JText::_('COM_JEPROSHOP_COUNTRY_LABEL') . '</option><option value="group_id"'; $content .= ($specificPricePriorities[3] == 'group_id' ? ' selected="selected"' : '') . '>' . JText::_('COM_JEPROSHOP_GROUP_LABEL') . '</option></select></div></div></div>'; $content .= '<p class="checkbox"><label for="jform_specific_price_priority_to_all"><input type="checkbox" name="price_field[specific_price_priority_to_all]" id="jform_specific_'; $content .= 'price_priority_to_all" />' . JText::_('Apply to all products') . '</label></p>'; /*<div class="form-group"> <label class="control-label col-lg-3" for="specificPricePriority1">'.$this->l('Priorities').'</label> col-lg-9"> </div> </div> <div class="form-group"> <div class="col-lg-9 col-lg-offset-3"> </div> </div> <div class="panel-footer"> <a href="'.$this->context->link->getAdminLink('AdminProducts').'" class="btn btn-default"><i class="process-icon-cancel"></i> '.$this->l('Cancel').'</a> <button id="product_form_submit_btn" type="submit" name="submitAddproduct" class="btn btn-default pull-right"><i class="process-icon-save"></i> '.$this->l('Save') .'</button> <button id="product_form_submit_btn" type="submit" name="submitAddproductAndStay" class="btn btn-default pull-right"><i class="process-icon-save"></i> '.$this->l('Save and stay') .'</button> </div> </div> '; */ $content .= '<script type="text/javascript">var currencies = new Array(); currencies[0] = new Array(); '; $content .= 'currencies[0]["sign"] = "' . $default_currency->sign . '"; currencies[0]["format"] = ' . $default_currency->format . '; '; foreach ($currencies as $currency) { $content .= ' currencies[' . $currency->currency_id . '] = new Array(); currencies[' . $currency->currency_id . ']["sign"] = "' . $currency->sign . '"; currencies[' . $currency->currency_id . ']["format"] = ' . $currency->format . ';'; } $content .= '</script>'; return $content; }
/** * 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; }
/** * Returns the product tax * * @param integer $product_id * @param integer $address_id * @param JeproshopContext $context * @return JeproshopTaxModelTax */ public static function getProductTaxRate($product_id, $address_id = null, JeproshopContext $context = null) { if ($context == null) { $context = JeproshopContext::getContext(); } $address = JeproshopAddressModelAddress::initialize($address_id); $tax_rules_id = (int) JeproshopProductModelProduct::getTaxRulesGroupIdByProductId($product_id, $context); $tax_manager = JeproshopTaxManagerFactory::getManager($address, $tax_rules_id); $tax_calculator = $tax_manager->getTaxCalculator(); return $tax_calculator->getTotalRate(); }