sugud0r
Forum Replies Created
Viewing 1 replies (of 1 total)
-
My issues was solved. For any those who have the same problem: When you create a custom producty type that inherits
WC_Product_Variableyou need to addwoocommerce_add_to_cart_handlerfilter and returnvariableto tell WooCommerce the correct handler for your product type when the product is added to cart.Sample:
/** * Set variable to handler add to cart * * @param string $handler * @param WC_Product $product * @return string */ public static function set_correct_add_to_cart_handler( $handler, $product ) { if ( $product->is_type( 'your type' ) ) { $handler = 'the hanlder'; # variable, simple or grouped } return $handler; } add_filter( 'woocommerce_add_to_cart_handler', 'set_correct_add_to_cart_handler', 10, 2 );This also apply with simple or grouped products types (remember that you need to inherit the correct WC_Product_* class to create your custom product type).
This behaviour is defined in
woocommerce/includes/class-wc-form-handler.phpline 769 for WooCommerce 4.4.1Also, you can define your own handler with the action
'woocommerce_add_to_cart_handler_' . $your_product_type, but I guess that you need to really know what you are doing.
Viewing 1 replies (of 1 total)