0
votes

Prestashop 1.6.1.10

When creating a product with combination and a customer group discount, the product page display the price without the discount.

But when you add the product to cart the discount is apply.

See a product with combination and group discount

1

1 Answers

1
votes

I solved by the following code change in controllers\front\ProductController.php

add function:

protected function getGroupReduction() {
    $id_customer = (isset($this->context->customer) ? (int)$this->context->customer->id : 0);
    $id_group = (int)Group::getCurrent()->id;
    $id_country = $id_customer ? (int)Customer::getCurrentCountry($id_customer) : (int)Tools::getCountry();

    $group_reduction = GroupReduction::getValueForProduct($this->product->id, $id_group);
    if ($group_reduction === false) {
        $group_reduction = Group::getReduction((int)$this->context->cookie->id_customer) / 100;
    }
    return $group_reduction;
}

replace line 467:

$combinations[$row['id_product_attribute']]['price'] = (float)Tools::convertPriceFull($row['price'], null, Context::getContext()->currency, false);

with the following lines:

            $group_reduction = $this->getGroupReduction();
            $price = $row['price'] - $row['price']* $group_reduction;
            $combinations[$row['id_product_attribute']]['price'] = (float)Tools::convertPriceFull($price, null, Context::getContext()->currency, false);