# Orders (Shopify & Virtualstock Supplier)

## Introduction

Sales orders are pulled from *Virtualstock Supplier* and created in *Shopify* with a `paid` and `unfulfilled` status. Finally, an acknowledgement is sent back to *Virtualstock Supplier*.

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2Fy22oHayvzwYoQMrlctZd%2Forder%20flow%20illustration.png?alt=media&#x26;token=b98360a6-bbd0-4868-aa8e-584631ec001a" alt=""><figcaption></figcaption></figure>

Any orders with an `ORDER` status are pulled from *Virtualstock Supplier*. Once an order is successfully sent into *Shopify*, we send an `ORDER_ACK` back to *Virtualstock Supplier* - the order is then moved into `ORDER_ACK` status so that it won't be picked up in subsequent flow runs.

## &#x20;Process flow snapshot

<details>

<summary><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FSUvxsp8XwrC9qsafJMIe%2Ficon%20process%20flow.svg?alt=media&#x26;token=ad1dc886-4a4e-4cad-9ad0-3d755e0f3b5a" alt="" data-size="line"> Process flow snapshot</summary>

<img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FBgih1EbGkVxajNKR9Soa%2Forders%20flow.png?alt=media&#x26;token=123e07f9-8579-4cfe-85c8-c0e5449aac63" alt="" data-size="original">

</details>

## Operations count <a href="#app-installation-and-setup" id="app-installation-and-setup"></a>

The operations count for this process flow is: **4 per order**.

## Process flow shapes

