Magento – Custom shipping price for particular two products after applying coupon

couponmagento-1.7shipping

I need to create a new coupon that will give a $50 discount for only two products . The customer should be charged shipping of $5 (fixed only for this two products). It should take $50 off of their cart, and then add $5 for shipping cost.

Can any body please give me some idea / guidance how to implement this? Any help will be greatly appreciated.

thanks

Edited

I am using Flat Rate shipping method for all the other products even this two particular products as well if customer doesn't use coupon.

Suppose the cost of Product A is $60 and shipping cost is $10. Grand total $60+$10 = $70

After applying coupon price will be only $15 ($10+$5)

Best Answer

You can achieve this in 2 steps.

1.Create a discount rule for 50$ that applies only to your 2 products. Add the sku's of the products in the Actions tab under the section Apply the rule only to cart items matching the following conditions (leave blank for all items)

2.Create your shipping method and inside the collectRates you can access the quote items like this: $request->getAllItems(). See if both your items are in the quote and add an extra 5$ to the cost. if they are and the quote has your coupon code applied ($quote->getCouponCode()) then make the shipping 5$.
You can get the quote like this:

$items=$request->getAllItems();
$quote = null;
foreach ($items as $item){
    $quote = $item->getQuote();
    break;
}
if ($quote){....}

Or you can just create a discount rule for those 2 products for 45$ (50-5).
Or you can make your coupon enable free shipping and make the discount 45$.

Related Topic