Hi
First Create a coupon type
For example :
Shipping Method Based Coupon (Machine name: shipping_method_based_coupon)
Add a field Discount Amount - type price commerce_coupon_fixed_amount
Now completed creating coupon type.
Create a coupon with fixed amount.
--------------------------------------------------------------------
Now the complicated part is creating rule
Go to configuration->work flow -> rules
You can see a rule Redeem a coupon with fixed amount
Clone that rule and give a name a you like.I have given following name
Discount Based on Shipping Method
--------------------------
Data comparison - Edit and select your coupon type
Now add a new condition in condition box
Shipping line item exists -
Select your shipping method
and save .
Thats it
Please reply if you have further doubts
Thanks
Ajai Chandran
Comments
Hi
I figured out!
I created a variable shipping price by calculating the price of the shipping services as a percentage of ALL the total amount of the order.
I used the module Commerce Flat rate and not Commerce Coupon module.
Here how to do this:
1.Go to admin/commerce/config/shipping and Add flat rate service. Give it a name and set the base rate to 0. Save;
2.Than go to admin/commerce/config/shipping/calculation-rules and add a new calculation rule, Calculating a shipping rate;
3.Add a condition: Text comparison. Than add the Text Data selector: commerce-line-item:line-item-label; In the Matching Text Value field, type name of the shipping service you created, leave the rest as is.
4.Add an action: Calculate a value. In Data selector type the following: commerce-line-item:order:commerce-order-total:amount. Choose the operator select multiplication (*) And set INPUT Value ( -0.05 for discount 5% or -0.10 for discount 10% or the shipping discount you need; ).
Under Provided Variables specify a name and save the rule action.
5. Add another action: to an amount to the unit price. Under the Line item data selector, type the following: commerce_line_item. Then under the Amount data selector, find the variable in which you stored the calculation in the action above. Under the value of the Price Component Type, select the shipping service you created before.
That's all