webMethods

webMethods

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only

Custom operations with Shopify connector in IBM webMethods Integration 

Mon March 31, 2025 05:14 AM

Summary :

IBM webMethods Integration provides predefined Shopify connector to create custom operations , in this tutorial we will see how to connect and create custom operations in Shopify by implementing a retail usecase which involves POS(point of sale) while integrating with Shopify online store.

UseCase Description : 

Shopify POS(Point of Sale) is a system that allows merchants to sell products in-person while syncing sales, inventory, and customer data with their Shopify online store. In our usecase we are going update our POS system by applying discount on seasonal Drinks in the store.

Diagram 

Technical Flow 

Pre-Requisites 

Content 

  •   Connect to shopify to get the products from Inventory (with Label as SeasonedDrinks)
  •   Apply discount (%) on each SeasonedDrink item
  •   Verify in Shopify to see discount applied to relevant products

Steps 

Create an app in shopify by following the doc : https://help.shopify.com/en/manual/apps/app-types/custom-apps , grab the Storefront API access token which will be used while executing the flows. 

Setup Inventory in Shopify.

Option1 : Manual

Log in to Shopify Admin: Go to Shopify and log in.

Navigate to Products: Click on "Products" in the left-hand menu.

  • Add Product: Click the "Add product" button.

  • Fill in Product Details:

    • Title: Enter the product name.

    • Description: Write a detailed product description.

    • Images: Upload product images.

    • Price: Set the selling price and compare-at price (if applicable).

    • Inventory: Choose SKU, barcode, and stock quantity.

    • Variants: Add different sizes, colors, etc.

    • Shipping: Set weight, customs info (if needed), and fulfillment options.

  • Save the Product: Click "Save" to publish

Option2: API

If you need automation, Shopify’s Product API allows developers to create products programmatically. refer to https://shopify.dev/docs/api/admin-graphql

Get Seasonal Drinks from Shopify

1) Connect to Shopify using pre-defined connector

• Create a new project or select existing project in webMethods.io tenant
• Go to Connectors → Predefined

From Available connectors, select - Shopify4 connector

Click on shopify connector and configure account

Provide URL and shopify key and Save.

2. Get Seasonal Products from Shopify using custom implementation 

i. Get all products from shopify using below API call 

        curl -X GET "https://your-store.myshopify.com/admin/api/2024-01/products.json" \
           -H "X-Shopify-Access-Token: YOUR_ACCESS_TOKEN"

        URL : https://%shopifyStore%/admin/api/2024-01/products.json

         Access token : <shopify access token>

 ii . Use the below logic inside your package to get the seasonal drinks from shopify store. (package attached )

3.  Apply Discount on SeasonalDrinkItems 

3.1 Create a price Rule

To apply a discount programmatically, you can use Shopify's Price Rule API or Discount API.

Now create one flow service and select Shopify connection (which we already created) to access the operations available at Shopify side.

1. Click on Add Custom Operation

2. For Connect to Shopify – select the connection we created earlier, click Next

3. Select the operation you want to perform

4. On next screen, you will be able to find the price rule object which you want to access.

5. Once you select the object, all the fields corresponding to the selected object should start appearing for selection, leave the fields selected by default (see below picture) and select entitled_product_ids field.

6. Once you select the fields, click on next and the screen shown below should appear with all the details, like the number of fields selected.

7. Once you click done, the custom operation is created and ready for use in the flowservices/workflow

8. create header document with input variables as and name it as "headersDoc"  and supply inputs to priceRule object.

Content-Type: application/json
X-Shopify-Access-Token: YOUR_ACCESS_TOKEN

Sample Input for PriceRule  : 

{
  "price_rule": {
    "title": "SUMMER SALE",
    "target_type": "line_item",
    "target_selection": "entitled",
    "allocation_method": "across",
    "value_type": "percentage",
    "value": "-20.0",
    "customer_selection": "all",
    "once_per_customer": false,
    "usage_limit": null,
    "starts_at": "2025-03-24T00:00:00Z",
    "entitled_product_ids": <product id number>
  }
}

9. From flowservice you can click on Run and it will create priceRule in shopify.

3.2 Apply discount on selected SeasonalDrink Items

      Create a new flow service with a custom operation named "createDiscountCode" by clicking on custom operation

Select the operation as "Create Discount Code" click next and say done.

Now open mapping of flowservice and map price rule id to PriceRuleId in parameters and generate a random code (For eg . SAVE20 ) and map it to code.

Run the flowservice it should apply discount on entitled product discount code will be applied to product which can be used during the checkout.

Note : Kindly note that each product should have unique code according to api specification .(Handled in the attached package)

4. Verify in Shopify 

  • Log in to Shopify Admin: Shopify Admin
  • Go to Discounts:
    • In the left sidebar, click on "Discounts".
  • Search for the Discount Code:
    • Use the search bar to find your discount (e.g., "SUMMER20").
  • Check Discount Details:
    • Ensure the discount is active.

Resources 

https://help.shopify.com/en

https://shopify.dev/docs/api

Statistics
0 Favorited
17 Views
1 Files
0 Shares
3 Downloads
Attachment(s)
zip file
ShopifyDrinkItems.zip   139 KB   1 version
Uploaded - Mon March 31, 2025
IS package