1

I am trying to create extension that add coupon code (Ajax) to one page checkout page last step. See http://www.lelandcope.com/2012/04/how-to-create-an-ajax-coupon-discount-code-box-in-magento/

Following code of CartController customcouponPostAction() which applies coupon code. its works fine

        $this->_getQuote()->getShippingAddress()->setCollectShippingRates(true);
        $this->_getQuote()->getShippingAddress()->collectShippingRates();
        $this->_getQuote()->setCouponCode(strlen($couponCode) ? $couponCode : '')
            ->collectTotals()
            ->save();

Shipping and handling charges calculation work fine as per table rate but when another Shopping Cart Price Rule which is free shipping above $15 (See http://www.phpro.be/news/configuring-shopping-cart-price-rules-magento-free-shipping) is also valid then shipping charge not become zero its still same as table rate.

Same scenario works like charm in cart page.

What am I missing?

  • If commented second line $this->_getQuote()->getShippingAddress()->collectShippingRates(); from above code the ajax response didn't reflect correct Shipping and handling charges even as per table rate. but if refresh page its show correct Shipping and handling charges. – Sandesh Jan 9 '14 at 15:15
1

A coupon code that enables 'Free shipping' does not automatically set the shipping price to zero. It just puts the 'Free shipping' in the shipping methods list for the customer to select.
I bet that if you refresh the checkout page after entering a valid coupon and go through all the steps again, in the shipping method step you should see the 'Free shipping' option available.

| improve this answer | |
  • Yes indeed after refresh its show correct shipping charges but If I check ajax response, shipping charges are of as per table rate not as per free shipping sales rule if applicable. – Sandesh Jan 9 '14 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.