2

We have a client who needs to add a 1% surcharge to online credit card orders only.

We've been fudging it via tax but that is only temporary as it won't allow us to control whether it is applied or not.

I have a feeling that we might need to manage it via Hooks but that is new territory for me. If any one has solved this problem or has some advice as to where to start I'd be grateful.

Cheers, Sean

1

It's not possible to do this natively using Store.

The best way to do it would be to write an extension using the store_order_recalculate_end hook:

https://exp-resso.com/docs/extension_hooks.html#store_order_recalculate_end

Here you can add an adjustment to the order depending on which payment method has been selected (and this would run right before the payment is submitted to the payment gateway, so as long as you tell your customers you will be adding a surcharge so that they expect the higher amount on their credit card statement).

5
  • [Redacted - error on my end]Is this as simple as adjusting the order_total property of the orders object that is passed to the hook? I'm try to update it, but it doesn't seem to be sticking.
    – Bryant
    Jan 20 '14 at 15:27
  • No, you need to add a new adjustment (adjustments are non-product line items which affect the total). In Store 2.1+ you can actually use the store_order_adjusters hook, and write your own adjuster class which adds an adjustment to the appropriate orders. That way it will automatically be included in the total, and recalculated correctly each time the order is updated. Jan 20 '14 at 20:13
  • Adrian, would you mind explaining the adjustment properties real quick? Just want to make sure I set them correctly. (ie: name, type, amount, taxable, included)
    – Bryant
    Jan 21 '14 at 15:51
  • Sure. Name and type can really be anything descriptive (current types are tax, shipping and discount, though you are by no means limited to these). Taxable should probably be true, though currently only shipping adjustments are taxed. Included should be false (it's only used for taxes which are displayed but already included in the price). Feel free to email support@exp-resso.com if you have any other questions or want a more thorough explanation :) Jan 21 '14 at 21:18
  • Hi I've got this set up using an extension using store_order_adjusters and my own adjuster class. It works great but I've got two questions. 1) My Adjuster.php file is in the Store/src/adjuster folder. Where should it live and how do I load it? 2) I may need to charge tax on the cost. If so how do I? I tried setting $adjustment->taxable = 1; but the order total does not change? Many thanks!
    – MrTomTom
    Nov 10 '14 at 5:14

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.