How do you add options or custom fields to an OrderAdjuster in Commerce 2?

I'm migrating a website from Craft2 to Craft3 and need this, this is how I do it in Commerce 2:

$promotionsAdjuster->optionsJson = [
    'lineItemsAffected' => [$lineItem->id],
    'affectedDiscountId' => $adjustment->id,
    'removeAffectedDiscountAmount' => $adjustment->amount - ($lineItem->total*$adjustment->optionsJson['percentDiscount']),
    'percentageDiscount' => true

1 Answer 1


Found it, you just need to use:

// `sourceSnapshot` can contain information to explain the adjustment
$adjustment->sourceSnapshot = [ 'data' => 'value' ];

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.