• I am trying to replicate the ajax call for adding a product to the cart, and doing it in PHP using the WooCommerce object.
    Here is my ajax url that works
    https://domain.com/cart/?add-to-cart=857&quantity=1&wc_autoship_frequency=30
    Here is my equivalent PHP call
    $woocommerce->cart->add_to_cart( 857, 1,'',array("wc_autoship_frequency" => 30) );
    This does add the product to the cart, but it ignores the custom value of wc_autoship_frequency.

    The wc_autoship_frequency appears to be a variation (value is stored for the product in post_meta table). The product does not have any variation_ids.

  • The topic ‘Replicating ajax add-to-cart call in cart->add_to_cart()’ is closed to new replies.