I need to figure out a method to check whether a coupon code is valid or not and add this method to a boolean. I have a few cases as to why:
1.controller is offered a valid coupon code
2.controller is offered an invalid coupon code
3.controller is offered no coupon code and this will generate coupon code removal
functionality.
If(valid){
coupon is added to order, ajax response (1) is prepared
}
elseif(!valid){
ajax response (2) is prepared
}
else{
coupon is removed from order, ajax response (3) is prepared
}
TLDR: How do I check whether a coupon code is valid or not?
Best Answer
On custom controller add an action which is check current coupen is validate and and apply.
In my code i have created action
couponPostAction
and this function isreturn jSON data(message, valid)
. and you you have remove coupon then send an extra paramsremove
$this->getRequest()->getParam('remove') which coupon from current cart