Hello. I am reading the documentation on Storefront API and I'm incredibly confused. I want to apply a discount with a dynamic amount based on the items in my cart. How do I do this? Can I do this without creating a fixed code in shopify admin? Because then the customers can reuse the code.
Please give me an in-depth explanation. I have created a custom app to do this for me and it works, but I found out later that I cannot use shopify extensions on custom distribution, and can only use public distribution for it to work.
Creating a dynamic discount based on the items in a cart on Shopify requires using various APIs and scripting methods. These can include:
The Product Discount Function API allows developers to create a new type of discount that can be applied to specific products or product variants in the cart. This can include offering discounts on certain items based on the quantity purchased or applying discounts to particular products or product variants.
Custom Apps with the Admin API - For more complex and dynamic discounting schemes, creating a custom app and leveraging the Admin API might be a viable option. Through this method, you can monitor the cart's contents and calculate discounts accordingly. However, the discounts would have to be predefined in the Shopify Admin as discount codes or automatic discounts, but the custom app can determine when and how these discounts are applied based on the cart's contents.