• Hi,

    I am trying to add an woocommerce subscription product that has variations to cart via URL e.g. /?add-to-cart=162 however this method along with standard woocommerce shortcode does not work with subscription variations for some reason.

    What would be the best method to do this using PHP or js/jquery?

    I was thinking doing it with PHP and then turn it into a custom shortcode.

    Any ideas?

    Thsi was my attempt?

    // Add Shortcode
    function custom_add_to_cart() {
    	global $woocommerce;
    	$woocommerce->cart->add_to_cart($product_id = '351');
    }
    add_shortcode( 'add_cart_basic_plan', 'custom_add_to_cart' );
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘WooCommerce PHP Add to cart script?’ is closed to new replies.