For E-commerce Success
Integrating B2B pricing from SAP ERP system into existing Shopify store.
B2B business face challenges with Shopify's B2C-focused platform and its limitations as a SaaS application. Specifically, B2B store owners struggle to integrate their ERP pricing seamlessly into the Shopify checkout process.
Team Integriti devised a multi-step solution using custom development and Shopify’s app development features.
Retail buyers log into Shopify and navigate through the website, where prices are displayed with a disclaimer indicating possible changes at checkout.
Customers add items to their cart, and upon checkout, an API is invoked to simulate prices.
This API revises item prices, tax rates, and shipping charges as needed, and can also add or remove goods from the cart.
The client requested the creation of custom fields for “Sold to Number” and “Ship to Number,” a disclaimer about potential price changes at checkout, and changes to the checkout process to call a custom API with specific inputs and outputs.
Stores list prices for each SKU in the cart
Calls the API to retrieve ERP prices
Updates the tax rate based on the API response
Modifies the cart according to the API response
Overrides the shipping amount as per the API response
Sets the prices back to list prices
If a customer adds an item listed at $23.00, the checkout process will update the price to $20.00 based on the SAP price, with shipping at $5.00 and a 10% tax rate, while the list price remains unchanged.
Our team leveraged the Node boilerplate provided by Shopify to gain in-depth understanding of its structure and database framework.
Maintaining application security through proper authentication was a significant challenge. We addressed this by implementing Shopify Auth, strictly following Shopify’s developer guidelines for secure authentication. (Link: https://shopify.dev/docs/apps/auth)
Managing session tokens for secure API calls to Shopify Admin APIs was another major hurdle.
Used when the application needs resources without immediate user presence.
Used when a user is actively using the application.
Solution 1: Webhook Integration
Utilized webhooks and data manipulation for B2B pricing at checkout.
Triggered by Shopify webhook “CHECKOUT CREATE” to initiate checkout attempts.
Data captured included customer and cart information for processing.
Products were transformed to meet SAP API requirements.
Customer ID used to retrieve shipping and billing details via Shopify APIs
Aggregated data into JSON object, converted to XML format for SAP.
Error handling redirected users to standard checkout in case of SAP issues.
Outcome
This solution technically achieved B2B pricing at checkout, but the client later opted for a different approach due to:
Lack of price consistency for all customers.
Lack of dynamic B2B pricing, specific to each customer without affecting store-wide prices.
Solution 2: Draft Order Integration
Similar to Solution 1 but utilized draft orders for pricing updates.
Webhook triggered on “CHECKOUT CREATE” to initiate checkout.
Customer and cart data processed for pricing updates.
Aggregated and converted data to XML format for SAP.
Upon SAP response, draft orders created with updated prices.
Customers received draft order URL for purchase completion.
Outcome
While this solution addressed the client’s immediate requirement, they later reconsidered due to Shopify Webhook Delays, especially under high customer traffic.
Solution 3: Frontend Price Change
Explored alternative methods due to Shopify webhook delays.
Leveraged App proxy and theme-app-extension for pricing updates.
Non-registered customers proceed through standard checkout.
Registered users’ default address verified for completeness.
Customer data obtained via theme-app-extension for SAP interaction.
Upon SAP response, draft orders created with updated prices.
Draft order checkout URL sent to frontend for purchase completion.
Outcome
This solution addressed the challenges of webhooks and fulfilled the client’s requirements, making it the accepted solution.
Initially deployed on both Heroku and Fly.io for environment understanding. Eventually, opted for exclusive hosting on Heroku for the final deployment.
Default SQLite database in Shopify Node app boilerplate lacks persistence. Addressed by migrating to PostgreSQL for robust data management.
Explored alternative methods due to Shopify webhook delays.
Leveraged App proxy and theme-app-extension for pricing updates.
Non-registered customers proceed through standard checkout.
Registered users’ default address verified for completeness.
Customer data obtained via theme-app-extension for SAP interaction.
Upon SAP response, draft orders created with updated prices.
Draft order checkout URL sent to frontend for purchase completion.