Discussing APIs and development related to customers, discounts, and order management.
Inserting new companies using the InsertCompany mutation - absolutely fine.
Updating existing company records with existing location records - an absolute mess! Did the update team responsible look at what the inset did and think 'simplicity, ease of use - that's not for us'?
When creating a new company, you can create it with a default location, which works perfectly. I will assume that most (not all) companies needing B2B will want a company with a single location and your API has reflected this requirement.
The problems arise when attempting to update that default location!
Thanks
Hi James,
Thanks for describing your experience with making updates via the API when there's multiple existing companies, I'm in touch with the product team that owns this space and I've communicated the issues you're seeing around efficiency and consistency. I will update here with their response.
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hi James,
Our team are curious what is the use case that requires you to create a company with a default location, and then update the location. You can specify the location details in the CompanyCreate mutation and it should create everything in one shot.
The product team wondering if this workflow might work for you: Instead of updating, create a new companyLocation with companyLocationCreate and delete the existing one with companyLocationsDelete?
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Liam, many thanks for the reply. To provide some background we provide integration with ERP systems (Sage and Acumatica though the scenario could apply to Dynamics, or any other ERP).
If we are passing up 'company' records to Shopify, the likely source will be Customers in the ERP, and most likely we would to create:
1. Company Record
2. Location
3. Customer
This would be a 1:1:1 relationship - The CreateCompany mutation allows us to create the Company, Default Location Contact, etc.
As an aside there is value with having multiple locations to a single company (but we need to do the same dance).
Obviously the customer has it's own address (an artifact of pre-Company/B2B times), but the Location has its own Billing and Shipping.
If there is a change in the address in the ERP (particularly billing) we want to be able to update the address really on both the customer, but also the Location to keep things in sync (and this is where it becomes difficult). The Billing and Shipping addresses (to the best of our knowledge) each require separate API requests.
If we need to update a contact record, we need to send another API request. If the Tax Registration is added (rarely changed) yet another request.
Yes you could do companyLocationsDelete and companyLocationCreate but you then need to reassociate a customer with the companyContactAssignRole so they can place an order. What happens if the customer is ordering and you make this change (a likely race condition)?