From 268f1fd030016a5744e0054d64f37b8de364edc5 Mon Sep 17 00:00:00 2001
From: gRoussac
Date: Fri, 5 Jul 2013 12:11:02 +0200
Subject: [PATCH 1/5] [-] FO : Bad specific price for a combination
---
themes/default/js/product.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/themes/default/js/product.js b/themes/default/js/product.js
index 7bea5e445..1b141da95 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'] > 0)
{
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
From 128ceffcc0be92e138833878cda94e1e4da33180 Mon Sep 17 00:00:00 2001
From: gRoussac
Date: Fri, 5 Jul 2013 12:28:10 +0200
Subject: [PATCH 2/5] [-] FO : Bad specific price for a combination // sorry
---
themes/default/js/product.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/themes/default/js/product.js b/themes/default/js/product.js
index 1b141da95..193da82e5 100644
--- a/themes/default/js/product.js
+++ b/themes/default/js/product.js
@@ -326,8 +326,9 @@ function updateDisplay()
reduction = ps_round(reduction / tax, 6);
}
- else if (product_specific_price && product_specific_price.reduction && selectedCombination['specific_price'] > 0)
+ else if (product_specific_price && product_specific_price.reduction && !selectedCombination.specific_price)
{
+ console.log('qsdqsd');
if (product_specific_price.reduction_type == 'amount')
reduction_price = (specific_currency ? product_specific_price.reduction : product_specific_price.reduction * currencyRate);
else
From 91cd196cf6586a9f558290faf619658aa284d70e Mon Sep 17 00:00:00 2001
From: gRoussac
Date: Fri, 5 Jul 2013 12:29:29 +0200
Subject: [PATCH 3/5] // remove console.log sorry bad commit
---
themes/default/js/product.js | 1 -
1 file changed, 1 deletion(-)
diff --git a/themes/default/js/product.js b/themes/default/js/product.js
index 193da82e5..5a4b4e8c8 100644
--- a/themes/default/js/product.js
+++ b/themes/default/js/product.js
@@ -328,7 +328,6 @@ function updateDisplay()
}
else if (product_specific_price && product_specific_price.reduction && !selectedCombination.specific_price)
{
- console.log('qsdqsd');
if (product_specific_price.reduction_type == 'amount')
reduction_price = (specific_currency ? product_specific_price.reduction : product_specific_price.reduction * currencyRate);
else
From 62ff976d69f4f5efd3413227f20bed429705e7b7 Mon Sep 17 00:00:00 2001
From: Damien Metzger
Date: Fri, 5 Jul 2013 14:24:39 +0200
Subject: [PATCH 4/5] // Removed redundant function calls
---
classes/Cart.php | 34 ++++++++++-----------------------
modules/blockcart/blockcart.php | 5 +++--
2 files changed, 13 insertions(+), 26 deletions(-)
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);
From 9f0867b7004b7052826eb74c2146f2b30e1c1c4d Mon Sep 17 00:00:00 2001
From: gRoussac
Date: Fri, 5 Jul 2013 14:42:39 +0200
Subject: [PATCH 5/5] [-] FO : could not see old_price_display when specific
price on one combination
---
themes/default/product.tpl | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
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()}