Answers.Body: <p>All of Craft’s core services are available via the <code>Craft::$app-&gt;getServiceName()-&gt;callServiceMethod()</code> signature.</p>
  
  <p>For example, the Elements service would be <code>Craft::$app-&gt;getElements()-&gt;saveElement()</code></p>
  
  <p>In the case of other plugins, most will make their Singleton “instance” available as a property on (or method of) their primary plugin class:</p>
  
  <pre><code>use craft/commerce/Plugin as Commerce;
  // Maybe a class declaration, and inside your own method…
  Commerce::getInstance()-&gt;getOrders()-&gt;getOrderByNumber('abc123...');
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-09T08:51:17.957Z
Answers.Text: Ok, the 'as Commerce' did the trick, thank you!
Answers.UserDisplayName: phaetons
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-08T17:26:04.190Z
Answers.LastActivityDate: 2019-01-08T22:03:45.023Z
Answers.LastEditDate: 2019-01-08T22:03:45.023Z
Answers.UserDisplayName: August Miller
Body: <p>I am migrating my plugin to Craft 3 / Commerce 2.</p>
  
  <p>What is the best way to call another plugins method like <code>craft()-&gt;commerce_orders-&gt;getOrderByNumber($number)</code> from my plugins service?</p>
  
Tags: <plugin-development><migration><plugin-craftcommerce2>
Title: Correct way to getOrderByNumber() from my Plugin in Commerce 2
ThreadText: # Correct way to getOrderByNumber() from my Plugin in Commerce 2
  
  (Asked by: username_0 on 2019-01-08)
  
  I am migrating my plugin to Craft 3 / Commerce 2.
  
  What is the best way to call another plugins method like `craft()->commerce_orders->getOrderByNumber($number)` from my plugins service?
  
  **Tags:** plugin-development, migration, plugin-craftcommerce2
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-01-08. Score: 1 | Accepted answer
  
  All of Craft’s core services are available via the `Craft::$app->getServiceName()->callServiceMethod()` signature.
  
  For example, the Elements service would be `Craft::$app->getElements()->saveElement()`
  
  In the case of other plugins, most will make their Singleton “instance” available as a property on (or method of) their primary plugin class:
  
  ```
  use craft/commerce/Plugin as Commerce;
  // Maybe a class declaration, and inside your own method…
  Commerce::getInstance()->getOrders()->getOrderByNumber('abc123...');
  
  ```
  
  > **Comments:**
  > **username_0**: Ok, the 'as Commerce' did the trick, thank you!  
  
  ---
  
  