viriato
viriato

Reputation: 869

Woocommerce product amount inserted dynamicaly

I have a very specific case where a website offers the possibility to a user to use some sort of calculator/simulator. This tool will tell the customer - according to data previously inserted in a form by the user - which product to buy, which amount to buy plus a bunch other technical data that is not needed for this. This tool is built mainly with JS.

Today there is no connection between the result presented to the user and a Woocommerce shop but I am working on that. The point is that along with the calculation/simulation result there will be a link to the proper product so that the customer can buy the product directly.

As it is right now, the link is linking to the proper product and that's it. I wonder if there is a way to automatically fill in the product amount according to the amount that the user got from the calculator/simulator?

Been searching for a while for a solution for this but unfortunately could not find. I would be mostly appreciated för any kind of constructive feedback.

Many thanks in advance!

Upvotes: 0

Views: 40

Answers (1)

Fabio
Fabio

Reputation: 791

One possible way to do it is to pass an additional url parameter (e.g. "http://yourshop/products/niceproduct&qty=30") and then use jQuery (or whatever you prefer) to grab that value after the page is loaded and change the product quantity.

This might help: Get url parameter jquery Or How to Get Query String Values In js

Upvotes: 1

Related Questions