WP custom post type cant already add to cart in woocommerce 3.0 above

I can still add custom post type to cart in WooCommerce 2.6 just by adding a filter to ‘woocommerce_product_class’

function wc_product_class( $class, $product_type, $post_type ) {

  if( 'my_custom_post_type_slug' == $post_type )
    $class = 'WC_Product_Simple';

  return $class;

}
add_filter( 'woocommerce_product_class', 'wc_product_class', 10, 3);

//This will echo the carti item id
echo WC()->cart->add_to_cart($custom_post_type_id, $quantity, null, null, array());

Unfortunately this doesn’t already work on the latest version of WooCommerce. Would somebody please help me what is the solution for this issue? Any suggestions, comments, solutions are much appreciated.

Read more here: WP custom post type cant already add to cart in woocommerce 3.0 above

Leave a Reply

Your email address will not be published. Required fields are marked *