Can I change the product price from the frontend in Shopify?

Solved

Can I change the product price from the frontend in Shopify?

rohit1
Shopify Partner
13 0 1
Hello Community,I am looking for a way to change the price of a product directly from the frontend of my Shopify store. For example, I want to be able to modify the price of a product like it is done on this URL: https://gabegolf.com/product/make-a-payment/.
Is there a way to achieve this on Shopify? Can it be done with a custom code , and if yes, how can I implement this feature on my store?I would really appreciate your guidance and help!Thank you!
Accepted Solution (1)

Asad__Shahzad
Shopify Partner
12 2 2

This is an accepted solution.

Hey Rohit, its not possible to do this entirely from the frontend. You will need to setup a serverless backend to handle this use case. Basically, the backend here will be responsible for creating a line item in the cart with the entered price. 

 

This is how it would work.

You will need to create a product and set the price to 0.

Create a new template just for this product and assign it to the product created in the previous step.

Create a new section to render the important information about the product along with the price input field.

Add this section to the template created previously.

Setup click listener for the 'Add to Cart' button which, after performing some basic input validation, will send out a request to the serverless backend with all the required information such as the product ID, the price etc.

The backend will fire a mutation using the Admin API and create a product with the custom price. It will also add it to the cart. 

Once done, you will send a response to the frontend indicating that the process was successful.

In the frontend, you can then proceed to the cart or the checkout pages. 

 

I hope it gives you an idea of how it can work. 

Drop me a message for queries and quotations.

View solution in original post

Replies 4 (4)

MarvellousPaige
Visitor
2 0 1

Hi there!

Yes, it’s absolutely possible to implement a feature like this on Shopify! While it does involve a bit of customization, it’s definitely achievable with some tweaks to your product page and the right setup to handle custom pricing. Apps can be helpful too, but for something as tailored as this, custom coding might be the perfect fit.

If this sounds like something you’d like to explore, I’d be thrilled to help you bring it to life! Let’s make your store even more dynamic and engaging for your customers. Feel free to reach out to me at marvellous.digital.solutions@gmail.com—I’d love to discuss your ideas and get this set up for you.

Looking forward to hearing from you and helping your vision come to life!

rohit1
Shopify Partner
13 0 1

I don't want to create an app. I want to know if it's possible for this to work just by adding the code in the admin section of my store?

Asad__Shahzad
Shopify Partner
12 2 2

This is an accepted solution.

Hey Rohit, its not possible to do this entirely from the frontend. You will need to setup a serverless backend to handle this use case. Basically, the backend here will be responsible for creating a line item in the cart with the entered price. 

 

This is how it would work.

You will need to create a product and set the price to 0.

Create a new template just for this product and assign it to the product created in the previous step.

Create a new section to render the important information about the product along with the price input field.

Add this section to the template created previously.

Setup click listener for the 'Add to Cart' button which, after performing some basic input validation, will send out a request to the serverless backend with all the required information such as the product ID, the price etc.

The backend will fire a mutation using the Admin API and create a product with the custom price. It will also add it to the cart. 

Once done, you will send a response to the frontend indicating that the process was successful.

In the frontend, you can then proceed to the cart or the checkout pages. 

 

I hope it gives you an idea of how it can work. 

Drop me a message for queries and quotations.
rohit1
Shopify Partner
13 0 1

@Asad__Shahzad Thanks !