0

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!

viriato
  • 859
  • 2
  • 13
  • 26

1 Answers1

1

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

Community
  • 1
  • 1
Fabio
  • 791
  • 1
  • 7
  • 27
  • Well, this is a nice clue! I will investigate and come back with a conclusion! :) Thanks so much! :) – viriato Jun 03 '16 at 11:49
  • Did it work out for you? If so please accept the answer so it can also be useful for others ;) – Fabio Jun 06 '16 at 00:00
  • Not yet since the customer still hasn't given me green light on this. I promise I will update you on this as soon as I can :) – viriato Jun 10 '16 at 13:43