diff --git a/classes/Cart.php b/classes/Cart.php index 731857cd7..4501178ef 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -2543,6 +2543,7 @@ class CartCore extends ObjectModel if (empty($id_carrier) && $this->isCarrierInRange((int)Configuration::get('PS_CARRIER_DEFAULT'), (int)$id_zone)) $id_carrier = (int)Configuration::get('PS_CARRIER_DEFAULT'); + $total_package_without_shipping_tax_inc = $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING, $product_list); if (empty($id_carrier)) { if ((int)$this->id_customer) @@ -2577,7 +2578,7 @@ class CartCore extends ObjectModel { $check_delivery_price_by_weight = Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $this->getTotalWeight(), (int)$id_zone); - $total_order = $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING, $product_list); + $total_order = $total_package_without_shipping_tax_inc; $check_delivery_price_by_price = Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $total_order, (int)$id_zone, (int)$this->id_currency); // Get only carriers that have a range compatible with cart @@ -2680,26 +2681,8 @@ class CartCore extends ObjectModel $id_zone = (int)$default_country->id_zone; } - $check_delivery_price_by_weight = Carrier::checkDeliveryPriceByWeight((int)$carrier->id, $this->getTotalWeight(), (int)$id_zone); - - // Code Review V&V TO FINISH - $check_delivery_price_by_price = Carrier::checkDeliveryPriceByPrice( - $carrier->id, - $this->getOrderTotal( - true, - Cart::BOTH_WITHOUT_SHIPPING, - $product_list - ), - $id_zone, - (int)$this->id_currency - ); - - if (( - $carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT - && !$check_delivery_price_by_weight - ) || ( - $carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE - && !$check_delivery_price_by_price + if (($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT && !Carrier::checkDeliveryPriceByWeight($carrier->id, $this->getTotalWeight(), (int)$id_zone)) + || ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE && !Carrier::checkDeliveryPriceByPrice($carrier->id, $total_package_without_shipping_tax_inc, $id_zone, (int)$this->id_currency) )) $shipping_cost += 0; else @@ -2846,7 +2829,10 @@ class CartCore extends ObjectModel $formatted_addresses['delivery'] = AddressFormat::getFormattedLayoutData($delivery); $formatted_addresses['invoice'] = AddressFormat::getFormattedLayoutData($invoice); - $total_tax = $this->getOrderTotal() - $this->getOrderTotal(false); + $base_total_tax_inc = $this->getOrderTotal(true); + $base_total_tax_exc = $this->getOrderTotal(false); + + $total_tax = $base_total_tax_inc - $base_total_tax_exc; if ($total_tax < 0) $total_tax = 0; @@ -2944,9 +2930,9 @@ class CartCore extends ObjectModel 'total_shipping_tax_exc' => $total_shipping_tax_exc, 'total_products_wt' => $total_products_wt, 'total_products' => $total_products, - 'total_price' => $this->getOrderTotal(), + 'total_price' => $base_total_tax_inc, 'total_tax' => $total_tax, - 'total_price_without_tax' => $this->getOrderTotal(false), + 'total_price_without_tax' => $base_total_tax_exc, 'is_multi_address_delivery' => $this->isMultiAddressDelivery() || ((int)Tools::getValue('multi-shipping') == 1), 'free_ship' => $total_shipping ? 0 : 1, 'carrier' => new Carrier($this->id_carrier, $id_lang), diff --git a/modules/blockcart/blockcart.php b/modules/blockcart/blockcart.php index 0dfce8c19..da283ece7 100644 --- a/modules/blockcart/blockcart.php +++ b/modules/blockcart/blockcart.php @@ -63,8 +63,9 @@ class BlockCart extends Module $nbTotalProducts += (int)$product['cart_quantity']; $cart_rules = $params['cart']->getCartRules(); - $shipping_cost = Tools::displayPrice($params['cart']->getOrderTotal($useTax, Cart::ONLY_SHIPPING), $currency); - $shipping_cost_float = Tools::convertPrice($params['cart']->getOrderTotal($useTax, Cart::ONLY_SHIPPING), $currency); + $base_shipping = $params['cart']->getOrderTotal($useTax, Cart::ONLY_SHIPPING); + $shipping_cost = Tools::displayPrice($base_shipping, $currency); + $shipping_cost_float = Tools::convertPrice($base_shipping, $currency); $wrappingCost = (float)($params['cart']->getOrderTotal($useTax, Cart::ONLY_WRAPPING)); $totalToPay = $params['cart']->getOrderTotal($useTax); diff --git a/themes/default/js/product.js b/themes/default/js/product.js index 7bea5e445..5a4b4e8c8 100644 --- a/themes/default/js/product.js +++ b/themes/default/js/product.js @@ -326,7 +326,7 @@ function updateDisplay() reduction = ps_round(reduction / tax, 6); } - else if (product_specific_price && product_specific_price.reduction) + else if (product_specific_price && product_specific_price.reduction && !selectedCombination.specific_price) { if (product_specific_price.reduction_type == 'amount') reduction_price = (specific_currency ? product_specific_price.reduction : product_specific_price.reduction * currencyRate); @@ -387,6 +387,7 @@ function updateDisplay() } $('#our_price_display').text(our_price); $('#old_price_display').text(formatCurrency(productPriceWithoutReductionDisplay, currencyFormat, currencySign, currencyBlank)); + if (productPriceWithoutReductionDisplay > productPriceDisplay) $('#old_price,#old_price_display,#old_price_display_taxes').show(); else diff --git a/themes/default/product.tpl b/themes/default/product.tpl index 21d0c3b23..508639287 100644 --- a/themes/default/product.tpl +++ b/themes/default/product.tpl @@ -410,19 +410,12 @@ var fieldRequired = '{l s='Please fill in all the required fields before saving {/if}
- {if $product->specificPrice AND $product->specificPrice.reduction && $product->specificPrice.reduction > 0} -- {if $priceDisplay >= 0 && $priceDisplay <= 2} - {if $productPriceWithoutReduction > $productPrice} - {convertPrice price=$productPriceWithoutReduction} - - {/if} - {/if} - -
+specificPrice || !$product->specificPrice.reduction} class="hidden"{/if}> + {if $priceDisplay >= 0 && $priceDisplay <= 2} + {if $productPriceWithoutReduction > $productPrice}{convertPrice price=$productPriceWithoutReduction}{/if} + {/if} +
{if $packItems|@count && $productPrice < $product->getNoPackPrice()}{l s='Instead of'} {convertPrice price=$product->getNoPackPrice()}