Hello,
Basically trying to add an option in the product where customers can choose the number of pages desired in their book for printing. then based on that input the price will be adjusted. If the drop down suggests number of pages ranging from 30 to 200, and the customer chooses 70 then the formula would adjust the price to : base price of 30 pages+ (price per page)*(70-30).Otherwise, I believe that creating different variants for each number of pages would be impractical as I will have at lease 170 variants per product, which is too much work and not the best way to do it.
Thanks
1 Like
Hello @Goldnmemory
To achieve this, you can use Shopify’s line item properties combined with JavaScript to dynamically adjust the price without creating multiple variants. Here’s the approach:
Add a Dropdown for Pages: Use a select input in your product template to let customers choose the number of pages (e.g., 30–200).
Dynamic Price Calculation: Use JavaScript to calculate the total price using the formula: Base Price + (Price per Page * (Selected Pages - Base Pages)).
Pass Data to Cart: Use line item properties to include the selected page count and adjusted price in the cart and checkout.
This method avoids creating excessive variants and simplifies the process for both you and your customers. Let me know if you need help implementing it!
Hello Devcoders,
Thanks for your reply, yes this is exactly what I am trying to do. However I am not sure how to do any of these without assistance as my knowledge in javascript is pretty limited. Also how do I add the dropdown for pages ? the only options I can add are as shown in the photo below:
Firstly if you doing this for non shopify stores then its not possible to do this, but if you are using shopify plus store, you have to create a cart transform api that will allow you to change the price on the fly, deploy your cart-transform-function activate it and then you are good to go