|
| 1 | +# Umbraco.Cms.Integrations.Commerce.Shopify |
| 2 | + |
| 3 | +This integration provides a products picker and a value converter that uses a strongly typed model for rendering, |
| 4 | +for products within a simple [Shopify](https://www.shopify.com/) store or through custom apps developed by [Shopify Partners](https://www.shopify.com/partners). |
| 5 | + |
| 6 | +## Prerequisites |
| 7 | + |
| 8 | +Requires minimum version of Umbraco CMS: 8.5.4. |
| 9 | + |
| 10 | +## How To Use |
| 11 | + |
| 12 | +### Authentication |
| 13 | + |
| 14 | +The package supports two modes of authentication: |
| 15 | + |
| 16 | +- API Access Token |
| 17 | +- OAuth |
| 18 | + |
| 19 | +#### API Access Token |
| 20 | + |
| 21 | +Log into the admin interface of your shop by accessing `https://{shop}.myshopify.com/admin`, go to _Apps > Develop apps_ and create a new App for the shop (if App Development feature is disabled, you will need to enable it). |
| 22 | + |
| 23 | +After the app is created, define the scopes for the Admin API: _read_products_ , then select the option to _Install App_. |
| 24 | + |
| 25 | +Once the app is installed the Admin API access token will be visible only once in the _API credentials_ tab. |
| 26 | + |
| 27 | +Use the access token and add it to an app setting in `Web.config` alongside settings for the API version and the name of the shop: |
| 28 | + |
| 29 | +``` |
| 30 | + <appSettings> |
| 31 | + ... |
| 32 | + <add key="Umbraco.Cms.Integrations.Commerce.Shopify.ApiVersion" value="2022-01" /> |
| 33 | + <add key="Umbraco.Cms.Integrations.Commerce.Shopify.AccessToken" value="[your access token]" /> |
| 34 | + <add key="Umbraco.Cms.Integrations.Commerce.Shopify.Shop" value="[your shop's name]" /> |
| 35 | + ... |
| 36 | + </appSettings> |
| 37 | +``` |
| 38 | + |
| 39 | +Shopify releases a new API version every 3 months at the beginning of the quarter. Latest stable version used for this integration is [2022-01](https://shopify.dev/api/usage/versioning). |
| 40 | + |
| 41 | +#### OAuth |
| 42 | + |
| 43 | +If you prefer not to use an API key, an authentication flow using OAuth is also available. |
| 44 | + |
| 45 | +To use this, simply ensure you don't have an API key in your configuration file. |
| 46 | + |
| 47 | +### Backoffice usage |
| 48 | + |
| 49 | +To use the products picker, a new data type should be created based on the Shopify Products Picker property editor. |
| 50 | + |
| 51 | +The settings in `Web.config` will be checked and a message presented indicating whether authenticiation is in place. |
| 52 | + |
| 53 | +If OAuth is being used for authentication is available, then the _Connect_ button will be enabled, prompting the user when clicked, |
| 54 | +with the Shopify authorization window. |
| 55 | + |
| 56 | +The retrieved access token will be saved into the database and used for future requests. |
| 57 | + |
| 58 | +_Revoke_ action will remove the access token from the database and the authorization process will need to be repeated. |
| 59 | + |
| 60 | +### Front-end rendering |
| 61 | + |
| 62 | +A strongly typed model will be generated by the property value converter, and an HTML helper is available, to easily render the products on the front-end. |
| 63 | + |
| 64 | +Ensure your template has a reference to the following using statement: |
| 65 | + |
| 66 | +``` |
| 67 | +@using Umbraco.Cms.Integrations.Commerce.Shopify.Helpers; |
| 68 | +``` |
| 69 | + |
| 70 | +And render the form using (assuming a property based on the created data type, with alias `shopifyProductPicker` has been created): |
| 71 | + |
| 72 | +``` |
| 73 | +@Html.RenderProductsList(Model.ShopifyProductPicker) |
| 74 | +``` |
| 75 | + |
| 76 | +### Developer Notes |
| 77 | + |
| 78 | +To copy the front-end assets to the test site While in DEBUG mode, use following post build events: |
| 79 | +``` |
| 80 | + set UmbracoCmsIntegrationsTestsiteV8Path=$(SolutionDir)\Umbraco.Cms.Integrations.Testsite.V8 |
| 81 | + set ShopifyDir=%UmbracoCmsIntegrationsTestsiteV8Path%\App_Plugins\UmbracoCms.Integrations\Commerce\Shopify |
| 82 | + if not exist %ShopifyDir% mkdir -p %ShopifyDir% |
| 83 | + xcopy "$(ProjectDir)App_Plugins\UmbracoCms.Integrations\Commerce\Shopify" "%ShopifyDir%" /e /y |
| 84 | +``` |
0 commit comments