Revert "Also delete when order type is placehoder, since it was created by HPOS."

This reverts commit 5e636046dd.

Reverting so that it can be properly included in a seperate PR
This commit is contained in:
Vedanshu Jain 2023-03-17 14:01:52 +05:30
parent ade1540ece
commit 31134c7055
1 changed files with 2 additions and 11 deletions

View File

@ -1790,18 +1790,9 @@ FROM $order_meta_table
$order->set_id( 0 );
/** We can delete the post data if:
* 1. If the HPOS table is authoritative and synchronization is enabled.
* 2. If the post record is of type `shop_order_placehold`, since this is created by the HPOS in the first place.
*
* In other words, we do not delete the post record when HPOS table is authoritative and synchronization is disabled but post record is a full record and not just a placeholder, because it implies that the order was created before HPOS was enabled.
*/
// Only delete post data if the posts table is authoritative and synchronization is enabled.
$data_synchronizer = wc_get_container()->get( DataSynchronizer::class );
if (
( $data_synchronizer->data_sync_is_enabled() && $order->get_data_store()->get_current_class_name() === self::class ) ||
( get_post_type( $order_id ) === 'shop_order_placehold' )
) {
if ( $data_synchronizer->data_sync_is_enabled() && $order->get_data_store()->get_current_class_name() === self::class ) {
// Delete the associated post, which in turn deletes order items, etc. through {@see WC_Post_Data}.
// Once we stop creating posts for orders, we should do the cleanup here instead.
wp_delete_post( $order_id );