We have woocommerce site that have all virtual and downloadable products. We have multiple tickets linked to each product. We did some research and came to know that woocommerce treating each item in cart as a separate reservation. We want to do single reservation for all items in cart.
For example,
We want to visit a museum on certain date 05/06/2021 and that have Adult, Kids and Senior citizen tickets linked to it. Suppose User have selected 5 Adult, 2 Kids and 1 senior citizen. As per our research we came to know that woocommerce will do 3 reservation
- 5 Adult
- 2 Kids
- 1 Senior citizen.
We want to keep only single reservation for 5 Adult, 2 Kids and 1 Senior Citizen.
Is there any way to do such thing in woocommerce ?
2
Answers
There are probably plugins out there, but the simplest way to do this would to pretty much build your own function to handle this.
So for example, instead of having the default add to cart button, you could either add your own or write some JavaScript that fires an AJAX request. That request would then add the relevant items to the cart programatically. On completion you could take the user to the cart page. So something like this, note that this is a very rough not tested example, there is a lot of info out there on how to do this
Fired on add to cart
In your functions.php file (or better in a separate functions-ajax.php file)
Yes, you don’t have to think of adults kids and Senior citezens as individual item but you need to think of it as a meta for order.
Suppose you have a
product A
which is a visit to a museum now when someone goes to product page then there should be 3 number field foradults
,kids
andsenior citizens
. Whenever one has to book the product he/she has to make sure that he atleast makes sure that there is atleast 1 value for any of the three fields.These fields would be responsible for updating price of the product and once the product is added the values of adults, child and senior citizen will be saved inside the order.
After googling I found this plugin – Advanced Product Fields
I don’t think this would save order meta ( count of adult, child and senior citizen) in order. Use this answer to update meta using code.