Use orders table if hpos is enabled

This commit is contained in:
Emili Castells Guasch 2023-08-01 16:46:33 +02:00
parent 66f29789fb
commit 9b589c6040

View file

@ -7,6 +7,8 @@
namespace WooCommerce\PayPalCommerce\Compat\PPEC;
use Automattic\WooCommerce\Utilities\OrderUtil;
/**
* Helper class with various constants associated to the PayPal Express Checkout plugin, as well as methods for figuring
* out the status of the gateway.
@ -73,6 +75,14 @@ class PPECHelper {
}
global $wpdb;
if ( class_exists( OrderUtil::class ) && OrderUtil::custom_orders_table_usage_is_enabled() ) {
$result = $wpdb->get_var(
$wpdb->prepare(
"SELECT 1 FROM {$wpdb->wc_orders} WHERE payment_method = %s",
'ppec_paypal'
)
);
} else {
$result = $wpdb->get_var(
$wpdb->prepare(
"SELECT 1 FROM {$wpdb->posts} p JOIN {$wpdb->postmeta} pm ON pm.post_id = p.ID
@ -83,6 +93,7 @@ class PPECHelper {
self::PPEC_GATEWAY_ID
)
);
}
set_transient(
'ppcp_has_ppec_subscriptions',