diff --git a/High-Performance-Order-Storage-Upgrade-Recipe-Book.md b/High-Performance-Order-Storage-Upgrade-Recipe-Book.md index b6062ab..16f535c 100644 --- a/High-Performance-Order-Storage-Upgrade-Recipe-Book.md +++ b/High-Performance-Order-Storage-Upgrade-Recipe-Book.md @@ -77,7 +77,7 @@ To help with this, we have provided a few guidelines for extension developers to While the WooCommerce CRUD API will let you support both posts and custom tables without additional effort most of the time, in some cases (like when you are writing a SQL query for better performance) you would want to know whether the store is using HPOS tables or not. In this case, you can use the following pattern: ```php -use Automattic\WooCommerce\Utilities\woocommerce; +use Automattic\WooCommerce\Utilities\OrderUtil; if ( OrderUtil::custom_orders_table_usage_is_enabled() ) { // HPOS usage is enabled. @@ -135,12 +135,12 @@ When getting exact type of an order, or checking if given ID is an order, you ca ```php // Pattern to check when an ID is an order -‘shop_order’ === get_post_type( $post_id ); // or +'shop_order' === get_post_type( $post_id ); // or in_array( get_post_type( $post_type ), wc_get_order_types() ); // replace with: use Automattic\WooCommerce\Utilities\OrderUtil; -‘shop_order’ === OrderUtil::get_order_type( $post_id ); // or +'shop_order' === OrderUtil::get_order_type( $post_id ); // or OrderUtil::is_order( $post_id, wc_get_order_types() ); ``` @@ -200,8 +200,10 @@ Once you examined the extension's code, you can declare whether it's compatible use Automattic\WooCommerce\Internal\Features\FeaturesController; add_action( - 'init', - FeaturesController::declare_compatibility( 'custom_order_tables', basename(__DIR__) ) + 'init', + function() { + FeaturesController::declare_compatibility( 'custom_order_tables', basename(__DIR__) ); + } ); ``` @@ -212,8 +214,10 @@ If you know your code doesn't support HPOS, you should declare incompatibility i use Automattic\WooCommerce\Internal\Features\FeaturesController; add_action( - 'init', - FeaturesController::declare_compatibility( 'custom_order_tables', basename(__DIR__), false ) + 'init', + function() { + FeaturesController::declare_compatibility( 'custom_order_tables', basename(__DIR__), false ); + } ); ```