We are a Insurance Company and are building a Shopify app, that adds a Insurance product to all the CARTS of the merchant who installs our Shopify APP (which is not public yet) .
The problem is we insure the product as a Percentage of the Cart Value , so a 100$ cart will add 2$ insurance , which a 200$ will add 4$ insurance. We have added a Fixed insurance product with 0.01$ but we are not able to change its price . We can change quantity, but we don;t want to , as cart number goes crazy , if the some insures a high value item, our product quantity shows 100,200,450, etc big numbers and to customer it looks lot of products are added, while only 1 product is added.
We are using Shopify Ajax API
but not able to update the Product price.
Any help would be greately appreciated.
Been thinking about this one for a while - it sure is an interesting challenge and valid requirement.
Unfortunately, no matter how you slice it, I don't think you will be able to implement this with your current requirements and most definetely not using the AJAX API.
To begin with, the AJAX API is a simple wrapper allowing you to programmatically interact with a cart and predating the JS Buy SDK or Storefront API. However, what you want to do is add items with dynamic pricing and since you cannot add anything to a cart that isn't a product variant, you'd need to have an actual product you are adding.
Which brings us to the issue that product prices arent dynamic least of all calculated based on total cart value. So what are your options? First and foremost, you will need to create an app in order to get access to Admin API for creating products and other actions that go beyond what's available in AJAX or Storefront API.
Each of the above have its own pitfalls / limitations. Let's go through them in same order as above
Ultimately, none of these are ideal, complete or effective in my opinion. So what I usually recommend in that case is to reconsider your requirements.
Of course, maybe someone else can come up with more effective suggestions?
Thanks for the answer, but so far no solution , what I know.
What I am doing is I am creating a product of insurance with 0.01 $ value and whatever percentage I get based on the cart Value , I am multiplying that with that value and getting the Number of Products I need to add to the cart for that 1 cent Insurance . This way I am able o get the Insurance percentage added to the CART Dynamically by playing with the Quantity of the insurance product.
The challenge is for a user , he purchase a product (leyts say 200$) , now we added another product of insurance for a price which is lest say 2% only , but it shows as 0.01 x 400 products of 1 cent each, so that I achivee 4$ as the percentage . Very high possibility that th user gets confused that he has 401 projducts now while he added only 1 .
Any solutions ? You recommend.