Shopify / js-buy-sdk

The JS Buy SDK is a lightweight library that allows you to build ecommerce into any website. It is based on Shopify's API and provides the ability to retrieve products and collections from your shop, add products to a cart, and checkout.
https://shopify.github.io/js-buy-sdk
MIT License
993 stars 263 forks source link

Checkout LineItem: Allow us to update prices through lineItem #587

Closed naiduasn closed 5 years ago

naiduasn commented 6 years ago

Is your feature request related to a problem? Please describe. I am building an app for which i have to modify the prices of line items based on quantities. For E.G: if user purchase 6 items, one price and user purchases 12 items another price. But unfortunately, checkout lineitem in js-buy sdk allows me to pass only variant ID and quantity due to which i will not be able to customize the prices of items.

Describe the solution you'd like Allow us to customize line item attributes while creating checkout

Describe alternatives you've considered I am not sure how should i approach this now.

Additional context Any suggestion would be of great help

StefanSlehta commented 6 years ago

Have you considered discounts for this? You can create a discounts that can't be stacked, require a certain amount of items, you can discount a fixed amount or a percentage..

naiduasn commented 6 years ago

@StefanSlehta Thanks for reply. The major problem i see with discounts is when the user adds multiple items where if I have at least two products which need discounts to be applied, Shopify will allow only 1 discount to be applied, which kind of defeats the purpose. Again, i cannot apply fixed amount / percentage for these scenarios.

ckaminski99 commented 6 years ago

@naiduasn I am about to start working with the shopify sdk and was just perusing their issues and saw this one that I may have a potential work around for you.

Could you possibly add different variants for each product based on the quantity range's and pick the specific variant ID based on the quantity? Each variant should be able to have it's own price (I think). On the UI you would not want to show these variants to the end users, so you would need some way to suppress them somehow.

Just a thought, hopefully it helps, and let me know either way please as I may need to utilize this kind of logic down the road as well.

Thanks, Chris

naiduasn commented 6 years ago

Hi Chris, I am using js-buy-sdk with react native application. I solved it in a different way. I was calculating all the discounts I should apply at cart level and dynamically creating a discount code with final discount amount using price rule API.

cons: 1) i will not able to provide user to add any other coupons available. 2) i will not be able to show user at checkout page how much each lineitem is costing after discount. 3) Storefront API will not support this and hence have to use REST Admin API.

Reference: https://help.shopify.com/en/api/reference/discounts/pricerule

rebeccajfriedman commented 5 years ago

@naiduasn You could also use automatic discounts: https://help.shopify.com/en/manual/promoting-marketing/discount-codes/automatic-discounts#create-an-automatic-buy-x-get-y-discount

0xHexE commented 3 years ago

Hi @rebeccajfriedman There is still one problem. If we want to create multiple promotions from different vendors, Its not possible to apply all at once.