0

I am looking to add a rule to all orders but magento core does not do what I am looking to do. What I want to do is check the cart to see if there is a product that has a subscription set up for it. If it does then I want to check the subtotal of the cart and if over $50 give them free ground shipping. If over $150 then they get the free shipping plus 10% of the entire cart.

I have the it so that I can loop through the cart checking for subscription products that are set up to recur on a regular basis. I know this works because I can add products to the cart if it is true. But I don't want to add products I want to give free shipping plus 10% off if applicable.

Is there a way in code to set the discount amount to 10% of the subtotal of the cart? And is there a way to check the shipping method and give them free shipping if they selected ground, or better yet give them the option for free shipping if they meet the criteria during checkout?

0

For you first question:

Is there a way in code to set the discount amount to 10% of the subtotal of the cart?

Have you considered making use of the built in coupon system? What you can do is programatically create a coupon, for the required discount amount, and then apply that coupon to the cart automatically. This way magento core will ensure that you have your discount applied to the cart correctly, and the bulk of the work is done for you.

And is there a way to check the shipping method and give them free shipping if they selected ground, or better yet give them the option for free shipping if they meet the criteria during checkout?

Magento core can do this, via the shopping cart rules (give free shipping). Thus what you can do is create a new shopping cart rule, which gives free shipping if a specific coupon is applied. You can then apply the required coupon to the cart programatically (same as above, but you apply the correct coupon to activate the rule that give free shipping) This way, again, magento internals will deal with all in checkout.

If you need to give the 10% and free shipping, then just set the coupon you create in answer 1 to also include free shipping

Hope that helps.

  • Ok, I like this so far. I was able to do what you suggested, however, I now need to delete this coupon code if conditions change in the cart. What is the simplest way to cancel/delete a coupon code from the cart without completely deleting the coupon code? I was able to remove the coupon from the cart but it also deleted any other coupons that were there and I can not apply any coupons unless the recurring product and price are within the limits. I just want to be able to make sure that the coupon codes set up for this are not used unless they qualify. And all other codes can be used any time. – Jamie Nov 13 '13 at 15:18
  • I got this to work, first I created the coupon codes, then I added them to the cart if the criteria was met. To get around other coupons being in the cart and being wiped out because my recurring criteria wasn't met was I just grabbed the coupon codes already applied looped through them and re-added them after wiping out the other codes (codes associated with the recurring product) – Jamie Nov 13 '13 at 18:46
  • @jamie Good job, sounds like you got it all under control :) – ProxiBlue Nov 13 '13 at 22:20

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.