You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adjustments for Custom Order Tables compatibility (#2420)
* Fixes math operation on empty string
`wc_parse_relative_date_option` will return an array. For that reason, it will cause to skip the validation because it will never be empty.
Later below, `$retention[‘number’]` is attempted unsuccessfully because `$retention[‘number’]` will be an empty string when the “Retain Stripe Data” option is not defined, causing an error and stopping the data removal.
* User Order method to update meta data
* Remove unused method
* Get order meta by using the `get_meta` method
* Add changelog entries
* Tweaks `get_order_by_source_id` to be compatible with Custom Order Tables
Avoids using the `wp_posts` table to get the order ID, instead uses the `wc_get_orders` which is compatible with COT.
* Tweaks `get_order_by_charge_id` to be compatible with Custom Order Tables
* Tweaks `get_order_by_intent_id` to be compatible with Custom Order Tables
* Tweaks `get_order_by_setup_intent_id` to be compatible with Custom Order Tables
* Remove unused method `delete_attribute`
* Check OrderUtil class exists before using it
* Use full path for class existence validation
* Check if current order exist
$order_id = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s AND meta.meta_key = %s", $source_id, '_stripe_source_id' ) );
378
+
if ( class_exists( 'Automattic\WooCommerce\Utilities\OrderUtil' ) && OrderUtil::custom_orders_table_usage_is_enabled() ) {
$order_id = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s AND meta.meta_key = %s", $source_id, '_stripe_source_id' ) );
391
+
}
377
392
378
393
if ( ! empty( $order_id ) ) {
379
394
returnwc_get_order( $order_id );
@@ -396,7 +411,17 @@ public static function get_order_by_charge_id( $charge_id ) {
396
411
returnfalse;
397
412
}
398
413
399
-
$order_id = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s AND meta.meta_key = %s", $charge_id, '_transaction_id' ) );
414
+
if ( class_exists( 'Automattic\WooCommerce\Utilities\OrderUtil' ) && OrderUtil::custom_orders_table_usage_is_enabled() ) {
$order_id = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s AND meta.meta_key = %s", $charge_id, '_transaction_id' ) );
424
+
}
400
425
401
426
if ( ! empty( $order_id ) ) {
402
427
returnwc_get_order( $order_id );
@@ -415,7 +440,20 @@ public static function get_order_by_charge_id( $charge_id ) {
$order_id = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s AND meta.meta_key = %s", $intent_id, '_stripe_intent_id' ) );
443
+
if ( class_exists( 'Automattic\WooCommerce\Utilities\OrderUtil' ) && OrderUtil::custom_orders_table_usage_is_enabled() ) {
$order_id = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s AND meta.meta_key = %s", $intent_id, '_stripe_intent_id' ) );
456
+
}
419
457
420
458
if ( ! empty( $order_id ) ) {
421
459
returnwc_get_order( $order_id );
@@ -434,7 +472,20 @@ public static function get_order_by_intent_id( $intent_id ) {
$order_id = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s AND meta.meta_key = %s", $intent_id, '_stripe_setup_intent' ) );
475
+
if ( class_exists( 'Automattic\WooCommerce\Utilities\OrderUtil' ) && OrderUtil::custom_orders_table_usage_is_enabled() ) {
$order_id = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s AND meta.meta_key = %s", $intent_id, '_stripe_setup_intent' ) );
0 commit comments