Hi @arconsulting,
If I am capturing this correctly, you’re trying to add a variable product to the cart programmatically.
The code you’re using seems to be correct since the right syntax is:
WC()->cart->add_to_cart( $product_id, $quantity, $variation_id );
As a first step, I’d suggest you double-check your $POST[] vars.
Thanks for your reply. I had already checked, however, to make sure it isn’t the coding I added one variable product directly to the cart and the same thing happens (parent id, quantity of 1, and variable ids):
WC()->cart->add_to_cart(96012, 1, 96130);
The results are the same. The price changes with each variation correctly, but not the title. Also, the url on the “a” tag changes as well. Something must be blocking it, but adding it directly should have worked. Very strange. Any thoughts?
Hi @arconsulting,
By default you should have in the cart the parent product name, then a dash, then the variation, like so:

Link to image: https://d.pr/i/g9Mli3
If not, maybe you’re using a custom template that modifies this default behavior?
Hi there,
Thanks again. I have done a lot of customization so no doubt something I have done, but have removed event listeners (as there is a lot of jQuery ajax coding) and revisions to templates.
Here is the page. If you scroll down to “Please select one of the following:” and select a membership option from the pulldown menu, you can view the problem in the cart by hovering over the green button on the top navigation bar.
I am grateful for any assistance or ideas. I don’t expect you do debug. Just thought it might be easier if you saw the problem.
https://wooc.nanps.org/online-plant-sale/
thanks again,
andrea
Hi @arconsulting,
I can’t tell this is related but that is something I would check:

Link to image: https://d.pr/i/3IV556
Hey there, since we haven’t heard back from you in awhile I’ll mark this thread as resolved now. If you have any further questions, I recommend creating a new thread.