PluginProbe
MailerLite – WooCommerce integration / trunk
MailerLite – WooCommerce integration vtrunk
3.1.27 3.1.25 3.1.26 3.1.24 3.1.23 3.1.22 3.1.21 3.1.20 3.1.19 3.1.18 3.1.17 3.1.16 3.1.15 1.8.7 1.8.8 2.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 All 148 releases
← All changes | includes/WooMailerLiteService.php +8 -6 3.1.16 → trunk View file →
@@ -29,8 +29,9 @@
29 29 * @return true
30 30 */
31 31 public function handleCartUpdated()
32 32 {
33 + WooMailerLiteLanguageService::capture();
33 34 WooMailerLiteSession::set('woo_mailerlite_cart_hash', WC()->session->get_customer_id());
34 35 $cart = WooMailerLiteCart::where('hash', WooMailerLiteSession::getMLCartHash())->first();
35 36 $data = WooMailerLiteSession::cart();
36 37 $data = json_decode($data, true);
@@ -75,8 +76,9 @@
75 76 * @return void
76 77 */
77 78 public function handleCheckoutPage()
78 79 {
80 + WooMailerLiteLanguageService::capture();
79 81 if (is_user_logged_in()) {
80 82 $this->sendCart();
81 83 }
82 84 }
@@ -101,8 +103,10 @@
101 103 if (!WooMailerLiteSession::getMLCartHash()) {
102 104 $this->handleCartUpdated();
103 105 }
104 106
107 + WooMailerLiteLanguageService::capture();
108 +
105 109 WooMailerLiteSession::set('woo_mailerlite_customer_data', ['customer' => $_POST, 'cart' => WC()->session->get( 'woo_mailerlite_cart_hash')]);
106 110 // find the cart by cart id
107 111 $cart = WooMailerLiteCart::where('hash', WooMailerLiteSession::getMLCartHash())->first();
108 112
@@ -130,9 +134,9 @@
130 134 return true;
131 135 }
132 136 $customer = WooMailerLiteSession::getMLCustomer();
133 137 $checkoutData = WooMailerLiteCheckoutDataService::getCheckoutData($customer['customer']['email'] ?? null);
134 - $customerQuery = WooMailerLiteCustomer::where('email', $customer['customer']['email'])->first();
138 + $customerQuery = WooMailerLiteCustomer::where('email', $customer['customer']['email'] ?? null)->first();
135 139 try {
136 140 if (self::instance()->apiClient->isClassic()) {
137 141 home_url();
138 142 self::instance()->apiClient->sendCart(home_url(), $checkoutData);
@@ -167,17 +171,14 @@
167 171
168 172 $orderCustomer['subscriber_fields'] = array_filter(
169 173 $orderCustomer['subscriber_fields'],
170 174 function ($v, $k) {
171 - return in_array($k, WooMailerLiteOptions::get("settings.syncFields"));
175 + return in_array($k, WooMailerLiteOptions::get("settings.syncFields", []));
172 176 },
173 177 ARRAY_FILTER_USE_BOTH
174 178 );
175 179
176 - if (isset($checkoutData['language'])) {
177 - $orderCustomer['subscriber_fields']['subscriber_language'] = $checkoutData['language'];
178 - $orderCustomer['subscriber_fields']['language'] = $checkoutData['language'];
179 - }
180 + $orderCustomer['subscriber_fields'] = WooMailerLiteLanguageService::applyTo($orderCustomer['subscriber_fields']);
180 181
181 182 $orderCart = [
182 183 'resource_id' => (string)$checkoutData['id'],
183 184 'checkout_url' => $checkoutData['abandoned_checkout_url'],
@@ -193,8 +194,9 @@
193 194 $product = wc_get_product($item['product_id']);
194 195
195 196 $orderCart['items'][] = [
196 197 'product_resource_id' => (string)$item['product_id'],
198 + 'ecommerce_product_variant_id' => (string) $item['variation_id'],
197 199 'variant' => $product->get_name(),
198 200 'quantity' => (int)$item['quantity'],
199 201 'price' => floatval($product->get_price('edit')),
200 202 ];