Jump to content

Make a page redirect if customer use certain voucher


8659design

Recommended Posts

I have maybe som odd question. On one page we have some old voucher codes that dont are in use anymore. Bur we still want contcat with customer thats try to use them.

So in prestahsop 1.5.3 solved that with this code in ParentOrderControlle.php and all have worked.

    if (($cartRule = new CartRule(CartRule::getIdByCode($code)))
                            && Validate::isLoadedObject($cartRule)
                        ) {
		if(trim(Tools::getValue('discount_name')) == 'discountA'){Tools::redirect('http://www.discountA.com');}
		elseif(trim(Tools::getValue('discount_name')) == 'discountB'){Tools::redirect('http://www.discountB.com');}
							
                            if ($error = $cartRule->checkValidity($this->context, false, true)) {
                                $this->errors[] = $error;
                            } else {
                                $this->context->cart->addCartRule($cartRule->id);
                            }
                        }

But now we will work with Prestashop 1.7.5 and still needs this function
I have found right place in cartContreller.php i think. But it seems that Tools::redirect dont work (maybe becuse this is executed with ajax?).

Does anyone have any idea how to solve this?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...