I am new to wordpress, trying to develop a wordpress plugin where I need to call a woocommerce method add_to_cart
from the class woocommerce/includes/class-wc-cart.php
. Is there any way to do that ?
1 comment
Comments are closed.
I am new to wordpress, trying to develop a wordpress plugin where I need to call a woocommerce method add_to_cart
from the class woocommerce/includes/class-wc-cart.php
. Is there any way to do that ?
Comments are closed.
WooCommerce declares a handy globlal
WC()
that you can use inside your plugin to call its functions.Add the following code to your plugin
Above code will automatically add a product to the cart when you visit the single product page. Here’s a list of hooks & filters offered by WooCommerce that you can hook into.