I would like to add a recervation fee of 20 % of the total amount. How can I do that?

Comments

facine’s picture

Hi, in the same rule could "Calculate a value" with the desired percentage and then assign the calculate result to the amount of the fee.

Regards

norsoa’s picture

Hi, Thank you. Now its working. Here how I did it.
Regards

{ "rules_add_reservation_fee_to_an_order" : {
"LABEL" : "Add reservation fee to an order",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules", "commerce_fees" ],
"ON" : [ "commerce_fees_order" ],
"DO" : [
{ "data_calc" : {
"USING" : {
"input_1" : [ "commerce-order:commerce-order-total:amount-decimal" ],
"op" : "*",
"input_2" : "20"
},
"PROVIDE" : { "result" : { "result" : "Calculation result" } }
}
},
{ "commerce_fees_apply" : {
"entity" : [ "commerce-order" ],
"fee" : "reservation_fee",
"amount" : [ "result" ],
"currency_code" : "EUR"
}
}
]
}
}

norsoa’s picture

Status: Active » Closed (fixed)
alamp’s picture

Issue summary: View changes

@norsoa, thanks it works like a charm.

svouthi’s picture

Thank you for sharing your rule. Do you know of any way to set the decimal places of the provided result? Since it's more than two decimal places and not rounded, Paypal returns an error message regarding my cart total not matching its calculation (rounded) after applying my percentage fee.

beautifulmind’s picture

@Norsoa, Thank you for sharing.
I had some hard time importing the rule because I had tax module enabled. But I figured it out. Thanks for sharing

Regards.

leramulina’s picture

But the amount field does not allow a value with percent. Only with number. Is this number just a flat sum of money in chosen currency?

leramulina’s picture

Could you please explain it somehow - how to make a fee let's say 4%?
I did not undestand anything from the explanation of norsoa.

leramulina’s picture

Status: Closed (fixed) » Active
boby_ui’s picture

@leramulina, please check on the frontpage there is a documentation on how to do it with rules and also @norsoa is already doing a good job showing us the rules export.

thank you

nexg’s picture

@norsoa , thank you , with your code I could understand a liitle bit more about rules and commerce fee module

greenrmor’s picture

@nexg , i've tried but failed to import the code given by @norsoa. what did i missed?
i solved it! Thanks @norsoa

greenrmor’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.