Dinamic pricing calling a remote API in the cart

I’m asking you if what I have in mind is feasible or not, that is, whether I should focus on Shopify or move to another solution. I need to implement dynamic pricing, where in the cart, a file (3D drawing) must be uploaded, and then an external API call is made that will return the correct price and modify the price in the cart.

I’ve developed the external API, and I can upload the file using a plugin (currently, I’ve set up Uploadly); the API call downloads the file from the Uploadly repository and returns the price.

From here, however, I can’t even find information on how to proceed.

With JavaScript (I have created a sample), I can indeed change the price on the page, but I suppose the modification for security reasons isn’t persisted if I click the buy button. Also, I noticed that there seems to be no API to change the price in the backend at that stage (before clicking buy button).

Is it possible to do dynamic pricing by calling a remote API at that point?
Can you point me in the right direction or does someone who has already developed the code want to leave me the references for further information?

Hey @cnc-cloud ,

Let me understand. Is there a base price before the file is uploaded? And when the API determines the price based on the drawing, is it to add on to the base price or create a new price completely?

For my curiosity and also may help me generate an answer too, how is the API going to determine the price?
My thinking is e.g. You can create a hidden input field which contains some product addons (normally used for + extra warranty, bundle deal,etc..) but since it’s hidden you can put in some fixed addons there and when the API call is successful, change the value of the hidden input field so the correct “add on” is applied to the product and increase the total price (base + add on)

If you have Shopify Plus, you can do this. If you don’t have it, you can use an app.

Thank you for your reply @ThePrimeWeb

The process involves analyzing the drawing to calculate the production time required for the item based on the drawing. From this calculated time, the price is determined. Therefore, there is no base price initially; a drawing must be uploaded to establish any price at all.

Given this, I’m afraid the approach you suggested might not be applicable in this context. This is because the pricing mechanism isn’t about adding fixed or discrete quantities—such as additional warranties or bundle deals—that can be easily appended or adjusted. Instead, it fundamentally hinges on a variable and dynamic calculation derived from each unique drawing. Therefore, using fixed add-ons to approximate the price wouldn’t accurately capture the highly variable nature of this calculation, especially considering the potentially vast range of production times and corresponding prices each drawing could represent.

Considering that I’m currently developing a Minimum Viable Product (MVP), I’m aiming to minimize initial costs, including avoiding the $2000 monthly recurring expense associated with Shopify Plus. When you suggest using an app, could you clarify whether you’re referring to leveraging an existing app available in the Shopify App Store or developing a custom app tailored to my specific needs? Your guidance on this would be greatly appreciated.

Yes, you are right. It has quite a high cost. Therefore, let’s find a different solution. The product detail page will receive a file and send a request to the API you specified. The product will be added to the cart with the price returned from there. This way, you’ll be able to add it with the desired price. Adding to the cart won’t be possible without uploading a file; this is a mandatory step. If a custom app is developed for you, this request can be fulfilled.