How to add multiple variable products to the cart via the add-to-cart query string
Clash Royale CLAN TAG #URR8PPP How to add multiple variable products to the cart via the add-to-cart query string I want to add two variable product into my cart when i clicking a link on my site. i added below code in my function.php this code is only working with the simple product its not working with the variable product. function woocommerce_maybe_add_multiple_products_to_cart( $url = false ) { // Make sure WC is installed, and add-to-cart qauery arg exists, and contains at least one comma. if ( ! class_exists( 'WC_Form_Handler' ) || empty( $_REQUEST['add-to-cart'] ) || false === strpos( $_REQUEST['add-to-cart'], ',' ) ) { return; } // Remove WooCommerce's hook, as it's useless (doesn't handle multiple products). remove_action( 'wp_loaded', array( 'WC_Form_Handler', 'add_to_cart_action' ), 20 ); $product_ids = explode( ',', $_REQUEST['add-to-cart'] ); $count ...