Updated High Performance Order Storage Upgrade Recipe Book (markdown)

Jorge A. Torres 2022-09-20 18:32:58 -03:00
parent b80d4d34f4
commit f6555c314a
1 changed files with 11 additions and 7 deletions

@ -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 );
}
);
```