Show SpecificPriceRule information

Viewed 38

I need to show the specific price percentage rule for a group on my Prestashop website but I can't find the class for it. I can show the discounted percentage of a group with the code:

{if $customer.is_logged}
        {*$customerGroups|@print_r*}
        {if Group::getCurrent()->reduction}
            <p class="discount"></i> Discount: {Group::getCurrent()->reduction|string_format:"%d"}%</p>
        {/if}
{/if}

Thanks

1 Answers

First of all it would be better to move this logic into module and use some kind of custom hook or widget. View is not a place for this kind of things.

You can retrieve any SpecificPrice you want using this method:

SpecificPrice::getSpecificPrice

So, basically you can hook into displayProductAdditionalInformation and do something like:

$specificPrice = SpecificPrice::getSpecificPrice(
$this->context->controller->getProduct()->id,
$this->context->shop->id,
$this->context->currency->id,
$ID_OF_THE_GROUP
);

dump($specificPrice);

and see what you got :)

Related