I have created a custom adjuster, there is a surcharge per item if a customer has selected rush delivery. But i need to charge tax on that adjuster. Below is code:

public function adjust(Order $order): array
    $adjustments = [];

    foreach ($order->getLineItems() as $item) {
        $adjustment = new OrderAdjustment;
        $adjustment->type = 'rush-delivery';
        $adjustment->name = 'Rush Delivery';
        $adjustment->description = 'Rush Delivery';
        $adjustment->sourceSnapshot = ['data' => 'value']; // This can contain information about how the adjustment came to be
        $adjustment->amount = 1;

        $adjustments[] = $adjustment;

    return $adjustments;

But tax is not added to the £1 i am adding here. How can i get tax to be added or calculated as included?


Having slept on it i thought it could be something to do with the order of the adjusters. Maybe Tax was applying to the price before my custom adjuster. So in the event i did the following:


This told me that my custom adjuster was going to the bottom of this array. To resolve this i used the php function array_unshift to push it to the front of the array


This now gave me the following array:

array(4) {
      string(18) "modules\MyAdjuster"
      string(33) "craft\commerce\adjusters\Shipping"
      string(33) "craft\commerce\adjusters\Discount"
      string(28) "craft\commerce\adjusters\Tax"

As you can see the adjuster is at the front of the array and now the tax applies to the fee as required.

  • When you say "in the event" do you mean EVENT_REGISTER_ORDER_ADJUSTERS? Mar 6 '20 at 15:31

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.