B2B/Wholesale Quantity Break Public API for Shopify Stores
Quantity break public API is an feature of B2B/Wholesale Solution shopify app. To use APIs, you must install app, upgrade to Platinum plan and get the access key.
These APIs are REST APIs. You can use them to manage quantity break rules, calculate variants' price based on rules, search customers, get products, etc. Detailed instructions on how to do it is showing bellow:
How to get the access key
After you install B2B/Wholesale Solution Shopify app. Go to Public API page, click on the Copy button.
Rule endpoints
There are fields of rule, you need to understand:
- priority: decides whether a rule is prioritized over another or not.
- status:
0: inactive 1: active
- apply_to:
0: All customers 1: Logged-in customers 2: Not-logged-in customers 3: Specific customers 4: Customer tags
- product_condition_type:
0: All products 1: Specific products 2: Product collections 3: Product tags
- rule_setting:
0: Quantity break 1: Amount break
Note:
When request get rules by domain or ID, the rule_setting field will appear at the response to inform you whether your rule is Quantity Break or Amount Break.
However, when send request Create/Update rule the rule_setting will be Quantity Break by default as we haven't support create/update Amount Break as of date.
- qty_table: Quantity settings of rule
+ rule_type:
0: Minimum Product Qty 1: Minimum Order Qty 2: Minimum Variant Qty
- Minimum Product Qty: If one order contains the selected products and the number of each product meets the quantity break ranges, the price of the product will be discounted accordingly. For example: You choose products A and B to apply the quantity break rule. A has two variants: A1, A2. B also has two variants B1, B2. The order quantity break ranges are from 0 to 5 (discounted 10%) and from 6 to 10 (discount 15%) That time, if the customer buys 3 A1, 6 A2 and 4 B1. The total quantity of A is 9 so the price of A will be discounted by 15%. The price of B, however, will be discounted by 10%. If the quantity of the order/product(s)/variant(s) is not within the ranges, the original prices are applied. - Minimum Order Qty: If one order contains the selected products and the total number of those products meets the quantity break ranges, they will be discounted accordingly. For example: You choose products A and B to apply the quantity break rule. A has two variants: A1, A2. B also has two variants B1, B2. The order quantity break ranges are from 0 to 5 (discounted 10%) and from 6 to 10 (discount 15%) and from 11 to 20 (discount 20%) That time, if the customer buys 3 A1, 6 A2 and 4 B1. The total quantity of A and B is 13, meaning that the prices of A and B will be discounted by 20%. If the quantity of the order/product(s)/variant(s) is not within the ranges, the original prices are applied. - Minimum Variant Qty : If one order contains the selected products and the number of variants meets the quantity break ranges, the price of those variants will be discounted accordingly. For example: You choose products A and B to apply the quantity break rule. A has two variants: A1, A2. B also has two variants B1, B2. The order quantity break ranges are from 0 to 5 (discounted 10%) and from 6 to 10 (discount 15%) and from 11 to 20 (discount 20%) That time, if the customer buys 3 A1, 6 A2 and 4 B1. Then, the prices of A1 and B1 will be discounted by 10% and that of A2 will be discounted by 15%. If the quantity of the order/product(s)/variant(s) is not within the ranges, the original prices are applied.
+ qty_from: The order quantity break ranges are from qty_from to qty_to
+ qty_to: The order quantity break ranges are from qty_from to qty_to
+ discount_type:
0: Apply a price to selected products 1: Decrease a fixed amount of the original prices of selected products 2: Decrease the original prices of selected products by a percentage (%)
Get Rules by Domain
Request URL: https://b2b-solution-public-api.bsscommerce.com/api/v1/qb/get-by-domain
Method: POST
Content-type: application/json
Request body:
domain: your default Shopify store domain. accessKey: value of access key.
{ "domain": "abc.myshopify.com", "accessKey": "xxx" }
Response body:
{ "success": true, "rules": [ { "id": 46, "shop_id": 231, "name": "firsts", "priority": 0, "rule_type": 1, "status": 1, "apply_to": 0, "customer_ids": [], "customer_tags": [], "product_condition_type": 0, "product_ids": [], "product_collections": [], "product_tags": [], "createdAt": "2021-09-16T06:50:04.000Z", "updatedAt": "2021-09-16T06:50:04.000Z", "qbRuleQtyTables": [ { "id": 39, "rule_id": 46, "qty_from": 1, "qty_to": 1, "discount_type": 0, "discount_value": 0, "createdAt": "2021-09-16T06:50:05.000Z", "updatedAt": "2021-09-16T06:50:05.000Z" } ] } ] }
Get Rule by ID
Request URL: https://b2b-solution-public-api.bsscommerce.com/api/v1/qb/get-by-id
Method: POST
Content-type: application/json
Request body:
{ "domain": "abc.myshopify.com", "accessKey": "xxx", "id": 46 }
Response body:
{ "success": true, "rule": { "id": 46, "name": "firsts", "priority": 0, "status": 1, "apply_to": 0, "product_condition_type": 0, "customer_ids": [], "customer_tags": [], "product_ids": [], "product_collections": [], "product_tags": [], "rule_setting": 0, "rule_type": 1, "qty_table": [ { "id": 39, "rule_id": 46, "qty_from": 1, "qty_to": 1, "discount_type": 0, "discount_value": 0, "createdAt": "2021-09-16T06:50:05.000Z", "updatedAt": "2021-09-16T06:50:05.000Z" } ], "createdAt": "2021-09-16T06:50:04.000Z", "updatedAt": "2021-09-16T06:50:04.000Z" } }
Create or Update Single Rule
Request URL: https://b2b-solution-public-api.bsscommerce.com/api/v1/qb/save
Method: POST
Content-type: application/json
Request body:
If there is no ID in request data, a new rule will be created. Otherwise, existing rule with ID will be updated.
{ "domain":"abc.myshopify.com", "accessKey": "xxx", "rule": { "id": 66, "name": "first", "priority": 0, "status": 1, "apply_to": 0, "product_condition_type": 0, "customer_ids": [], "customer_tags": [], "product_ids": [], "product_collections": [], "product_tags": [], "rule_type": 2, "qty_table": [ { "qty_from": 1, "qty_to": 3, "discount_type": 0, "discount_value": 10 }, { "qty_from": 6, "qty_to": 7, "discount_type": 1, "discount_value": 10 } ] } }
Response body
{ "success": true, "message": "Update the rule successfully", "ruleId": 66 }
Create or Update Multiple Rules
Request URL: https://b2b-solution-public-api.bsscommerce.com/api/v1/qb/bulk-save
Method: POST
Content-type: application/json
Request body:
If there is no ID in request data, a new rule will be created. Otherwise, existing rule with ID will be updated.
{ "domain": "abc.myshopify.com", "accessKey": "xxx", "rules": [ { "id": 71, "name": "sencond1", "priority": 0, "status": 1, "apply_to": 0, "product_condition_type": 0, "customer_ids": [], "customer_tags": [], "product_ids": [], "product_collections": [], "product_tags": [], "rule_type": 2, "qty_table": [ { "qty_from": 1, "qty_to": 4, "discount_type": 0, "discount_value": 10 }, { "qty_from": 6, "qty_to": 8, "discount_type": 1, "discount_value": 10 } ] }, { "id": 72, "name": "sencond2", "priority": 0, "status": 1, "apply_to": 0, "product_condition_type": 0, "customer_ids": [], "customer_tags": [], "product_ids": [], "product_collections": [], "product_tags": [], "rule_type": 2, "qty_table": [ { "qty_from": 1, "qty_to": 4, "discount_type": 0, "discount_value": 10 }, { "qty_from": 6, "qty_to": 8, "discount_type": 1, "discount_value": 11 } ] } ] }
Response Body:
{ "success": true, "message": [ "Update rule with ID 71 successfully", "Update rule with ID 72 successfully" ] }
Delete Rule
Request URL: https://b2b-solution-public-api.bsscommerce.com/api/v1/qb/delete
Method: POST
Content-type: application/json
Request body:
{ "domain": "abc.myshopify.com", "accessKey": "xxx", "id": 71 }
Response body:
{ "success": true, "message": "Deleted rule successfully" }
Delete Mulitple Rule
Request URL: https://b2b-solution-public-api.bsscommerce.com/api/v1/qb/mass-delete
Method: POST
Content-type: application/json
Request body:
{ "domain": "abc.myshopify.com", "accessKey": "xxx", "ids": [67,68,69] }
Response body:
{ "success": true, "message": "Deleted multiple qb rule successfully" }
Get Applied Rules for Products
Request URL: https://b2b-solution-public-api.bsscommerce.com/api/v1/qb/get-products-applied-rules
Method: POST
Content-type: application/json
Request body:
If customer_id is null, the system will check Quantity Break Rules which applied for all customers or not-logged-in customers.
{ "domain": "abc.myshopify.com", "accessKey": "xxxx", "product_ids": [ 6103930831040,6103930929344], "customer_id": 5110452355264 }
Response body:
{ "success": true, "productsAppliedRule": [ { "id": "6103930831040", "rule_name": "first", "rule_id": 51, "qty_table": [ { "id": 47, "qty_from": 1, "qty_to": 3, "discount_type": 0, "discount_value": 10, "createdAt": "2021-09-16T08:41:14.000Z", "updatedAt": "2021-09-16T08:41:14.000Z" }, { "id": 48, "qty_from": 6, "qty_to": 7, "discount_type": 1, "discount_value": 10, "createdAt": "2021-09-16T08:41:14.000Z", "updatedAt": "2021-09-16T08:41:14.000Z" } ] }, { "id": "6103930929344", "rule_name": "first", "rule_id": 51, "qty_table": [ { "id": 47, "qty_from": 1, "qty_to": 3, "discount_type": 0, "discount_value": 10, "createdAt": "2021-09-16T08:41:14.000Z", "updatedAt": "2021-09-16T08:41:14.000Z" }, { "id": 48, "qty_from": 6, "qty_to": 7, "discount_type": 1, "discount_value": 10, "createdAt": "2021-09-16T08:41:14.000Z", "updatedAt": "2021-09-16T08:41:14.000Z" } ] } ] }
Get Price List of Variants based on Applied Rules
Request URL: https://b2b-solution-public-api.bsscommerce.com/api/v1/qb/get-variants-price-list
Method: POST
Content-type: application/json
Request body:
If customer_id is null, the system will check Quantity Break Rules which applied for all customers or not-logged-in customers.
{ "domain": "abc.myshopify.com", "accessKey": "xxx", "product_ids": [ 6103930831040, 6103930929344 ], "customer_id": 5110452355264 }
Response body:
{ "success": true, "priceList": [ { "id": "6103930831040", "rule_name": "first", "rule_id": 52, "variants": [ { "id": "37682508955840", "price": "36.00", "compareAtPrice": null, "appliedRulePrice": [ { "qty_from": 6, "qty_to": 7, "discount_type": 1, "discount_value": 10, "modifiedPrice": 90 }, { "qty_from": 1, "qty_to": 3, "discount_type": 0, "discount_value": 10, "modifiedPrice": 10 } ] } ] }, { "id": "6103930929344", "rule_name": "first", "rule_id": 52, "variants": [ { "id": "37682509086912", "price": "100.00", "compareAtPrice": "80.00", "appliedRulePrice": [ { "qty_from": 6, "qty_to": 7, "discount_type": 1, "discount_value": 10, "modifiedPrice": 90 }, { "qty_from": 1, "qty_to": 3, "discount_type": 0, "discount_value": 10, "modifiedPrice": 10 } ] }, { "id": "37682509119680", "price": "100.00", "compareAtPrice": null, "appliedRulePrice": [ { "qty_from": 6, "qty_to": 7, "discount_type": 1, "discount_value": 10, "modifiedPrice": 90 }, { "qty_from": 1, "qty_to": 3, "discount_type": 0, "discount_value": 10, "modifiedPrice": 10 } ] }, { "id": "37682509152448", "price": "100.00", "compareAtPrice": null, "appliedRulePrice": [ { "qty_from": 6, "qty_to": 7, "discount_type": 1, "discount_value": 10, "modifiedPrice": 90 }, { "qty_from": 1, "qty_to": 3, "discount_type": 0, "discount_value": 10, "modifiedPrice": 10 } ] }, { "id": "37682509185216", "price": "100.00", "compareAtPrice": null, "appliedRulePrice": [ { "qty_from": 6, "qty_to": 7, "discount_type": 1, "discount_value": 10, "modifiedPrice": 90 }, { "qty_from": 1, "qty_to": 3, "discount_type": 0, "discount_value": 10, "modifiedPrice": 10 } ] } ] } ] }
Product endpoints
Search products
Request URL: https://b2b-solution-public-api.bsscommerce.com/api/v1/product/search
Method: POST
Content-type: application/json
Request body:
Index is a cursor value, where you want to start searching. If afterIndex is null, the system will search products from the beginning. For example:
afterIndex: "eyJsYXN0X2lkIjo2NjU1NDU2Mzc5MDUzLCJsYXN0X3ZhbHVlIjo2NjU1NDU2Mzc5MDUzfQ=="
{ "domain": "abc.myshopify.com", "accessKey": "xxx", "afterIndex": null, "first": 20, "searchQuery": "ocean" }
Response body:
{ "success":true, "productList":{ "edges":[ { "node":{ "id":"gid://shopify/Product/6586580271277", "title":"Ocean Blue Shirt", "handle":"ocean-blue-shirt", "productType":"", "totalVariants":1, "hasOnlyDefaultVariant":true, "priceRange":{ "minVariantPrice":{ "currencyCode":"VND", "amount":"50.0" }, "maxVariantPrice":{ "currencyCode":"VND", "amount":"50.0" } }, "featuredImage":{ "transformedSrc":"https://cdn.shopify.com/s/files/1/0538/3874/1677/products/young-man-in-bright-fashion_925x_5251bcfa-6939-4d7a-9287-dd9bf058ed03.jpg?v=1616405807" }, "onlineStoreUrl":null }, "cursor":"eyJsYXN0X2lkIjo2NTg2NTgwMjcxMjc3LCJsYXN0X3ZhbHVlIjo2NTg2NTgwMjcxMjc3fQ==" }, { "node":{ "id":"gid://shopify/Product/6655456379053", "title":"Riri Bracelet", "handle":"riri-bracelet-rose", "productType":"women's bracelets", "totalVariants":1, "hasOnlyDefaultVariant":false, "priceRange":{ "minVariantPrice":{ "currencyCode":"VND", "amount":"68.0" }, "maxVariantPrice":{ "currencyCode":"VND", "amount":"68.0" } }, "featuredImage":{ "transformedSrc":"https://cdn.shopify.com/s/files/1/0538/3874/1677/products/2015-04-20_Accessories_31_23500_21376.jpg?v=1619597977" }, "onlineStoreUrl":null }, "cursor":"eyJsYXN0X2lkIjo2NjU1NDU2Mzc5MDUzLCJsYXN0X3ZhbHVlIjo2NjU1NDU2Mzc5MDUzfQ==" } ], "pageInfo":{ "hasNextPage":false, "hasPreviousPage":false } } }
Get Product Tags
Request URL: https://b2b-solution-public-api.bsscommerce.com/api/v1/product/get-tags
Method: POST
Content-type: application/json
Request body:
{ "domain": "abc.myshopify.com", "accessKey": "xxx" }
Response body:
{ "success":true, "productTags":{ "tags":[ "cotton blouse", "Couch", "cowl", "cpace", "Crane", "cream", "crepe wool", "crew", "crew neck", "crewneck", "crisp" ], "last_cursor":"Y3Jpc3A=" } }
Get Products by Tags
Request URL: https://b2b-solution-public-api.bsscommerce.com/api/v1/product/get-by-tags
Method: POST
Content-type: application/json
Request body:
{ "domain": "abc.myshopify.com", "accessKey": "xxx", "afterIndex": null, "first": 20, "tags": ["tag1","tags2","tags3"], "operation": "AND" }
"Operation" is "AND" or "OR". If you use "AND", returned products must contain all tags. If you use "OR", returned products just need to belong one tag in array (["tag1","tags2","tags3"]).
Response body:
{ "success":true, "productList":[ { "id":"gid://shopify/Product/6586590625965", "title":"Anchor Bracelet Mens", "handle":"leather-anchor", "productType":"Bracelet", "totalVariants":2, "hasOnlyDefaultVariant":false, "priceRange":{ "minVariantPrice":{ "currencyCode":"VND", "amount":"55.0" }, "maxVariantPrice":{ "currencyCode":"VND", "amount":"70.0" } }, "featuredImage":{ "transformedSrc":"https://cdn.shopify.com/s/files/1/0538/3874/1677/products/anchor-bracelet-mens_925x_8dcf313c-5c78-41ea-874d-59804d449315.jpg?v=1616407017" }, "onlineStoreUrl":null } ] }
Get Products by IDs
Request URL: https://b2b-solution-public-api.bsscommerce.com/api/v1/product/get-by-ids Method: POST Content-type: application/json Request body:
{ "domain": "abc.myshopify.com", "accessKey": "xxx", "ids": [ 6586590625965 ] }
Response body:
{ "success":true, "productList":[ { "id":"gid://shopify/Product/6586590625965", "title":"Anchor Bracelet Mens", "handle":"leather-anchor", "productType":"Bracelet", "totalVariants":2, "hasOnlyDefaultVariant":false, "priceRange":{ "minVariantPrice":{ "currencyCode":"VND", "amount":"55.0" }, "maxVariantPrice":{ "currencyCode":"VND", "amount":"70.0" } }, "featuredImage":{ "transformedSrc":"https://cdn.shopify.com/s/files/1/0538/3874/1677/products/anchor-bracelet-mens_925x_8dcf313c-5c78-41ea-874d-59804d449315.jpg?v=1616407017" }, "onlineStoreUrl":null } ] }
Customer endpoints
Get Customer Tags
Request URL: https://b2b-solution-public-api.bsscommerce.com/api/v1/customer/get-tags
Method: POST
Content-type: application/json
Request body:
{ "domain": "abc.myshopify.com", "accessKey": "xxx" }
Response body
{ "success":true, "customerTags":[ { "node":"wholesale", "cursor":"d2hvbGVzYWxl" } ] }
Get Customers by IDs
Request URL: https://b2b-solution-public-api.bsscommerce.com/api/v1/customer/get-by-ids
Method: POST
Content-type: application/json
Request body:
{ "domain": "abc.myshopify.com", "accessKey": "xxx", "ids": [5127974846637] }
Response body
{ "success":true, "customerList":[ { "id":"gid://shopify/Customer/5127974846637", "displayName":"nta", "email":"abc@gmail.com", "firstName":"n", "lastName":"ta" } ] }
Search Customers
Request URL: https://b2b-solution-public-api.bsscommerce.com/api/v1/customer/search
Method: POST
Content-type: application/json
Request body:
{ "domain": "abc.myshopify.com", "accessKey": "xxx", "afterIndex": null, "first": 20, "searchQuery": "nta" }
Response body
{ "success":true, "customers":[ { "node":{ "id":"gid://shopify/Customer/5127974846637", "displayName":"nta", "email":"abc@gmail.com", "firstName":"n", "lastName":"ta", "phone":null, "tags":[ "wholesale" ], "note":"" }, "cursor":"eyJsYXN0X2lkIjo1MTI3OTc0ODQ2NjM3LCJsYXN0X3ZhbHVlIjo1MTI3OTc0ODQ2NjM3fQ==" } ] }
Get Customers by Tags
Request URL: https://b2b-solution-public-api.bsscommerce.com/api/v1/customer/get-by-tags
Method: POST
Content-type: application/json
Request body:
{ "domain": "abc.myshopify.com", "accessKey": "xxx", "afterIndex": null, "first": 20, "tags": ["tag1","tags2","tags3"], "operation": "AND" }
"Operation" is "AND" or "OR". If you use "AND", returned products must contain all tags. If you use "OR", returned products just need to belong one tag in array (["tag1","tags2","tags3"]).
Response body
{ "success":true, "customers":[ { "node":{ "id":"gid://shopify/Customer/5127974846637", "displayName":"nta", "email":"abc@gmail.com", "firstName":"n", "lastName":"ta", "phone":null, "tags":[ "wholesale" ], "note":"" }, "cursor":"eyJsYXN0X2lkIjo1MTI3OTc0ODQ2NjM3LCJsYXN0X3ZhbHVlIjo1MTI3OTc0ODQ2NjM3fQ==" } ] }
Collection endpoints
Get Collections
Request URL: https://b2b-solution-public-api.bsscommerce.com/api/v1/collection/get-list
Method: POST
Content-type: application/json
Request body:
{ "domain": "abc.myshopify.com", "accessKey": "xxx" }
Response body
{ "success":true, "collections":[ { "id":"gid://shopify/Collection/244026966189", "image":null, "title":"Home page", "handle":"frontpage" } ] }