Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix specific prices #8002

Closed

Conversation

hibatallahAouadni
Copy link
Contributor

@hibatallahAouadni hibatallahAouadni commented Jun 13, 2017

Questions Answers
Branch? 1.6.1.x
Description? when you use specific prices for different quantities of product, as you increase the qty, the discount value will be displayed instead of discounted price, so the user will have no idea about the new discounted price
Type? bug fix
Category? FO
BC breaks? no
Deprecations? no
Fixed ticket? http://forge.prestashop.com/browse/PSCSX-9102 & http://forge.prestashop.com/browse/PSCSX-9095 & http://forge.prestashop.com/browse/PSCSX-9144
How to test? create multiple specific prices for different quantities (amount or percentage, with fixed price or without, it doesn't matter). As you increase the quantity of product on its page (in FO), the specific prices will be displayed correctly.

@fatmaBouchekoua fatmaBouchekoua added the Waiting for QA Status: action required, waiting for test feedback label Jun 13, 2017
@maximebiloe maximebiloe added this to the 1.6.1.15 milestone Jun 20, 2017
@marionf marionf added QA ✔️ Status: check done, code approved and removed Waiting for QA Status: action required, waiting for test feedback labels Jun 21, 2017
@maximebiloe
Copy link
Contributor

Unfortunately, this is a too huge front modification.
As it may break the theme compatibility, I can't merge it.

@hibatallahAouadni
Copy link
Contributor Author

@maximebiloe it's not a big change :/ it's the code review who made all this green in the tpl folder

@@ -323,24 +323,24 @@ protected function assignPriceAndTax()
$ecotax_rate = (float)Tax::getProductEcotaxRate($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
if (Product::$_taxCalculationMethod == PS_TAX_INC && (int)Configuration::get('PS_TAX')) {
$ecotax_tax_amount = Tools::ps_round($this->product->ecotax * (1 + $ecotax_rate / 100), 2);
} else {
$ecotax_tax_amount = Tools::ps_round($this->product->ecotax, 2);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

caused by Code review


$combination = new Combination((int)$quantity_discount['id_product_attribute']);
$attributes = $combination->getAttributesName((int)$this->context->language->id);
foreach ($attributes as $attribute) {
$quantity_discount['attributes'] = $attribute['name'].' - ';
$quantity_discount['attributes'] = $attribute['name'] . ' - ';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

caused by Code review

// Tables & rows selection
var quantityDiscountTable = $('#quantityDiscount');
var combinationsSpecificQuantityDiscount = $('.quantityDiscount_'+combination, quantityDiscountTable);
var combinationsSpecificQuantityDiscount = $('.quantityDiscount_' + combination, quantityDiscountTable);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

caused by Code review

{
$('#quantityDiscount tbody tr').each(function(){
function updateDiscountTable(newPrice) {
$('#quantityDiscount tbody tr').each(function () {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

caused by Code review

}
else if (type == 'amount')
{
else if (type == 'amount') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

var discountUpTo = newPrice * (discount/100) * quantity;
if (type == 'percentage') {
var discountedPrice = newPrice * (1 - discount / 100);
var discountUpTo = newPrice * (discount / 100) * quantity;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

var discountedPrice = newPrice - discount;
var discountUpTo = discount * quantity;
}

if (displayDiscountPrice != 0)
$(this).children('td').eq(1).text( formatCurrency(discountedPrice * currencyRate, currencyFormat, currencySign, currencyBlank) );
$(this).children('td').eq(1).text(formatCurrency(discountedPrice * currencyRate, currencyFormat, currencySign, currencyBlank));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too

{/if}
{if (isset($quantity_discounts) && count($quantity_discounts) > 0)}
<!-- quantity discount -->
<section class="page-product-box {if $content_only}hidden{/if}">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only add {if $content_only}hidden{/if}

@@ -399,72 +399,70 @@
{/if}
</div> <!-- end pb-right-column-->
</div> <!-- end primary_block -->
{if !$content_only}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I place this if bellow (*)

</div>
</section>
{/if}
{if !$content_only}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(*) just right here

data-discount="{$quantity_discount.real_value|floatval}"
data-base-Price="{convertPrice price= $quantity_discount.base_price}"
data-discount-formatted="{if $quantity_discount.reduction_type == 'amount'}{convertPrice price=($quantity_discount.real_value*-1)}{else}{($quantity_discount.real_value * -1)|floatval}%{/if}"
data-discount-quantity="{$quantity_discount.quantity|intval}">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right here I add some data that I need it to calculate the new price with reduction

if (noTaxForThisProduct || customerGroupWithoutTax)
updateDiscountTable(priceWithDiscountsWithoutTax);
else
updateDiscountTable(priceWithDiscountsWithTax);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(**) this one I placed just above

}
else {
updateDiscountTable(priceWithDiscountsWithTax);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(**) just right here

@maximebiloe
Copy link
Contributor

maximebiloe commented Jun 22, 2017

Yes, but as you modify the product.tpl and the product.js we can't do it into a patch version.

@hibatallahAouadni
Copy link
Contributor Author

ok

@sooroos
Copy link

sooroos commented Jul 14, 2017

hi,

this might work for the following situation as described before:

"when you use specific prices for different quantities of product, as you increase the qty, the discount value will be displayed instead of discounted price, so the user will have no idea about the new discounted price"

but it surely does NOT work when you instead of "Apply a discount of" use " change base price", meaning i need to change the base price from a certain quantity and not apply a discount of

Is there any possibility to adapt the changes for both situations and not only for the "discount" situation?

Regards

@hibatallahAouadni
Copy link
Contributor Author

Hello @sooroos this one is not complete that's why it's closed, this PR #8099 is complete abd it will be merged in the next version 1.6.1.16

@sooroos
Copy link

sooroos commented Jul 14, 2017

Hi @hibatallahAouadni . i have just tested #8099 and it is still wrong.
It updates the base price accordingly but as i said before i apply no discount and still on the product page i got displayed a reduction with "0,00€" and the previous price (which is also wrong while it is the new price)

Moreover in the "Volume discounts" table i have displayed only the qty from which the new price is changed and there is no info about the new base price, only reduction, again with 0.00€

i ll post this comment there too

@hibatallahAouadni
Copy link
Contributor Author

Hi @sooroos thanks for mention this issue we will try to edit #8099 PR before merge it

@sooroos
Copy link

sooroos commented Jul 14, 2017

@hibatallahAouadni
it is simple, i allready fixed myself, its only the product.tpl that has some mistaks. Thanks for pointing me to the right direction :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
QA ✔️ Status: check done, code approved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants