Register the new shop_order_placehold post type.

This post type will be used for placeholder entries for orders
that are created in the orders table when orders->posts sync is off
(placeholder entries are created to reserve a proper order id)
This commit is contained in:
Nestor Soriano 2022-04-20 16:30:08 +02:00
parent ad57fcf89a
commit 2301903a31
No known key found for this signature in database
GPG Key ID: 08110F3518C12CAD
1 changed files with 38 additions and 0 deletions

View File

@ -124,6 +124,13 @@ class CustomOrdersTableController {
$this->process_options_updated();
}
);
add_action(
'woocommerce_after_register_post_type',
function() {
$this->register_post_type_for_order_placeholders();
}
);
}
/**
@ -469,4 +476,35 @@ class CustomOrdersTableController {
$this->data_synchronizer->start_synchronizing_pending_orders();
}
}
/**
* Handler for the woocommerce_after_register_post_type post,
* registers the post type for placeholder orders.
*
* @return void
*/
private function register_post_type_for_order_placeholders(): void {
wc_register_order_type(
DataSynchronizer::PLACEHOLDER_ORDER_POST_TYPE,
array(
'public' => false,
'exclude_from_search' => true,
'publicly_queryable' => false,
'show_ui' => false,
'show_in_menu' => false,
'show_in_nav_menus' => false,
'show_in_admin_bar' => false,
'show_in_rest' => false,
'rewrite' => false,
'query_var' => false,
'can_export' => false,
'supports' => array(),
'capabilities' => array(),
'exclude_from_order_count' => true,
'exclude_from_order_views' => true,
'exclude_from_order_reports' => true,
'exclude_from_order_sales_reports' => true,
)
);
}
}