You may have noticed that when you combine a quantity discount and a price dedicated to one of your customers on the same product, Prestashop gets confused.
Let’s take a look at how to solve this Prestashop-specific pricing problem.
Example of mismanagement of specific price priorities
I’m Mr CHARTIER and I’ll be paying €2.12 for this item, as that’s the price the merchant has set for me.
But the merchant has also decided to offer a discount to anyone who buys 75 copies of this product.
The price for these good customers will be €2.35 each instead of €2.50.
Here’s how it looks in Front Office (FO) and Back Office (BO).
I’m offered my specific price, but if I buy 75 copies, what happens?
My price will go up, because the “reduction” is –0.23 €.
Notice the functional and display inconsistencies?
Take the test!
A client of my web agency encountered this problem, and here’s how we dealt with it.
Mind you, this may not be the best solution for you, but our client’s need was as follows:
If a specific price applies to customer X, then quantity discounts should not be taken into account for this customer.
To start with, we’re going to create an overload of the SpecificPrice class, and it’s in this other article that I explain why it’s better to create an overload rather than modify the Prestashop core.
<?php
class SpecificPrice extends SpecificPriceCore {
}
We retrieve the getQuantityDiscounts and getQuantityDiscount functions and create the getCustomerSpecificPrice function to check for the presence of a rule applicable to a particular customer.
public static function getCustomerSpecificPrice($id_product, $id_product_attribute,$id_customer) {
$sql = 'SELECT `id_specific_price` FROM '._DB_PREFIX_.'specific_price WHERE `id_product`='.(int)$id_product.' AND `id_product_attribute`='.(int)$id_product_attribute.' AND `id_customer`='.(int)$id_customer;
return (int)Db::getInstance()->getValue($sql);
}
We modify the start of the getQuantityDiscounts and getQuantityDiscount functions as follows:
if (!SpecificPrice::isFeatureActive())
return array();
if (SpecificPrice::getCustomerSpecificPrice($id_product, $id_product_attribute, $id_customer))
return array();
The problem of Prestashop-specific price priority has been resolved.