While developing a WooCommerce plugin which adds custom products to shoppin cart, I am using the function add_to_cart
inside the class-wc-cart.php
. But after updating woocomerce to latest version I receive the error.
Sorry, this product cannot be purchased.
because inside the function add_to cart
, the section $product_data->is_purchasable()
started to return false
. I debugged a find out that the reason why is_purchasable()
returns false is that get_price()
function. Because this function returns empty as price, hence woocommerce tells me the product is not purchasable because of empty price.
The product has a price and can be added to the cart using the interface. The plugin was working fine with old version of woocommerce. Let me know if you need more data.