Dynamically alter product price

Tolulope_Akinol
Shopify Partner
25 1 0

How can I modify the price of an item in the cart (or as it before it is placed in the cart) dynamically? eg Product X has a price of $100 on Tuesdays but $150 on Wednesdays. Product Y costs $50 if the customer is new but costs $70 if they have a cookie set

0 Likes
Visely-Team
Shopify Partner
1837 210 421

Hey Tolu. You can't do that, unless you do it through a discount or create a product on the fly which has the custom pricing (which is not scaleable). Another option would be to have all products duplicated, or at least variants duplicated (which again might not be scaleable) that will have different prices assigned. Then you substitute the right variant ID at the cart addition. But in this case you'll have to make sure only the variants with the relevant price are showing up on PDP.

 

And a bottom line, doing that only from the store front is not secure and definitely hackable.

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes
djnugent
Tourist
3 0 1

I have created a product page that sends a request to my server when the user adds the item to the cart. The server creates a variant, returns it's variant ID to the product page, and adds that variant to the cart. The limitation of this approach is the 100 variant limit per product. Which doesn't scale. 

 

I see their are apps on the app store that offer some form of dynamic pricing(Infinite options, Dynamic Product options, etc). I am curious what mechanism those apps are using to achieve this dynamic pricing behavior. 

 

Thanks,
Daniel

0 Likes
HunkyBill
Shopify Expert
4374 36 468

If you can dream up a nasty solution, then those are what those Apps do! As you can tell, making up variants on the fly is complete garbage as no accounting or inventory management can safely be applied, and if you think those "other Apps" are doing something smart and sensible and good with accounting and inventory management, well, you'd be wrong. You take them for a spin, and see what they do to your books. Infinite headaches!

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
djnugent
Tourist
3 0 1

Hi HunkyBill,

 

Thanks for the reply. Thats disappointing to hear. Of all the approaches you've seen attempt dynamic pricing on Shopify, which is the best in your opinion? I am trying to figure out if there is a reasonable "hacky" solution or if I have to switch to platforms.

 

Luckily my store will have low sales volume, which should give me time to implement a proper solution on another platform if it starts to become a problem. 

 

Thanks for your help,

Daniel

0 Likes
HunkyBill
Shopify Expert
4374 36 468

I think you understand. A product has variants. variants have a price. You cannot change the price except by using a discount code, or in Plus, where you can script a checkout and change a price to whatever you want. Assuming you are not on Plus then, you get discount codes. That is all.

 

 

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes
djnugent
Tourist
3 0 1

Ah ok. I wasn't aware of the Plus functionality. I will have to look into that a bit. I found a similar thread discussing the same issue. I will post it here for anyone reading this in the future. 

 

https://community.shopify.com/c/Shopify-APIs-SDKs/Changing-Prices-Dynamically-in-Product-page/m-p/36...

HunkyBill
Shopify Expert
4374 36 468

Yes. I answered that same way. You can use Line Item Properties, and by choosing their units carefully, you can add value to one product with a fixed base price, by choose to glue on a second product to it in the cart, where the second product would cover increased costs. Note that this is not going to help with whimsy things, or for customers with different situations... it is strictly a way to collect more money without blowing the variant limit. And it does mean you have to have your shit together when it comes to coding the theme and your Javascript!

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes
gemhealth
New Member
1 0 0

Can you expand upon how to use Plus to do this?

0 Likes