Change insertSubscriberFromOrder() to use WooCommerce methods
This commit changes \MailPoet\Segments\WooCommerce::insertSubscriberFromOrder() to use WooCommerce method instead of querying the database directly. This is needed as WooCommerce is moving away from WP tables and creating its own tables. [MAILPOET-4570]
This commit is contained in:
committed by
Aschepikov
parent
8e88a86f02
commit
b6bdce3535
@ -148,7 +148,7 @@ class WooCommerce {
|
||||
$status = SubscriberEntity::STATUS_SUBSCRIBED;
|
||||
}
|
||||
|
||||
$email = $this->insertSubscriberFromOrder($orderId, $status);
|
||||
$email = $this->insertSubscriberFromOrder($wcOrder, $status);
|
||||
|
||||
if (empty($email)) {
|
||||
return;
|
||||
@ -240,17 +240,10 @@ class WooCommerce {
|
||||
", ['capabilities' => $wpdb->prefix . 'capabilities', 'source' => Source::WOOCOMMERCE_USER]);
|
||||
}
|
||||
|
||||
private function insertSubscriberFromOrder(int $orderId, string $status): ?string {
|
||||
global $wpdb;
|
||||
private function insertSubscriberFromOrder(\WC_Order $wcOrder, string $status): ?string {
|
||||
$validator = new ModelValidator();
|
||||
|
||||
$email = $this->connection->executeQuery("
|
||||
SELECT wppm.meta_value AS email
|
||||
FROM `{$wpdb->posts}` wpp
|
||||
JOIN `{$wpdb->postmeta}` wppm ON wpp.ID = wppm.post_id AND wppm.meta_key = '_billing_email' AND wppm.meta_value != ''
|
||||
WHERE wpp.post_type = 'shop_order'
|
||||
AND wpp.ID = :orderId
|
||||
", ['orderId' => $orderId])->fetchOne();
|
||||
$email = $wcOrder->get_billing_email();
|
||||
|
||||
if (!$email || !$validator->validateEmail($email)) {
|
||||
return null;
|
||||
|
@ -775,11 +775,6 @@ parameters:
|
||||
count: 1
|
||||
path: ../../lib/Segments/WooCommerce.php
|
||||
|
||||
-
|
||||
message: "#^Method MailPoet\\\\Segments\\\\WooCommerce\\:\\:insertSubscriberFromOrder\\(\\) should return string\\|null but returns mixed\\.$#"
|
||||
count: 1
|
||||
path: ../../lib/Segments/WooCommerce.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$ch of function curl_errno expects resource, mixed given\\.$#"
|
||||
count: 1
|
||||
|
@ -775,11 +775,6 @@ parameters:
|
||||
count: 1
|
||||
path: ../../lib/Segments/WooCommerce.php
|
||||
|
||||
-
|
||||
message: "#^Method MailPoet\\\\Segments\\\\WooCommerce\\:\\:insertSubscriberFromOrder\\(\\) should return string\\|null but returns mixed\\.$#"
|
||||
count: 1
|
||||
path: ../../lib/Segments/WooCommerce.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$handle of function curl_errno expects CurlHandle, mixed given\\.$#"
|
||||
count: 1
|
||||
|
@ -774,11 +774,6 @@ parameters:
|
||||
count: 1
|
||||
path: ../../lib/Segments/WooCommerce.php
|
||||
|
||||
-
|
||||
message: "#^Method MailPoet\\\\Segments\\\\WooCommerce\\:\\:insertSubscriberFromOrder\\(\\) should return string\\|null but returns mixed\\.$#"
|
||||
count: 1
|
||||
path: ../../lib/Segments/WooCommerce.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$handle of function curl_errno expects CurlHandle, mixed given\\.$#"
|
||||
count: 1
|
||||
|
Reference in New Issue
Block a user