Forum

Thread tagged as: Question

Help with perch_shop_set_discount_code

Hello, I need some PHP help here please.

I want to use a basic php page add_to_cart.php to add products to the cart getting the pid parameter from the url. Also for a specific pid I want it to apply a discount code. So this is what I did

<?php 

$pid = perch_get('pid');

perch_shop_add_to_cart($pid);
if ($pid === '11') {
    perch_shop_set_discount_code('ABCD1234');
}
PerchSystem::redirect('/checkout-step-1');

I tested it with the specific pid and it worked but problem is that it now applies the discount to all products not only pid 11. And even if I remove the line with perch_shop_set_discount_code or disable the promotion, it still does apply the discount. Something is terribly wrong in my page but have no idea what. Anyone could guide me here?

Thanks in advance!

Proko Mountrichas

Proko Mountrichas 3 points

  • 2 years ago