You can use hooks with shortcodes: https://docs.woothemes.com/document/woocommerce-shortcodes/#section-9
Or create overrides for WooCommerce files in your own template.
Hi beamkiller. Actually all the shortcodes are helpful whenever i want to add one product to the cart.
[add_to_cart id=”105″]
This adds the product with id 105 easily.
However i want to add 2 or more products at one click.
I tried [add_to_cart id=”105&107″] but that did not work.
Add to cart endpoint does not support adding multiple items at once.
what approach should i follow then to achieve it?
Right now, custom querystring variable, then some code to detect this and loop over the IDs to add to the cart. WC()->cart->add_to_cart( ID );
Im fairly new to this actually. Is there no plugin available for this? Couldnt understand the approach you offered correctly.
I think the above plugin works only with the shop page. I want to use the button on any page of my site as required.
Then you’ll need to code something. If you need a developer, try jobs.wordpress.net.
I have a snippet for adding upsells to cart which can be used as a starting point but it needs adapting for your use case. https://mikejolley.com/2016/05/31/woocommerce-add-all-upsells-of-a-product-to-the-cart-via-custom-link/
Could you suggest me on what all to adapt in it?
The snippet shows how to look for a query string variable, and add items to the cart programmatically. As mentioned above, if you need help modifying this and making something perfect for your unique needs, use jobs.wordpress.net.
In the snippet why is it adding 2 quantity of upsells instead of a single quantity?
This adds 2 quantity of upsells for me, as well. What could be causing this?