Answers.Body: <p>I realize that this is an older question, but I have found the answer for it after much searching, and want to leave this answer for others who might be coming from a search engine.</p>
  
  <p>The way I have found that you would do this is with the Stripe Payments plugin. The documentation for it can be found at <a href="https://github.com/craftcms/commerce-stripe" rel="noreferrer">https://github.com/craftcms/commerce-stripe</a>. </p>
  
  <p>From there, you will find that there is a beforeSubscribe event. You can use that to set parameters for quantity. From the documentation:</p>
  
  <pre><code>use craft\commerce\stripe\events\SubscriptionRequestEvent;
  use craft\commerce\stripe\base\SubscriptionGateway as StripeGateway;
  use yii\base\Event;
  
  Event::on(StripeGateway::class, StripeGateway::EVENT_BEFORE_SUBSCRIBE, function(SubscriptionRequestEvent $e) {
      $e-&gt;parameters['someKey'] = 'some value';
      unset($e-&gt;parameters['unneededKey']);
  });
  </code></pre>
  
  <p>For my subscription, I have found that <code>$e-&gt;parameters['items'][0]['quantity'] = 3;</code> works for my setup. </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-11T12:17:03.240Z
Answers.LastActivityDate: 2019-06-11T12:45:07.060Z
Answers.LastEditDate: 2019-06-11T12:45:07.060Z
Answers.UserDisplayName: Brian McCaul
Body: <h2><em>How can I pass in a quantity value while creating a subscription?</em></h2>
  
  <hr>
  
  <p><strong>Plugin (version):</strong> </p>
  
  <ul>
  <li><p><strong>Craft CMS</strong> (3.1.21)</p></li>
  <li><p><strong>Craft Commerce</strong> (2.1.2) </p></li>
  <li><p><strong>Stripe for Craft Commerce</strong> (1.2.0)</p></li>
  </ul>
  
  <hr>
  
  <p><strong>Problem:</strong> My website allows users to subscribe to meal plans. For example, a user can subscribe to receive 5 vegetarian meals per week. Another user may also subscribe to recieve 10 meals per week. Currently, I must create two subscritpion plans on Stripe and on Craft (i.e Vegetarian-5 and Vegetarian-10). <strong>Stripe's API</strong> offers the ability to create a single plan that <a href="https://stripe.com/docs/billing/subscriptions/quantities" rel="nofollow noreferrer">charges per quantity</a> (i.e I want to create one Vegetarian Plan and charge $10 per meal). </p>
  
  <p>I wrote a <strong>plugin</strong> that uses <strong>createSubscription()</strong> from <a href="https://docs.craftcms.com/commerce/api/v2/craft-commerce-services-subscriptions.html#public-methods" rel="nofollow noreferrer">craft\commerce\services</a>. However, ideally I want to send a quantity value but after reviewing Craft's logic for this function, I am unable to figure out a way to pass in a <strong>quantity</strong> value. However, I could easily bypass Craft and use the Stripe's API to do this (<a href="https://stripe.com/docs/billing/subscriptions/quantities" rel="nofollow noreferrer">setting subscription quantity through stripe API</a>) but that feels like the wrong solution. </p>
  
Tags: <craft3><plugin-craftcommerce2>
Title: Setting Quantity Field on Subscriptions
ThreadText: # Setting Quantity Field on Subscriptions
  
  (Asked by: username_0 on 2019-04-08)
  
  ## *How can I pass in a quantity value while creating a subscription?*
  
  ---
  
  **Plugin (version):**
  
  * **Craft CMS** (3.1.21)
  * **Craft Commerce** (2.1.2)
  * **Stripe for Craft Commerce** (1.2.0)
  
  ---
  
  **Problem:** My website allows users to subscribe to meal plans. For example, a user can subscribe to receive 5 vegetarian meals per week. Another user may also subscribe to recieve 10 meals per week. Currently, I must create two subscritpion plans on Stripe and on Craft (i.e Vegetarian-5 and Vegetarian-10). **Stripe's API** offers the ability to create a single plan that [charges per quantity](https://stripe.com/docs/billing/subscriptions/quantities) (i.e I want to create one Vegetarian Plan and charge $10 per meal).
  
  I wrote a **plugin** that uses **createSubscription()** from [craft\commerce\services](https://docs.craftcms.com/commerce/api/v2/craft-commerce-services-subscriptions.html#public-methods). However, ideally I want to send a quantity value but after reviewing Craft's logic for this function, I am unable to figure out a way to pass in a **quantity** value. However, I could easily bypass Craft and use the Stripe's API to do this ([setting subscription quantity through stripe API](https://stripe.com/docs/billing/subscriptions/quantities)) but that feels like the wrong solution.
  
  **Tags:** craft3, plugin-craftcommerce2
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-06-11. Score: 5 | Accepted answer
  
  I realize that this is an older question, but I have found the answer for it after much searching, and want to leave this answer for others who might be coming from a search engine.
  
  The way I have found that you would do this is with the Stripe Payments plugin. The documentation for it can be found at <https://github.com/craftcms/commerce-stripe>.
  
  From there, you will find that there is a beforeSubscribe event. You can use that to set parameters for quantity. From the documentation:
  
  ```
  use craft\commerce\stripe\events\SubscriptionRequestEvent;
  use craft\commerce\stripe\base\SubscriptionGateway as StripeGateway;
  use yii\base\Event;
  
  Event::on(StripeGateway::class, StripeGateway::EVENT_BEFORE_SUBSCRIBE, function(SubscriptionRequestEvent $e) {
      $e->parameters['someKey'] = 'some value';
      unset($e->parameters['unneededKey']);
  });
  
  ```
  
  For my subscription, I have found that `$e->parameters['items'][0]['quantity'] = 3;` works for my setup.
  
  
  ---
  
  