I have implemented and eshop with commerce module in drupal 8. How can I add extra cost in case the customer chooses the cash on delivery method? I use payment module. Is there any solution or some other alternative? I tried rules also, but there is not any event that is triggered on payment method selection.

  • The question would be how will Drupal know when delivery is completed... At some point I think you’d need a second human interaction with your commerce forms. And I think that’s the answer. Forms. Either you submit second form, containing the “incomplete purchase form, or something like amazon, let your delivery agent present the purchaser with a mobile form, let that complete your order. Is there more info you could provide? Just looking for a hook maybe? Commented Apr 1, 2019 at 14:58
  • @Prestosaurus thanks for the help! What I need basically, is a fixed cost to be added in case a client chooses the cash on delivery method. Ofcourse this cost should be visible and be added in the cart summary total price. I found this link as well as a module but they are for drupal 7 only.. Commented Apr 2, 2019 at 5:26
  • Presenting a product with a different price to the user is what product types, product attributes, and product variations are for. But there could be 100 ways to alter a commerce product price. The "fixed" cost could even be"dynamic" based on distance from the shipping address, but, I think having a more concise question will help get a better response... docs.drupalcommerce.org/commerce2/user-guide/products/…, is there a more particular issue? Commented Apr 2, 2019 at 14:55
  • @Prestosaurus in my case the cash on delivery extra cost is not related to product or its type but it is universal for all products no matter distance etc. It is an extra fee for a particular payment method. So the question is whether it is possible an extra fee to be added and be displayed in cart summary in any order in case a customer chooses the COD as payment gateway. Commented Apr 2, 2019 at 19:31

1 Answer 1


It's been a long time since this has been asked, but I'm adding my input here since I bumped into this while looking for the exact same thing for one of my projects. The way I found as the cleanest and most straight forward, while reading through the documentation, is the use of an order processor class that would check the current order for the use of the payment method in question and add an adjustment accordingly. You can have a look here on information as to how to setup an order processor https://docs.drupalcommerce.org/commerce2/developer-guide/orders/order-refresh-and-process. The class has to implement the \Drupal\commerce_order\OrderProcessorInterface and it has to provide an implementation of the process method.

class MyCustomProcessor implements OrderProcessorInterface {

    public function process(OrderInterface $order) {
        $payment = $order->get('payment_method')->first()->entity;
//   or 
        $payment = $order->get('payment_gateway')->first()->entity;

//... your logic here depending on what you'd like to do 

        $order->addAdjustment(new Adjustment([
            'type' => 'fee',
            'label' => 'Payment method fee',
            'amount' => new Price($fee, 'EUR')


Based on the instructions above have created this example module https://github.com/GiorgosK/commerce_custom_fees

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.