<p>Found it, you just need to use:</p>
<pre><code>// `sourceSnapshot` can contain information to explain the adjustment
$adjustment-&gt;sourceSnapshot = [ 'data' =&gt; 'value' ];
</code></pre>

CC BY-SA 4.0
2020-09-10T10:43:20.057Z
2020-09-10T10:43:20.057Z
José Veríssimo
<p>How do you add options or custom fields to an OrderAdjuster in Commerce 2?</p>
<p>I'm migrating a website from Craft2 to Craft3 and need this, this is how I do it in Commerce 2:</p>
<pre><code>$promotionsAdjuster-&gt;optionsJson = [
    'lineItemsAffected' =&gt; [$lineItem-&gt;id],
    'affectedDiscountId' =&gt; $adjustment-&gt;id,
    'removeAffectedDiscountAmount' =&gt; $adjustment-&gt;amount - ($lineItem-&gt;total*$adjustment-&gt;optionsJson['percentDiscount']),
    'percentageDiscount' =&gt; true
];
</code></pre>

<craft3><plugin-craftcommerce2>
How to add custom options or fields to an Order Adjuster?
# How to add custom options or fields to an Order Adjuster?

(Asked by: username_0 on 2020-09-10)

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
];

**Tags:** craft3, plugin-craftcommerce2


---

## 1 answers

### Answer by username_0 on 2020-09-10. Score: 1

Found it, you just need to use:
// `sourceSnapshot` can contain information to explain the adjustment
$adjustment->sourceSnapshot = [ 'data' => 'value' ];


---

