Categorias: Todos - price - discount - rules - validation

por Liang Yufeng 2 anos atrás

104

Bundle App

The app in question is designed to manage cart bundling and linking for e-commerce stores, specifically addressing issues related to price validation and variant management. The app needs to ensure that item prices passed from the frontend are verified through the Shopify API to prevent inaccuracies in creating draft orders.

Bundle App

Bundle App

https://www.figma.com/file/lcAiv9quIJybAT09WtMD42/Cart-Bundling%2FLinking?node-id=751%3A330



https://secretlabsg.slack.com/files/U02BXMH4T1P/F03BBBPEA9Y/image_from_ios.jpg




problem:


  1. price validation, the item price passed from frontend cannot be trusted to create a draft order. Might need to take the price from shopify api.
  2. for variant needed to be auto removal if main product is gone, where to indicate that? does this variant need to be removed from a single rule or all the rules?

V3 UI

Add/Edit
sku list

price_overwrite

to overwrite the original price,

if set to 0 means this is free

should_remove_exceeded

if the quantity in cart exceed the max quantity, should remove the exceeded quantity?



auto_add

is_main

value

max quantity

min quantity

variant_id

id

this id is sku list item id, not present in UI.

the primary key is also used for multiple same sku item do sales like buy 1 get the same 1 free or buy 1 get the same one at 50% discount.

quantity

maximum

minimum

stackable

does this bundle rule can be stack with other bundle rules?



not on sales price

priority

0:highest

-

10: lowest

validity

end_time

start_time

discount

amount

type

has_discount

bundle type

limited

customer optional to add sub product

mandatory

n+m

auto add sub product

has main product

optional

> 2 skus

bundle name
List
update rules to all stores if same name existed
copy bundle rules to other store

check for existence

selectable

store selection
Add new

V3 Api

Create/Update draft order

Checkout cart


Method:Post

logic

validation

no draft order id

create draft order

https://shopify.dev/api/admin-rest/2021-10/resources/draftorder#post-draft-orders


- use line item discount

has draft order id

update draft order

return error

checkout url

draft order id

nullable

Validation

has_bundle: boolean

does the cart object fit into any bundle rule?


cart_items: array

skus and its discount amount


error: array

skus needs to be removed

skus needs to be added




{

"has_bundle": true,

"cart_items": [

{

"sku": "2022",

"discounted_amount":0,

},

{

"sku": "2022",

"discounted_amount":10,

},

{

"sku": "2022",

"discounted_amount":10,

}

],

"error":[

{

"sku": "2022",

"add":1,

"deduct":0,

"message":""

]

]

Recommended bundles

Cart Page


Method:Post

the response is same as product page, it is just giving more rules by multiple skus

cart object

Shopify Cart Object

bundle list

Product Page


Method:Get

response

rule 1:

[

  {

   "bundle_name":"A",

   "bundle_type":"1",

   "priority":1,

   "stackable":false,

   "has_discount":true,

   "discount_type":"value",

   "discount_value":20.00,

   "minimum_quantity":3,

   "maximum_quantity":0,

   "variants":[

     {

      "id":1,

      "variant_id":100,

      "sku":"2022",

      "minimum_quantity":1,

      "maximum_quanity":1,

      "is_main":false,

      "auto_add":false,

      "has_discount":false,

      "discount_type":null,

      "discount_value":null

     },

     {

      "id":2,

      "variant_id":101,

      "sku":"wiper",

      "minimum_quantity":1,

      "maximum_quanity":0,

      "is_main":false,

      "auto_add":false,

      "has_discount":false,

      "discount_type":null,

      "discount_value":null

     }

   ]

  }

]


---------------------------------------

rule 2:

[

  {

   "bundle_name":"A",

   "bundle_type":"2",

   "priority":1,

   "stackable":false,

   "has_discount":"ture",

   "discount_type":"value",

   "discount_value":20.00,

   "minimum_quantity":3,

   "maximum_quantity":0,

   "variants":[

     {

      "id":1,

      "variant_id":100,

      "sku":"2022",

      "minimum_quantity":1,

      "maximum_quanity":1,

      "is_main":true,

      "auto_add":false,

      "has_discount":false,

      "discount_type":null,

      "discount_value":null

     },

     {

      "id":2,

      "variant_id":101,

      "sku":"wiper",

      "minimum_quantity":1,

      "maximum_quanity":1,

      "is_main":false,

      "auto_add":true,

      "has_discount":false,

      "discount_type":null,

      "discount_value":null

     }

   ]

  }

]


---------------------------------------

rule 3:

[

  {

   "bundle_name":"A",

   "bundle_type":"3",

   "priority":1,

   "stackable":false,

   "has_discount":"ture",

   "discount_type":"percentage",

   "discount_value":10,

   "minimum_quantity":3,

   "maximum_quantity":3,

   "variants":[

     {

      "id":1,

      "variant_id":100,

      "sku":"2022",

      "minimum_quantity":1,

      "maximum_quanity":1,

      "is_main":true,

      "auto_add":false,

      "has_discount":false,

      "discount_type":null,

      "discount_value":null

     },

     {

      "id":2,

      "variant_id":101,

      "sku":"dry-wiper",

      "minimum_quantity":0,

      "maximum_quanity":2,

      "is_main":false,

      "auto_add":false,

      "has_discount":false,

      "discount_type":null,

      "discount_value":null

     },

     {

      "id":3,

      "variant_id":102,

      "sku":"wet-wiper",

      "minimum_quantity":0,

      "maximum_quanity":2,

      "is_main":false,

      "auto_add":false,

      "has_discount":false,

      "discount_type":null,

      "discount_value":null

     }

   ]

  }

]


params

sku