Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

magento: URL querystring for adding product and applying discount coupon to cart

I am a newbie, after extensive research and exploration I am able to figure out the following:

To add a product to cart I can use

/checkout/cart/add?product=76&qty=1

to apply discount code I can use

/checkout/cart/couponPost?coupon_code=WQ9D-XXXX

The code for it resides in file:

/public_html/app/code/local/Mage/Checkout/controllers/-

I would like to add product and apply discount code in one link such as:

/checkout/cart/couponPost?product=76&qty=1&coupon_code=WQ9D-XXXX

OR

/checkout/cart/add?product=76&qty=1&coupon_code=WQ9D-XXXX

OR Any other means?

Is there a way to get this working? Idea is to embed this link in a newsletter so using one click the user is able to add the product to cart and get discount.

I have tried calling $this->couponPostAction(); from function addAction() and vice-versa but it does not work!

like image 489
rukpat Avatar asked Dec 26 '22 15:12

rukpat


1 Answers

Got it working without modifying the code,

'http://www.example.com/checkout/cart/add?Product=76&qty;=1&return;_url=http://www.example.com/index.php/checkout/cart/couponPost?coupon_code=WQ9D-XXXX&return;_url=http://www.example.com/checkout/cart/'

the return_url has to be encoded.

Please see: http://www.magentocommerce.com/boards/viewthread/296763/

like image 68
rukpat Avatar answered Apr 07 '23 00:04

rukpat