For reference, all shapes in this process flow are documented below. Do not change shape settings unless advised to do so in our [installation guide](https://doc.wearepatchworks.com/product-documentation/blueprints/patchworks-blueprints/shopify-and-virtualstock-supplier/installation-guide-shopify-and-virtualstock-supplier). &#x20;

<table data-full-width="false"><thead><tr><th width="230">Shape</th><th>Notes</th></tr></thead><tbody><tr><td>Trigger</td><td>Having installed the blueprint, edit this shape and define your preferred run schedule. Please see the <a href="../installation-guide-shopify-and-virtualstock-supplier/stage-5-review-and-test-the-orders-process-flow-shopify-and-virtualstock-supplier">installation guide</a> for specific notes.</td></tr><tr><td>Connector</td><td>If instance credentials are provided as part of the blueprint installation, there should be no need to change any settings for this shape. For reference, the required settings are:<br><br><code>Source instance</code>: Virtualstock Supplier <br><code>Source endpoint</code>: GET List orders<br><code>Variables</code>: Set as <code>Status</code> / <code>ORDER</code></td></tr><tr><td>Flow control</td><td>There should be no need to change any settings for this shape. For reference, required settings are:<br><br><code>Source instance</code>: Virtualstock Supplier <br><code>Source endpoint</code>: GET List orders<br><code>Batch level</code>: *<br><code>Batch size</code>: 1</td></tr><tr><td>Map</td><td>Generally, field mappings should not be changed. However please refer to the <a href="../installation-guide-shopify-and-virtualstock-supplier/stage-5-review-and-test-the-orders-process-flow-shopify-and-virtualstock-supplier">installation guidelines for this process flow</a> for any fields that are noted for special attention.<br><br><code>Source instance</code>: None <br><code>Source endpoint</code>: None</td></tr><tr><td>Add to cache</td><td>These settings should not be changed. For reference, required settings are:<br><br><code>Cache</code>: (Flow run) VSSalesOrder<br><code>Cache key</code>: VSSalesOrder<br><code>Append</code>: OFF<br><code>Save all pages</code>: OFF<br></td></tr><tr><td>Script</td><td>These settings should not be changed. For reference, required settings are:<br><br><code>Script</code>: SKU Search Script<br><code>Version</code>: v3 (latest) </td></tr><tr><td>Connector</td><td>If instance credentials are provided as part of the blueprint installation, there should be no need to change any settings for this shape. For reference, the required settings are:<br><br><code>Source instance</code>: Shopify <br><code>Source endpoint</code>: POST Get VariantID by SKU - GraphQL<br><code>Variables</code>: Set as <code>Query String</code>  / <code>[[payload.productCodeString]]</code></td></tr><tr><td>Add to cache</td><td>These settings should not be changed. For reference, required settings are:<br><br><code>Cache</code>: (Flow run) VSSalesOrder<br><code>Cache key</code>: VSSalesOrder<br><code>Append</code>: ON<br><code>Path to append to</code>: SKUData<br><code>Save all pages</code>: OFF</td></tr><tr><td>Load from cache</td><td>These settings should not be changed. For reference, required settings are:<br><br><code>Cache</code>: (Flow run) VSSalesOrder<br><code>Cache key</code>: VSSalesOrder<br><code>Fail on cache miss</code>: OFF<br><code>Load all pages</code>: OFF</td></tr><tr><td>Script</td><td>These settings should not be changed. For reference, required settings are:<br><br><code>Script</code>: Match Shopify Variant to SKU<br><code>Version</code>: v3 (latest) </td></tr><tr><td>Connector</td><td>If instance credentials are provided as part of the blueprint installation, there should be no need to change any settings for this shape. For reference, the required settings are:<br><br><code>Source instance</code>: Shopify <br><code>Source endpoint</code>: POST Create an order</td></tr><tr><td>Route</td><td>If instance credentials are provided as part of the blueprint installation, there should be no need to change any settings for this shape. For reference, the required settings are:<br><br><code>Source instance</code>: Virtualstock Supplier<br><code>Source endpoint</code>: N/A<br><code>Routing method</code>: Follow all matching routes<br><code>Route 1</code>: No Errors<br><code>Route 2</code>: Error<br><br><code>Route 1</code><br><code>Payload fields</code>: order.id<br><code>Type</code>: Null comparison<br><code>Operator</code>: Not NULL<br><code>Keep matching</code>: ON<br><br><code>Route 2</code><br><code>Payload fields</code> order.id<br><code>Type</code>: Null comparison<br><code>Operator</code>: Is NULL<br><code>Keep matching</code>: ON</td></tr><tr><td>(Route 1) Script</td><td>These settings should not be changed. For reference, required settings are:<br><br><code>Script</code>: Save Order URI ID to Meta Var<br><code>Version</code>: v6 (latest) </td></tr><tr><td>(Route 1) Map</td><td>Generally, field mappings should not be changed. However please refer to the <a href="../installation-guide-shopify-and-virtualstock-supplier/stage-5-review-and-test-the-orders-process-flow-shopify-and-virtualstock-supplier">installation guidelines for this process flow</a> for any fields that are noted for special attention.<br><br><code>Source instance</code>: None <br><code>Source endpoint</code>: None</td></tr><tr><td>(Route 1) Connector</td><td>If instance credentials are provided as part of the blueprint installation, there should be no need to change any settings for this shape. For reference, the required settings are:<br><br><code>Source instance</code>: Virtualstock Supplier <br><code>Source endpoint</code>: POST Acknowledge an order<br><code>Variables</code>: Set as <code>Order URI</code>  / <code>[[meta.VSorderId]]</code></td></tr><tr><td>(Route 2) Connector</td><td>These settings should not be changed. For reference, required settings are:<br><br><code>Expected Payload</code>: Order failed to create if reached here.</td></tr></tbody></table>

## Scripts used in this process flow

<table><thead><tr><th width="293">Script</th><th>Summary</th></tr></thead><tbody><tr><td>Phone Number Formatter</td><td>Corrects formatting for UK telephone numbers.</td></tr><tr><td>SKU Search Script</td><td>Creates GraphQL input for Shopify.</td></tr><tr><td>Match Shopify Variant Id to SKU</td><td>Replaces sales order SKUs with variant Ids.</td></tr><tr><td>Save Order URI ID to Meta Var</td><td>Extracts URI from Shopify notes.</td></tr><tr><td>Calculate dispatch date using orderDate</td><td>Takes Shopify's order created date and adds 5 days to calculate the supplier delivery date. If required, you can change the number of days used for this calculation - please see the <a href="../installation-guide-shopify-and-virtualstock-supplier/stage-5-review-and-test-the-orders-process-flow-shopify-and-virtualstock-supplier">installation guide</a> for details.</td></tr></tbody></table>

## Cross-reference lookups used in this process flow

<table><thead><tr><th width="293">Cross-reference lookup</th><th>Summary</th></tr></thead><tbody><tr><td>Carrier map</td><td>Maps Shopify tracking companies to Virtualstock carriers (and vice versa). You need to update this table with your own values - please see the <a href="../installation-guide-shopify-and-virtualstock-supplier/stage-4-update-cross-reference-lookups-shopify-to-virtualstock-supplier">installation guide</a> for details.</td></tr><tr><td>SKU Lookup</td><td>Maps <em>Virtualstock Supplier</em> part numbers to Shopify SKUs. You need to update this table with your own values - please see the <a href="../installation-guide-shopify-and-virtualstock-supplier/stage-4-update-cross-reference-lookups-shopify-to-virtualstock-supplier">installation guide</a> for details.</td></tr></tbody></table>
