Automattic\WooCommerce\Admin\Features\ProductBlockEditor
RedirectionController::is_product_supported()
Check if a product is supported by the new experience.
Method of the class: RedirectionController{}
No Hooks.
Return
null
. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->is_product_supported( $product_id ): bool;
- $product_id(int) (required)
- Product ID.
RedirectionController::is_product_supported() RedirectionController::is product supported code WC 9.7.1
protected function is_product_supported( $product_id ): bool { $product = $product_id ? wc_get_product( $product_id ) : null; if ( is_null( $product ) ) { return false; } $digital_product = $product->is_downloadable() || $product->is_virtual(); $product_template_id = $product->get_meta( '_product_template_id' ); foreach ( $this->product_templates as $product_template ) { if ( is_null( $product_template->get_layout_template_id() ) ) { continue; } $product_data = $product_template->get_product_data(); $product_data_type = $product_data['type']; // Treat a variable product as a simple product since there is not a product template // for variable products. $product_type = $product->get_type() === ProductType::VARIABLE ? ProductType::SIMPLE : $product->get_type(); if ( isset( $product_data_type ) && $product_data_type !== $product_type ) { continue; } if ( isset( $product_template_id ) && $product_template_id === $product_template->get_id() ) { return true; } if ( isset( $product_data_type ) ) { return true; } } return false; }