Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-10T10:43:20.057Z
Answers.LastActivityDate: 2020-09-10T10:43:20.057Z
Answers.UserDisplayName: José Veríssimo
Body: <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>
  
Tags: <craft3><plugin-craftcommerce2>
Title: How to add custom options or fields to an Order Adjuster?
ThreadText: # 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' ];
  
  ```
  
  
  ---
  
  