Ajax add to cart error
-
Hi,
I am trying to get ajax add to cart working on my custom theme.
My theme allows you to add a quantity on the category and product pages.
I am using this code in my functionsif(isset($_POST['action']) && $_POST['action'] == 'ajax_button'){ global $woocommerce; $woocommerce->cart->add_to_cart($_POST['id'] , $_POST['qty']); WC_Cart::add_to_cart($_POST['id'], $_POST['qty']); }
but it returns
"PHP Fatal error: Call to a member function add_to_cart() on a non-object" line 378 returns error "PHP Notice: wc_get_product was called <strong>incorrectly</strong>. wc_get_product should not be called before the woocommerce_init action.
Any ideas what I’m doing wrong?
Cheers
Nik
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Ajax add to cart error’ is closed to new replies.