{"title":"Extend the Shopify Connector","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/devenv-extending-shopify/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-extending-shopify, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-extending-shopify","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Discover extensibility options for the Shopify Connector, including event subscriptions, API interactions, and co-development contributions.","date":"2026-09-03","meta":{"topic":"how-to"},"outline":[{"level":1,"title":"Extend the Shopify Connector","slug":"extend-the-shopify-connector","at":0,"chars":31128},{"level":2,"title":"Extensibility approaches","slug":"extensibility-approaches","at":31,"chars":2003},{"level":3,"title":"Per-tenant extension","slug":"per-tenant-extension","at":59,"chars":895},{"level":3,"title":"Hybrid approach","slug":"hybrid-approach","at":954,"chars":370},{"level":3,"title":"Co-development","slug":"co-development","at":1324,"chars":710},{"level":2,"title":"Useful hints for co-development","slug":"useful-hints-for-co-development","at":2034,"chars":4412},{"level":3,"title":"Registering the Shopify app","slug":"registering-the-shopify-app","at":2069,"chars":2344},{"level":3,"title":"Adjusting the Shopify Connector for co-development","slug":"adjusting-the-shopify-connector-for-co-development","at":4413,"chars":1614},{"level":3,"title":"Known issues with authentication","slug":"known-issues-with-authentication","at":6027,"chars":419},{"level":4,"title":"Error: Oauth error invalid_request: The redirect_uri is not whitelisted.","slug":"error-oauth-error-invalid_request-the-redirect_uri-is-not-whitelisted","at":6064,"chars":184},{"level":4,"title":"Error: cannot install app","slug":"error-cannot-install-app","at":6248,"chars":198},{"level":2,"title":"Extensibility examples","slug":"extensibility-examples","at":6446,"chars":24509},{"level":3,"title":"Application manifest","slug":"application-manifest","at":6523,"chars":580},{"level":3,"title":"Order processing","slug":"order-processing","at":7103,"chars":9057},{"level":4,"title":"Populate fields on an imported Shopify order","slug":"populate-fields-on-an-imported-shopify-order","at":7484,"chars":1543},{"level":4,"title":"Verify that a Shopify order is ready to become a sales document","slug":"verify-that-a-shopify-order-is-ready-to-become-a-sales-document","at":9027,"chars":698},{"level":4,"title":"Add information to a sales document that's based on a Shopify order","slug":"add-information-to-a-sales-document-thats-based-on-a-shopify-order","at":9725,"chars":676},{"level":4,"title":"Change the VAT Business Posting Group based on the country of the order","slug":"change-the-vat-business-posting-group-based-on-the-country-of-the-order","at":10401,"chars":1432},{"level":4,"title":"Add information to a sales document line that's based on a Shopify order","slug":"add-information-to-a-sales-document-line-thats-based-on-a-shopify-order","at":11833,"chars":2024},{"level":4,"title":"Show information from a Shopify order on a sales document","slug":"show-information-from-a-shopify-order-on-a-sales-document","at":13857,"chars":851},{"level":4,"title":"Show related information on a sales document","slug":"show-related-information-on-a-sales-document","at":14708,"chars":533},{"level":4,"title":"Show information from a Shopify order line on a sales document line","slug":"show-information-from-a-shopify-order-line-on-a-sales-document-line","at":15241,"chars":919},{"level":3,"title":"Stock calculation","slug":"stock-calculation","at":16160,"chars":5249},{"level":4,"title":"Calculate on-hand stock","slug":"calculate-on-hand-stock","at":16948,"chars":660},{"level":4,"title":"Calculate on-hand stock reduced by reserved stock","slug":"calculate-on-hand-stock-reduced-by-reserved-stock","at":17608,"chars":801},{"level":4,"title":"Calculate the projected available balance on a specific date","slug":"calculate-the-projected-available-balance-on-a-specific-date","at":18409,"chars":1380},{"level":4,"title":"Calculate the quantity available to pick for locations","slug":"calculate-the-quantity-available-to-pick-for-locations","at":19789,"chars":1620},{"level":3,"title":"Price management","slug":"price-management","at":21409,"chars":2512},{"level":4,"title":"Implement logic to define prices","slug":"implement-logic-to-define-prices","at":21886,"chars":1128},{"level":4,"title":"Implement logic to define compare-at prices","slug":"implement-logic-to-define-compare-at-prices","at":23014,"chars":907},{"level":3,"title":"Product properties","slug":"product-properties","at":23921,"chars":5961},{"level":4,"title":"Use a manufacturer instead of a vendor when you export items","slug":"use-a-manufacturer-instead-of-a-vendor-when-you-export-items","at":24369,"chars":761},{"level":4,"title":"Tag exported items","slug":"tag-exported-items","at":25130,"chars":816},{"level":4,"title":"Map imported products to existing items","slug":"map-imported-products-to-existing-items","at":25946,"chars":1267},{"level":4,"title":"Process imported product metafields","slug":"process-imported-product-metafields","at":27213,"chars":1175},{"level":4,"title":"Modify created Item or Item Variant description","slug":"modify-created-item-or-item-variant-description","at":28388,"chars":1494},{"level":3,"title":"Customer properties","slug":"customer-properties","at":29882,"chars":1073},{"level":4,"title":"Adjust created customer based on information received from Shopify","slug":"adjust-created-customer-based-on-information-received-from-shopify","at":30122,"chars":833},{"level":2,"title":"Related information","slug":"related-information","at":30955,"chars":173}],"text":"# Extend the Shopify Connector\n## Extensibility approaches\n### Per-tenant extension\nPer-tenant extensions use classic extensibility. Extensions subscribe to exposed events and other artifacts and adjust existing flows. The benefit of this approach is that you can develop in a cloud sandbox. The restriction is that you can't modify API calls. For example, to add new nodes or call different Shopify APIs. Because the connector depends on the Shopify API and its release cycle, the number of exposed events in the connector is noticeably less than in other Microsoft code. There have been cases where a redesign was needed to uptake the new ways to do things on Shopify that would cause multiple breaking changes for per-tenant extensions. If you discovered missing integration events or public function or have other extensibility enhancement, you can contribute via BCApps<https://github.com/microsoft/BCApps/tree/main/src/Apps/W1/Shopify> repository.\n### Hybrid approach\nIn addition to classic extensibility, you can also create a separate branch of code that interacts directly with the Shopify API. This approach offers more flexibility, but it has higher requirements because you must register your own unlisted Shopify app and implement your own communication logic. You can also use a cloud sandbox for development.\n### Co-development\nIf you're missing functionality you need, instead of building a per-tenant extension or onboarding to the hybrid approach, you can contribute code to the Shopify Connector through a co-development process. Co-development ensures that you don't need to maintain proprietary code and can use out of the box functionality. Co-development requires acceptance from the engineering team from both the use case and architectural perspectives. Also worth mentioning is that shipping new features, including those built by our community, is usually tied to major releases. You can find code and contribute via the BCApps<https://github.com/microsoft/BCApps/tree/main/src/Apps/W1/Shopify> repository.\n## Useful hints for co-development\n### Registering the Shopify app\nBegin by joining the Shopify Partner Program<https://help.shopify.com/partners/about>. Afterward, use the Partner Dashboard to create the development store and app.\nThe following are the main steps. For specific details, refer to the Shopify documentation.\n1. In the Shopify Partner Dashboard, go to Apps > All apps, and choose the Create app button.\n2. Choose the Create app manually button.\n3. Enter the App name, and choose Create.\n4. In the Overview section of the app, note the Client credentials, Client ID, and Client secret. You'll use this information to access the Shopify API.\n5. In the Configuration section, enter a valid URL in the App URL field.\n6. Fill in the Allowed redirection URL(s) field using the following formats:`<Server>[:port]/<ServerInstance>/OauthLanding.htm` (for example, `https://bc-shopify.westeurope.cloudapp.azure.com/BC/OauthLanding.htm` or `https://localhost:48900/BC/OAuthLanding.htm`).\n The exact value depends on the configuration of your development environment. You can see what your development environment returns by calling the https://learn.microsoft.com/dynamics365/business-central/application/system-application/codeunit/system.security.authentication.oauth2#getdefaultredirecturl method of the OAuth2 system module. Also, make sure that this URL is reachable. If you use a container sandbox development environment, consider using the deployment template from aka.ms/getbc<https://aka.ms/getbc>, where you can enable the Let's Encrypt SSL certificate to ensure that Business Central is accessible in the container.\n7. For co-development, because the Shopify Connector reads all orders, and not only orders from the last 60 days, you must request access for your app. Go to API access, and choose the Request access button in Read all order scopes. The process requires review, which might take some time, so plan in advance. See https://shopify.dev/docs/api/usage/access-scopes#orders-permissions. You'll receive an email from Shopify when access is granted. You can also check the API access section of the Shopify Partner dashboard. You'll see the following message, \"Your app can access the full order history for a store\".\nWhile in the Shopify partner admin, consider creating a development store for testing. See /shopify/shopify-account#development-store.\n### Adjusting the Shopify Connector for co-development\ncodeunit 30199 \"Shpfy Authentication Mgt.\", path: Apps/W1/Shopify/app/src/Integration/Codeunits/ShpfyAuthenticationMgt.Codeunit.al\nModify GetClientId and GetClientSecret to return Shopify client credentials because your app doesn't have access to Azure Key Vault. Use the Client ID and Client secret from your registered Shopify app<#registering-the-shopify-app>.\n```al\n    [Scope('OnPrem')]\n    local procedure GetClientId(): SecretText\n    var\n        ...\n    begin\n        exit(SecretText.SecretStrSubstNo(‘add Client ID here’));  //ADD THIS LINE\n        ...\n    end;\n\n    [Scope('OnPrem')]\n    local procedure GetClientSecret(): SecretText\n    var\n        ...\n    begin\n        exit(SecretText.SecretStrSubstNo(‘Add Client secret here’)); //ADD THIS LINE\n\n        ...\n    end;\n```\nIf access to read all orders isn't available yet, temporarily replace read_all_orders in ScopeTxt with read_orders. After access is granted, reintroduce read_all_orders.\n```al\ncodeunit 30199 \"Shpfy Authentication Mgt.\"\n{\n    Access = Internal;\n    var\n        // https://shopify.dev/api/usage/access-scopes\n        // ScopeTxt: Label 'write_orders,read_all_orders,read_orders...  //replace this line with line below\n        ScopeTxt: Label 'write_orders,read_orders,...\n\n```\nNow you can publish the updated connector and connect Business Central to the Shopify online store. See /shopify/get-started#connect-business-central-to-the-shopify-online-store.\n> IMPORTANT\n> Don't commit these changes in the public repo. If you did, rotate the Shopify client secrets of your app.\n### Known issues with authentication\n#### Error: Oauth error invalid_request: The redirect_uri is not whitelisted.\nMake sure that you filled in the Allowed redirection URL(s) field correctly in the Configuration section.\n#### Error: cannot install app\nIn the Overview section of the app, choose the Select Store action. First install the app from there, then try to connect Business Central to the Shopify store again.\n## Extensibility examples\nBelow you can find various extensibility examples.\n### Application manifest\nIf you're building a per-tenant extension or plan to use the hybrid approach, you must list the Shopify Connector as a dependency in the app.json file. Remember to use the correct version number.\n```json\n{\n  \"id\": \"a74041b2-f9d2-4899-b4bd-58388a10f169\",\n  \"name\": \"ExtendShopify\",\n  \"publisher\": \"Default Publisher\",\n  \"version\": \"1.0.0.0\",\n  \"dependencies\": [\n    {\n      \"id\":  \"ec255f57-31d0-4ca2-b751-f2fa7c745abb\",\n      \"name\":  \"Shopify Connector\",\n      \"publisher\":  \"Microsoft\",\n      \"version\": \"25.0.0.0\"\n    }\n  ],\n```\nSee devenv-json-files.\n### Order processing\nVarious factors affect how businesses process sales orders, for example:\n The type of products or services\n The sales channels\n Policies and procedures for shipping and handling\nYou can subscribe to various events from the Shpfy Order Events codeunit.\nLearn more about synchronizing orders in Synchronize and fulfill sales orders</shopify/synchronize-orders>.\n#### Populate fields on an imported Shopify order\nThe following example shows how to populate fields on an order that you imported from Shopify. For example, select a customer based on the sales channel.\n```al\ncodeunit 50113 \"Shpfy Order Set Customer\"\n{\n    [EventSubscriber(ObjectType::Codeunit, Codeunit::\"Shpfy Order Events\", OnAfterImportShopifyOrderHeader, '', false, false)]\n    procedure OnAfterImportShopifyOrderHeader(var ShopifyOrderHeader: Record \"Shpfy Order Header\", IsNew: Boolean)\n    var\n        ShopifyShop: Record \"Shpfy Shop\";\n    begin\n        if ShopifyOrderHeader.\"Channel Name\" = 'Point of Sale' then begin\n            ShopifyShop.Get(ShopifyOrderHeader.\"Shop Code\");\n            ShopifyShop.TestField(\"POS Customer No.\");\n            ShopifyOrderHeader.\"Bill-to Customer No.\" := ShopifyShop.\"POS Customer No.\";\n            ShopifyOrderHeader.\"Sell-to Customer No.\" := ShopifyShop.\"POS Customer No.\";\n            ShopifyOrderHeader.Modify();\n        end;\n    end;\n}\ntableextension 50100 \"Shpfy Shop Ext\" extends \"Shpfy Shop\"\n{\n    fields\n    {\n        field(50100; \"POS Customer No.\"; Code[20])\n        {\n            TableRelation = Customer;\n            DataClassification = CustomerContent;\n        }\n    }\n}\npageextension 50102 \"Shpfy Shop Ext\" extends \"Shpfy Shop Card\"\n{\n    layout\n    {\n        addafter(DefaultCustomer)\n        {\n            field(\"POS Customer No.\"; Rec.\"POS Customer No.\")\n            {\n                ApplicationArea = All;\n                Visible = true;\n            }\n        }\n    }\n}\n```\n#### Verify that a Shopify order is ready to become a sales document\nThe following example shows how to check whether a Shopify order is ready to be converted to a sales document, and you want to make it mandatory to specify a payment method.\n```al\ncodeunit 50107 \"Shpfy Order Check Pay. Method\"\n{\n    [EventSubscriber(ObjectType::Codeunit, Codeunit::\"Shpfy Order Events\", OnBeforeCreateSalesHeader, '', false, false)]\n    internal procedure OnBeforeCreateSalesHeader(ShopifyOrderHeader: Record \"Shpfy Order Header\"; var SalesHeader: Record \"Sales Header\"; var LastCreatedDocumentId: Guid; var Handled: Boolean)\n    begin\n        ShopifyOrderHeader.Testfield(\"Payment Method Code\");\n    end;\n}\n```\n#### Add information to a sales document that's based on a Shopify order\nYou can add more information to a sales document that's based on a Shopify order. For example, you can add the Shopify order number as an external document number.\n```al\ncodeunit 50112 \"Shpfy Order External Doc. No\"\n{\n\n    [EventSubscriber(ObjectType::Codeunit, Codeunit::\"Shpfy Order Events\", OnAfterCreateSalesHeader, '', false, false)]\n    procedure OnAfterCreateSalesHeader(ShopifyHeader: Record \"Shpfy Order Header\"; var SalesHeader: Record \"Sales Header\")\n    begin\n        SalesHeader.\"External Document No.\" := ShopifyHeader.\"Shopify Order No.\";\n        SalesHeader.Modify(true);\n    end;\n}\n```\n#### Change the VAT Business Posting Group based on the country of the order\nThe following example shows how to change the VAT Business Posting Group based on the country of the order. For example, if the order is from an EU country, you can set the VAT Business Posting Group to 'EU'. This can be useful if you need to apply different VAT group compared the default one set on the Customer.\n```al\ncodeunit 50103 \"Shpfy Change VAT Group\"\n{\n    [EventSubscriber(ObjectType::Codeunit, Codeunit::\"Shpfy Order Events\", OnAfterCreateSalesHeader, '', false, false)]\n    local procedure ChangeVATPostingGroup(OrderHeader: Record \"Shpfy Order Header\"; var SalesHeader: Record \"Sales Header\")\n    var\n        CountryRegion: Record \"Country/Region\";\n        CompanyInfo: Record \"Company Information\";\n    begin\n        if OrderHeader.\"Bill-to Country/Region Code\" = '' then\n            exit;\n\n        CompanyInfo.Get();\n        if OrderHeader.\"Bill-to Country/Region Code\" = CompanyInfo.\"Country/Region Code\" then\n            SalesHeader.\"VAT Bus. Posting Group\" := 'DOMESTIC'\n        else begin\n            CountryRegion.Get(OrderHeader.\"Bill-to Country/Region Code\");\n            if CountryRegion.\"EU Country/Region Code\" <> '' then\n                SalesHeader.\"VAT Bus. Posting Group\" := 'EU'\n            else\n                SalesHeader.\"VAT Bus. Posting Group\" := 'EXPORT';\n        end;\n\n        SalesHeader.Modify(true);\n    end;\n}\n```\n#### Add information to a sales document line that's based on a Shopify order\nThe following example shows how to add dimensions to a sales document line that's based on a Shopify order.\n```al\ncodeunit 50111 \"Shpfy Order Line Dim\"\n{\n    [EventSubscriber(ObjectType::Codeunit, Codeunit::\"Shpfy Order Events\", OnAfterCreateItemSalesLine, '', false, false)]\n\n    procedure OnAfterCreateItemSalesLine(ShopifyOrderHeader: Record \"Shpfy Order Header\"; ShopifyOrderLine: Record \"Shpfy Order Line\"; SalesHeader: Record \"Sales Header\"; var SalesLine: Record \"Sales Line\")\n    var\n        DimMgt: Codeunit DimensionManagement;\n        TempDimSetEntry: Record \"Dimension Set Entry\" temporary;\n        DimensionValue: Record \"Dimension Value\";\n    begin\n        FindShpfyDimension(ShopifyOrderHeader.\"Channel Name\", DimensionValue);\n\n        DimMgt.GetDimensionSet(TempDimSetEntry, SalesLine.\"Dimension Set ID\");\n        TempDimSetEntry.Init();\n        TempDimSetEntry.\"Dimension Set ID\" := SalesLine.\"Dimension Set ID\";\n        TempDimSetEntry.Validate(\"Dimension Code\", DimensionValue.\"Dimension Code\");\n        TempDimSetEntry.Validate(\"Dimension Value Code\", DimensionValue.Code);\n        if not TempDimSetEntry.Insert() then\n            TempDimSetEntry.Modify();\n        SalesLine.Validate(\"Dimension Set ID\", DimMgt.GetDimensionSetID(TempDimSetEntry));\n        SalesLine.Modify(true);\n    end;\n\n    local procedure FindShpfyDimension(SourceName: Code[20]; var DimensionValue: Record \"Dimension Value\")\n    var\n        Dimension: Record Dimension;\n    begin\n        If not Dimension.Get('SHOPIFY') then begin\n            Dimension.Init();\n            Dimension.Code := 'SHOPIFY';\n            Dimension.Insert(true);\n        end;\n        if not DimensionValue.Get(Dimension.Code, SourceName) then begin\n            DimensionValue.Init();\n            DimensionValue.Validate(\"Dimension Code\", Dimension.Code);\n            DimensionValue.Validate(Code, SourceName);\n            DimensionValue.Insert(true);\n        end;\n    end;\n}\n```\n#### Show information from a Shopify order on a sales document\nThe following example shows how to include information from a Shopify order on a sales document. For example, the sales channel.\n```al\ntableextension 50101 \"Shpfy Sales Header Extend\" extends \"Sales Header\"\n{\n    fields\n    {\n        field(50100; \"Channel Name\"; Text[100])\n        {\n            CalcFormula = lookup(\"Shpfy Order Header\".\"Channel Name\" WHERE(\"Shopify Order Id\" = FIELD(\"Shpfy Order Id\")));\n            FieldClass = FlowField;\n            Editable = false;\n        }\n    }\n}\npageextension 50100 \"Shpfy SI Extend\" extends \"Sales Invoice\"\n{\n    layout\n    {\n        addafter(ShpfyOrderNo)\n        {\n            field(\"Channel Name\"; Rec.\"Channel Name\")\n            {\n                ApplicationArea = All;\n                Visible = true;\n            }\n        }\n    }\n}\n```\n#### Show related information on a sales document\nThe following example shows how to include related information, for example tags, in a sales document.\n```al\npageextension 50103 \"Shpfy SO Extend\" extends \"Sales Order\"\n{\n    layout\n    {\n        addafter(IncomingDocAttachFactBox)\n        {\n            part(OrderTags; \"Shpfy Tag Factbox\")\n            {\n                ApplicationArea = All;\n                SubPageLink = \"Parent Table No.\" = const(30118), \"Parent Id\" = field(\"Shpfy Order Id\");\n            }\n        }\n    }\n}\n```\n#### Show information from a Shopify order line on a sales document line\nThe following example shows how to include information from a Shopify order line in a sales document line. For example, a description of an item variant.\n```al\ntableextension 50102 \"Shpfy Sales Line Extend\" extends \"Sales Line\"\n{\n    fields\n    {\n        field(50102; \"Variant Description\"; Text[50])\n        {\n            CalcFormula = lookup(\"Shpfy Order Line\".\"Variant Description\" WHERE(\"Line Id\" = FIELD(\"Shpfy Order Line Id\")));\n            FieldClass = FlowField;\n            Editable = false;\n        }\n    }\n}\npageextension 50101 \"Shpfy Sales Line Extend\" extends \"Sales Order Subform\"\n{\n    layout\n    {\n        addafter(\"Variant Code\")\n        {\n            field(\"Variant Description\"; Rec.\"Variant Description\")\n            {\n                ApplicationArea = All;\n                Visible = true;\n            }\n        }\n    }\n}\n```\n### Stock calculation\nCompanies have different rules on how and what items to expose to Shopify as available stock.\nYou can extend the Shpfy Stock Calculation enum by adding your own options. Each enum value must map both interfaces. The Shpfy Stock Calculation interface calculates the quantity, and the Shpfy IStock Available interface determines whether the connector can export that quantity. Map Shpfy IStock Available to `Shpfy Can Have Stock` when the calculation permits inventory export. If the mapping is missing or its implementation returns false, the connector can calculate and store the stock value without sending an inventory update to Shopify.\nTo learn more about standard inventory calculation, go to Synchronize inventory with Shopify</shopify/synchronize-inventory>.\n#### Calculate on-hand stock\nThe following example shows how to calculate stock on hand.\n```al\nenumextension 50101 \"Extended Stock Calculations\" extends \"Shpfy Stock Calculation\"\n{\n  value(50101; \"Inventory on hand\")\n    {\n        Caption = 'Inventory on hand';\n        Implementation = \"Shpfy Stock Calculation\" = \"Shpfy Stock Calc. Inventory\",\n                         \"Shpfy IStock Available\" = \"Shpfy Can Have Stock\";\n    }\n}\ncodeunit 50101 \"Shpfy Stock Calc. Inventory\" implements \"Shpfy Stock Calculation\"\n{\n    procedure GetStock(var Item: Record Item): decimal\n    begin\n        Item.Calcfields(Inventory);\n        exit(Item.Inventory);\n    end;\n}\n```\n#### Calculate on-hand stock reduced by reserved stock\nThe following example shows how to calculate stock on hand reduced by reserved stock.\n```al\nenumextension 50102 \"Extended Stock Calculations\" extends \"Shpfy Stock Calculation\"\n{\n    value(50102; \"Non-reserved Inventory\")\n    {\n        Caption = 'Free Inventory (not reserved)';\n        Implementation = \"Shpfy Stock Calculation\" = \"Shpfy Stock Calc. Free Invent\",\n                         \"Shpfy IStock Available\" = \"Shpfy Can Have Stock\";\n    }\n}\ncodeunit 50102 \"Shpfy Stock Calc. Free Invent\" implements \"Shpfy Stock Calculation\"\n{\n    procedure GetStock(var Item: Record Item): decimal\n    begin\n        Item.Calcfields(Inventory, \"Reserved Qty. on Inventory\");\n        exit(Item.Inventory - Item.\"Reserved Qty. on Inventory\");\n    end;\n}\n```\n#### Calculate the projected available balance on a specific date\nThe following example shows how to calculate the balance that's expected to be available on a specific date in the future.\n```al\nenumextension 50103 \"Extended Stock Calculations\" extends \"Shpfy Stock Calculation\"\n{\n    value(50103; \"Projected Available Balance in X Days\")\n    {\n        Caption = 'Projected Available Balance in X Days';\n        Implementation = \"Shpfy Stock Calculation\" = \"Shpfy Stock Calc. Proj at Date\",\n                         \"Shpfy IStock Available\" = \"Shpfy Can Have Stock\";\n    }\n}\ncodeunit 50103 \"Shpfy Stock Calc. Proj at Date\" implements \"Shpfy Stock Calculation\"\n{\n    procedure GetStock(var Item: Record Item): decimal\n    var\n        CompanyInfo: Record \"Company Information\";\n        ItemAvailabilityFormsMgt: codeunit \"Item Availability Forms Mgt\";\n        GrossRequirement, PlannedOrderRcpt, ScheduledRcpt, PlannedOrderReleases, ProjAvailableBalance, ExpectedInventory, QtyAvailable : decimal;\n    begin\n        CompanyInfo.Get();\n        Item.SetRange(\"Date Filter\", 0D, CalcDate(CompanyInfo.\"Check-Avail. Period Calc.\", Today()));\n        ItemAvailabilityFormsMgt.CalcAvailQuantities(Item, true, GrossRequirement, PlannedOrderRcpt, ScheduledRcpt, PlannedOrderReleases, ProjAvailableBalance, ExpectedInventory, QtyAvailable);\n        exit(ProjAvailableBalance);\n    end;\n}\n```\n#### Calculate the quantity available to pick for locations\nThe following example shows how to calculate the quantity that's available and can be picked for locations that require warehouse handling.\n```al\nenumextension 50104 \"Extended Stock Calculations\" extends \"Shpfy Stock Calculation\"\n{\n    value(50104; \"Available to Pick\")\n    {\n        Caption = 'Available to pick (warehouse handling)';\n        Implementation = \"Shpfy Stock Calculation\" = \"Shpfy Stock Calc. AvailPick\",\n                         \"Shpfy IStock Available\" = \"Shpfy Can Have Stock\";\n    }\n}\ncodeunit 50104 \"Shpfy Stock Calc. AvailPick\" implements \"Shpfy Stock Calculation\"\n{\n    procedure GetStock(var Item: Record Item): decimal\n    var\n        Location: Record Location;\n        TempWhseWorksheetLine: Record \"Whse. Worksheet Line\" temporary;\n        WhseMgt: Codeunit \"Whse. Management\";\n        AvailableQty: Decimal;\n    begin\n        TempWhseWorksheetLine.Init();\n        TempWhseWorksheetLine.\"Item No.\" := Item.\"No.\";\n        TempWhseWorksheetLine.\"Variant Code\" := Item.\"Variant Filter\";\n        TempWhseWorksheetLine.\"Unit of Measure Code\" := Item.\"Base Unit of Measure\";\n        TempWhseWorksheetLine.\"Qty. per Unit of Measure\" := 1;\n        TempWhseWorksheetLine.\"Due Date\" := WorkDate();\n        Item.CopyFilter(\"Location Filter\", Location.Code);\n        if Location.FindSet() then\n            repeat\n                TempWhseWorksheetLine.\"Location Code\" := Location.\"Code\";\n                AvailableQty += TempWhseWorksheetLine.CalcAvailableQtyBase();\n            until Location.Next() = 0;\n        Exit(AvailableQty)\n    end;\n}\n```\n### Price management\nPrice management is an important aspect of e-commerce because it can impact the profitability and competitiveness of a business. There's no one-size-fits-all approach because companies prioritize different factors and have different strategies for reaching their target audience.\nYou can subscribe to various events from the Shpfy Product Events codeunit.\nLearn more about standard price calculation in /shopify/synchronize-items#sync-prices-with-shopify.\n#### Implement logic to define prices\nThe following example shows how to implement logic for defining prices.\n```al\ncodeunit 50105 \"Shpfy Custom Price\"\n{\n    [EventSubscriber(ObjectType::Codeunit, Codeunit::\"Shpfy Product Events\", OnBeforeCalculateUnitPrice, '', false, false)]\n    procedure BeforeCalculateUnitPrice(Item: Record Item; VariantCode: Code[20]; UnitOfMeasure: Code[20]; ShopifyShop: Record \"Shpfy Shop\"; Catalog: Record \"Shpfy Catalog\"; var UnitCost: Decimal; var Price: Decimal; var ComparePrice: Decimal; var Handled: Boolean)\n    var\n        CurrExchRate: Record \"Currency Exchange Rate\";\n        ItemUOM: Record \"Item Unit of Measure\";\n    begin\n        Price := CurrExchRate.ExchangeAmtLCYToFCY(\n                        WorkDate(),\n                        ShopifyShop.\"Currency Code\",\n                        Item.\"Unit Price\",\n                        CurrExchRate.ExchangeRate(WorkDate(), ShopifyShop.\"Currency Code\"));\n\n        if (UnitOfMeasure <> '') and ItemUOM.Get(Item.\"No.\", UnitOfMeasure) then\n            Price := Price * ItemUOM.\"Qty. per Unit of Measure\";\n\n        Handled := true;\n    end;\n}\n```\n#### Implement logic to define compare-at prices\nWhen you're selling an item at a discounted price, you can include the original price, or the price a customer might have paid elsewhere to give them something to compare the discount with. This price is often referred to as a compare-at price.\nThe following example shows how to implement logic for defining compare-at prices.\n```al\ncodeunit 50110 \"Shpfy Custom Compare Price\"\n{\n    [EventSubscriber(ObjectType::Codeunit, Codeunit::\"Shpfy Product Events\", OnAfterCalculateUnitPrice, '', false, false)]\n    procedure AfterCalculateUnitPrice(Item: Record Item; VariantCode: Code[20]; UnitOfMeasure: Code[20]; ShopifyShop: Record \"Shpfy Shop\"; Catalog: Record \"Shpfy Catalog\"; var UnitCost: Decimal; var Price: Decimal; var ComparePrice: Decimal)\n    begin\n        ComparePrice := Round(Price * 1.3, 1);\n        Price := Round(Price, 1) - 0.05;\n    end;\n}\n```\n### Product properties\nProduct descriptions and specifications help customers understand what they're buying, so they can make informed purchasing decisions. This information should be clear, concise, easy to understand, and include all relevant details.\nStarting with version 22, you can subscribe to various events from the Shpfy Product Events codeunit.\nLearn more about exporting products in /shopify/synchronize-items#export-items-to-shopify.\n#### Use a manufacturer instead of a vendor when you export items\nThe following example shows how to use a manufacturer instead of a vendor when you export items.\n```al\ncodeunit 50106 \"Shpfy Product Export Manuf\"\n{\n    [EventSubscriber(ObjectType::Codeunit, Codeunit::\"Shpfy Product Events\", OnAfterFillInShopifyProductFields, '', false, false)]\n    procedure OnAfterFillInShopifyProductFields(Item: Record Item; var ShopifyProduct: Record \"Shpfy Product\")\n    var\n        Manufacturer: Record Manufacturer;\n    begin\n        if Manufacturer.Get(Item.\"Manufacturer Code\") then begin\n            ShopifyProduct.Vendor := Manufacturer.Name;\n            if not ShopifyProduct.IsTemporary() then\n                ShopifyProduct.Modify();\n        end;\n    end;\n}\n```\n#### Tag exported items\nThe following example shows how to tag exported items. Tags categorize products on your online store and organize search results for customers.\n```al\ncodeunit 50109 \"Shpfy Product Export Tag\"\n{\n    [EventSubscriber(ObjectType::Codeunit, Codeunit::\"Shpfy Product Events\", OnAfterCreateTempShopifyProduct, '', false, false)]\n    procedure AfterCreateTempShopifyProduct(Item: Record Item; var ShopifyProduct: Record \"Shpfy Product\"; var ShopifyVariant: Record \"Shpfy Variant\"; var ShopifyTag: Record \"Shpfy Tag\")\n    begin\n        ShopifyTag.\"Parent Table No.\" := Database::\"Shpfy Product\";\n        ShopifyTag.\"Parent Id\" := ShopifyProduct.Id;\n        ShopifyTag.Tag := Format(Item.\"Replenishment System\");\n        if not ShopifyTag.Insert() then\n            ShopifyTag.Modify();\n    end;\n}\n```\n#### Map imported products to existing items\nThe following example shows how to use the GTIN field to map imported products to existing items. If it makes sense for your implementation, you can also use other fields for the mapping. For example, a field that your extension adds.\n```al\ncodeunit 50108 \"Shpfy Product Import Mapping\"\n{\n    [EventSubscriber(ObjectType::Codeunit, Codeunit::\"Shpfy Product Events\", OnBeforeFindProductMapping, '', false, false)]\n    procedure BeforeFindMapping(Direction: Enum \"Shpfy Mapping Direction\"; var ShopifyProduct: Record \"Shpfy Product\"; var ShopifyVariant: Record \"Shpfy Variant\"; var Item: Record Item; ItemVariant: Record \"Item Variant\"; var Handled: Boolean)\n    var\n        FindItem: Record Item;\n    begin\n        if (Direction = Direction::ShopifyToBC) and (not Handled) and (not ShopifyProduct.\"Has Variants\") then\n            if IsNullGuid(ShopifyProduct.\"Item SystemId\") and (ShopifyVariant.SKU <> '') then begin\n                Clear(Item);\n                Clear(ItemVariant);\n                FindItem.SetRange(GTIN, ShopifyVariant.SKU);\n                If FindItem.FindFirst() then begin\n                    Item := FindItem;\n                    Handled := true;\n                end;\n            end;\n    end;\n}\n```\n#### Process imported product metafields\nThe following example shows how to handle product metafields. Metafields are a flexible way to add and store additional information about a Shopify resource, such as a product or variant.\n```al\ncodeunit 50110 \"Shpfy Product Metafields\"\n{\n    [EventSubscriber(ObjectType::Codeunit, Codeunit::\"Shpfy Product Events\", OnAfterCreateItem, '', false, false)]\n    procedure CreateSubstitutesOnAfterCreateItem(var Item: Record Item; var ShopifyProduct: Record \"Shpfy Product\")\n    var\n        Metafield: Record \"Shpfy Metafield\";\n        ItemSubstitution: Record \"Item Substitution\";\n    begin\n        Metafield.SetRange(\"Owner Type\", Metafield.\"Owner Type\"::Product);\n        Metafield.SetRange(\"Owner ID\", ShopifyProduct.Id);\n        Metafield.SetRange(Name,'substitute');\n        if Metafield.FindFirst() then begin\n            ItemSubstitution.Init();\n            ItemSubstitution.\"No.\" := Item.\"No.\";\n            ItemSubstitution.\"Substitute Type\" := ItemSubstitution.\"Substitute Type\"::Item;\n            ItemSubstitution.Validate(\"Substitute No.\",Metafield.Value);\n            ItemSubstitution.Insert(true);\n        end;\n    end;\n}\n```\n#### Modify created Item or Item Variant description\nThe following example shows how to modify the description of an item or item variant that you created based on information received from Shopify. For example, you can build a name based on item and variant information.\n```al\ncodeunit 50100 \"Shpfy Custom Item Desc.\"\n{\n\n    [EventSubscriber(ObjectType::Codeunit, Codeunit::\"Shpfy Product Events\", OnAfterCreateItemVariant, '', false, false)]\n    local procedure ModifyItemVariantDescription(Shop: Record \"Shpfy Shop\"; ShopifyProduct: Record \"Shpfy Product\"; var ShopifyVariant: Record \"Shpfy Variant\"; Item: Record Item; var ItemVariant: Record \"Item Variant\");\n    begin\n        // Build name based on Item and Variant info\n        ItemVariant.Description := CopyStr(Item.Description + ' - ' + ShopifyVariant.\"Display Name\", 1, MaxStrLen(ItemVariant.Description));\n        ItemVariant.Modify(true);\n    end;\n\n    [EventSubscriber(ObjectType::Codeunit, Codeunit::\"Shpfy Product Events\", OnAfterCreateItem, '', false, false)]\n    local procedure ModifyItemDescription(Shop: Record \"Shpfy Shop\"; var ShopifyProduct: Record \"Shpfy Product\"; ShopifyVariant: Record \"Shpfy Variant\"; var Item: Record Item);\n    begin\n        Item.Description := CopyStr(ShopifyVariant.\"Display Name\", 1, MaxStrLen(Item.Description));\n        Item.\"Description 2\" := CopyStr(ShopifyVariant.\"Display Name\", MaxStrLen(Item.Description) + 1, MaxStrLen(Item.\"Description 2\"));\n        Item.Modify(true);\n    end;\n}\n```\n### Customer properties\nCustomer information is essential for businesses to understand their customers, provide better service, and build long-term relationships. You can subscribe to various events from the Shpfy Customer Events codeunit.\n#### Adjust created customer based on information received from Shopify\nThe following example shows how to adjust a created customer based on information received from Shopify. For example, you can remove all non-numeric characters from the phone number.\n```al\ncodeunit 50101 \"Shpfy Custom Customer Info\"\n{\n    [EventSubscriber(ObjectType::Codeunit, Codeunit::\"Shpfy Customer Events\", OnAfterCreateCustomer, '', false, false)]\n    local procedure ModifyCustomerPhoneNo(Shop: Record \"Shpfy Shop\"; var ShopifyCustomerAddress: Record \"Shpfy Customer Address\"; var Customer: Record Customer);\n    begin\n        // Remove all non-numeric characters from the phone number\n        Customer.\"Phone No.\" := DelChr(Customer.\"Phone No.\", '=', DelChr(Customer.\"Phone No.\", '=', '1234567890/+.()'));\n        Customer.Modify(true);\n    end;\n}\n```\n## Related information\ndevenv-extensibility-overview\nShopify</shopify/get-started>\nShopify FAQ<https://aka.ms/bcshopifyfaq>\n/shopify/walkthrough-setting-up-and-using-shopify"}