Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

E-Commerce Modules /

Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.

Moderators: martimiz, Nicolaas, Sean, Ed, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba

Add Processing Fee if Paying By Credit Card

Go to End



Community Member, 8 Posts

12 September 2012 at 8:46pm

I am hoping someone might be able to give me some direction on how to make my checkout process apply a 3% fee only if the consumer is paying by credit card. There is a radio button for 'Invoice' or 'Credit Card' and if 'Credit Card' is selected I would like the cart to update with Javascript to show the new total.

I already have some other custom functions for different fees (eg insurance) but they are all applied irrespective of what payment method.

I am not sure how to get the SubTotal and Total functions available in the javascript function. I have used the

function updateForAjax(array &$js) {
                $insurance = $subTotal * 0.08;
		$insurance = DBField::create('Currency', $this->Insurance())->Nice();
                $js[] = array('id' => $this->InsuranceID(), 'parameter' => 'innerHTML', 'value' => $insurance);

for the other custom functions, but not sure how to test what option is selected to determine if a fee should be applied or not. Or even if this is the way to do it.

I am still pretty new to Silverstripe, so still trying to get my head around it.