Changeset 3348600
- Timestamp:
- 08/22/2025 11:20:09 AM (7 months ago)
- Location:
- woo-mailerlite/trunk
- Files:
-
- 9 edited
-
includes/api/WooMailerLiteClassicApi.php (modified) (1 diff)
-
includes/common/WooMailerLiteQueryBuilder.php (modified) (1 diff)
-
includes/controllers/WooMailerLiteOrderController.php (modified) (2 diffs)
-
includes/models/WooMailerLiteCart.php (modified) (1 diff)
-
includes/models/WooMailerLiteModel.php (modified) (1 diff)
-
public/js/blocks-integration/woo-mailerlite-blocks.js (modified) (2 diffs)
-
public/js/woo-mailerlite-public.js (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
-
woo-mailerlite.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woo-mailerlite/trunk/includes/api/WooMailerLiteClassicApi.php
r3346776 r3348600 116 116 return $this->get('/subscribers/' . $email); 117 117 } 118 119 public function syncCustomers($data) 120 { 121 return $this->successResponse(); 122 } 123 124 public function importCategories() 125 { 126 return $this->successResponse(); 127 } 128 129 public function importProducts() 130 { 131 return $this->successResponse(); 132 } 118 133 } -
woo-mailerlite/trunk/includes/common/WooMailerLiteQueryBuilder.php
r3338878 r3348600 66 66 $model->attributes[$key] = json_decode($model->attributes[$key], true); 67 67 break; 68 case 'boolean': 69 $model->attributes[$key] = (bool) $model->attributes[$key]; 70 break; 68 71 } 69 72 } -
woo-mailerlite/trunk/includes/controllers/WooMailerLiteOrderController.php
r3346776 r3348600 63 63 $orderCustomer = [ 64 64 'email' => $customer->email ?? $order->get_billing_email(), 65 'create_subscriber' => (bool)$subscribe,66 'accepts_marketing' => (bool)$subscribe,65 'create_subscriber' => $subscribe, 66 'accepts_marketing' => $subscribe, 67 67 'subscriber_fields' => $customerFields, 68 68 'total_spent' => ($customer->total_spent ?? $order->get_total()), … … 131 131 } 132 132 if ($this->apiClient()->isClassic()) { 133 $response = $this->apiClient()->searchSubscriber( 'gaurang+testabandonedcart40@mailerlite.com');133 $response = $this->apiClient()->searchSubscriber($customer->email); 134 134 if ($response->success) { 135 135 $response->data->customer->subscriber->created_at = $response->data->date_created; -
woo-mailerlite/trunk/includes/models/WooMailerLiteCart.php
r3338878 r3348600 13 13 ]; 14 14 15 protected $format = [ 16 'data' => 'array' 17 ]; 15 protected $format = [ 16 'data' => 'array', 17 'subscribe' => 'boolean', 18 ]; 18 19 } -
woo-mailerlite/trunk/includes/models/WooMailerLiteModel.php
r3338878 r3348600 3 3 class WooMailerLiteModel 4 4 { 5 public array $meta = [6 '_woo_ml_product_tracked' => 'tracked',7 '_woo_ml_product_ignored' => 'ignored',8 '_woo_ml_category_tracked' => 'tracked'9 ];10 public $attributes;5 public array $meta = [ 6 '_woo_ml_product_tracked' => 'tracked', 7 '_woo_ml_product_ignored' => 'ignored', 8 '_woo_ml_category_tracked' => 'tracked' 9 ]; 10 public $attributes; 11 11 12 protected $table;12 protected $table; 13 13 14 protected array $updateAttributes = [];14 protected array $updateAttributes = []; 15 15 16 protected $casts = [];16 protected $casts = []; 17 17 18 protected $format;18 protected $format; 19 19 20 protected $removeEmpty = [];20 protected $removeEmpty = []; 21 21 22 protected $isResource = false;22 protected $isResource = false; 23 23 24 public static $customTablesEnabled;24 public static $customTablesEnabled; 25 25 26 public function __construct($attributes = [])27 {28 $this->attributes = $attributes;29 }26 public function __construct($attributes = []) 27 { 28 $this->attributes = $attributes; 29 } 30 30 31 public function __get($attribute)32 {33 if (in_array($attribute, $this->casts)) {31 public function __get($attribute) 32 { 33 if (in_array($attribute, $this->casts)) { 34 34 35 if (!empty($this->format[$attribute])) {36 switch ($this->format[$attribute]) {37 case 'array':38 if (!is_array($this->attributes[$attribute])) {39 return json_decode($this->attributes[$attribute], true);40 }41 break;42 case 'object':43 return json_decode($this->attributes[$attribute]);44 case 'boolean':45 return (bool)$this->attributes[$attribute];46 case 'string':47 return (string)$this->attributes[$attribute];48 default:49 return $this->attributes[$attribute];50 }51 }52 return $this->attributes[$attribute];53 } elseif (isset($this->attributes[$attribute])) {54 return $this->attributes[$attribute];55 }56 return null;57 }35 if (!empty($this->format[$attribute])) { 36 switch ($this->format[$attribute]) { 37 case 'array': 38 if (!is_array($this->attributes[$attribute])) { 39 return json_decode($this->attributes[$attribute], true); 40 } 41 break; 42 case 'object': 43 return json_decode($this->attributes[$attribute]); 44 case 'boolean': 45 return (bool)$this->attributes[$attribute]; 46 case 'string': 47 return (string)$this->attributes[$attribute]; 48 default: 49 return $this->attributes[$attribute]; 50 } 51 } 52 return $this->attributes[$attribute]; 53 } elseif (isset($this->attributes[$attribute])) { 54 return $this->attributes[$attribute]; 55 } 56 return null; 57 } 58 58 59 public function __set($attribute, $value)60 {61 if (static::class === 'WooMailerLiteCategory') {62 unset($this->meta['_woo_ml_product_tracked']);63 }64 if (in_array($attribute, array_values($this->meta))) {65 $this->attributes[$attribute] = $value;66 $this->updateAttributes[] = $attribute;59 public function __set($attribute, $value) 60 { 61 if (static::class === 'WooMailerLiteCategory') { 62 unset($this->meta['_woo_ml_product_tracked']); 63 } 64 if (in_array($attribute, array_values($this->meta))) { 65 $this->attributes[$attribute] = $value; 66 $this->updateAttributes[] = $attribute; 67 67 68 } else {69 $this->attributes[$attribute] = $value;70 }71 }68 } else { 69 $this->attributes[$attribute] = $value; 70 } 71 } 72 72 73 public function __call($method, $parameters)74 {75 return $this->queryBuilder()->$method(...$parameters);76 }73 public function __isset($attribute) 74 { 75 return isset($this->attributes[$attribute]); 76 } 77 77 78 public static function __callStatic($name, $arguments)79 {80 return (new static([]))->$name(...$arguments);81 }78 public function __call($method, $parameters) 79 { 80 return $this->queryBuilder()->$method(...$parameters); 81 } 82 82 83 public function save() 84 { 85 foreach ($this->updateAttributes as $updateAttribute) { 86 if (static::class === 'WooMailerLiteCategory') { 87 update_term_meta($this->resource_id, array_search($updateAttribute, $this->meta), $this->attributes[$updateAttribute]); 88 } else { 89 if ($updateAttribute === 'ignored') { 90 $ignoredProducts = WooMailerLiteOptions::get('ignored_products', []); 91 if (!$this->attributes[$updateAttribute]) { 92 unset($ignoredProducts[$this->resource_id]); 93 } else { 94 $ignoredProducts[$this->resource_id] = $this->name; 95 } 96 WooMailerLiteOptions::update('ignored_products', $ignoredProducts); 97 } 98 update_post_meta($this->resource_id, array_search($updateAttribute, $this->meta), $this->attributes[$updateAttribute]); 83 public static function __callStatic($name, $arguments) 84 { 85 return (new static([]))->$name(...$arguments); 86 } 99 87 100 } 101 } 102 } 88 public function save() 89 { 90 foreach ($this->updateAttributes as $updateAttribute) { 91 if (static::class === 'WooMailerLiteCategory') { 92 update_term_meta($this->resource_id, array_search($updateAttribute, $this->meta), $this->attributes[$updateAttribute]); 93 } else { 94 if ($updateAttribute === 'ignored') { 95 $ignoredProducts = WooMailerLiteOptions::get('ignored_products', []); 96 if (!$this->attributes[$updateAttribute]) { 97 unset($ignoredProducts[$this->resource_id]); 98 } else { 99 $ignoredProducts[$this->resource_id] = $this->name; 100 } 101 WooMailerLiteOptions::update('ignored_products', $ignoredProducts); 102 } 103 update_post_meta($this->resource_id, array_search($updateAttribute, $this->meta), $this->attributes[$updateAttribute]); 103 104 104 public function exists() 105 { 106 return count($this->attributes) > 0; 107 } 105 } 106 } 107 } 108 108 109 public function setRelation($relation, $value) 110 { 111 $this->attributes[$relation] = $value; 112 return $this; 113 } 109 public function exists() 110 { 111 return count($this->attributes) > 0; 112 } 114 113 115 public function queryBuilder() 116 { 117 return new WooMailerLiteQueryBuilder($this); 118 } 114 public function setRelation($relation, $value) 115 { 116 $this->attributes[$relation] = $value; 117 return $this; 118 } 119 119 120 public function getTable()121 {122 return $this->table;123 }120 public function queryBuilder() 121 { 122 return new WooMailerLiteQueryBuilder($this); 123 } 124 124 125 public function isResource()126 {127 return $this->isResource;128 }125 public function getTable() 126 { 127 return $this->table; 128 } 129 129 130 public function getCastsArray()131 {132 return $this->casts;133 }130 public function isResource() 131 { 132 return $this->isResource; 133 } 134 134 135 public function getFormatArray()136 {137 return $this->format;138 }135 public function getCastsArray() 136 { 137 return $this->casts; 138 } 139 139 140 public function getRemoveEmptyArray()141 {142 return $this->removeEmpty;143 }140 public function getFormatArray() 141 { 142 return $this->format; 143 } 144 144 145 public function setResource() 146 { 147 $this->isResource = true; 148 } 145 public function getRemoveEmptyArray() 146 { 147 return $this->removeEmpty; 148 } 149 150 public function setResource() 151 { 152 $this->isResource = true; 153 } 149 154 } -
woo-mailerlite/trunk/public/js/blocks-integration/woo-mailerlite-blocks.js
r3338878 r3348600 19 19 return el( 20 20 'div', 21 {}, 22 ) 21 ); 23 22 } 24 23 … … 174 173 } 175 174 176 return MailerLiteWooHidden ? MailerLiteHiddenCheckbox() : MailerLiteCheckbox(); 175 return el( 176 'div', 177 { 178 'data-block-name': 'mailerlite-block/woo-mailerlite', 179 }, 180 MailerLiteWooHidden ? MailerLiteHiddenCheckbox() : MailerLiteCheckbox() 181 ); 177 182 }; 178 183 -
woo-mailerlite/trunk/public/js/woo-mailerlite-public.js
r3346224 r3348600 6 6 let foundEmail = false; 7 7 let checkboxAdded = false; 8 let mailerLiteCheckoutBlockActive = null; 9 8 10 if (document.querySelector('[data-block-name="woocommerce/checkout"]')) { 9 window.mailerlitePublicJsCaptured = false 10 return 11 window.mailerlitePublicJsCaptured = false; 11 12 } else { 12 window.mailerlitePublicJsCaptured = true 13 window.mailerlitePublicJsCaptured = true; 13 14 } 15 14 16 if (wooMailerLitePublicData.checkboxSettings.enabled && document.body.classList.contains('woocommerce-checkout')) { 15 17 triggerAddEvents(); 16 18 } 19 17 20 var execute; 21 18 22 if (wooMailerLitePublicData.checkboxSettings.preselect) { 19 23 jQuery('#woo_ml_subscribe').prop('checked', true); 20 24 } 25 21 26 if (wooMailerLitePublicData?.checkboxSettings?.enabled) { 22 27 let retryCount = 0; … … 36 41 37 42 function triggerAddEvents() { 38 if (checkboxAdded) { 43 44 const mailerLiteCheckoutBlockWrapper = document.querySelector('[data-block-name="mailerlite-block/woo-mailerlite"]'); 45 46 if(mailerLiteCheckoutBlockWrapper && mailerLiteCheckoutBlockWrapper.querySelector('#woo_ml_subscribe')) { 47 mailerLiteCheckoutBlockActive = true; 48 } 49 50 if (checkboxAdded || (mailerLiteCheckoutBlockActive !== null && mailerLiteCheckoutBlockActive)) { 39 51 return false; 40 52 } 53 41 54 allowedInputs.forEach((val, key) => { 42 55 if (!foundEmail && val.match('email')) { … … 59 72 }) 60 73 61 const signup = document.querySelector('#woo_ml_subscribe'); 62 if (email !== null && !email.form?.querySelector('#woo_ml_subscribe')) { 74 let signup = document.getElementById('woo_ml_subscribe'); 63 75 64 if (!document.getElementById('woo_ml_subscribe')) {65 const checkboxWrapper = document.createElement('div');66 checkboxWrapper.className = 'woo-ml-subscribe-wrapper';67 checkboxWrapper.style.marginTop = '15px';68 const wooMlCheckoutCheckbox = document.createElement('input');69 wooMlCheckoutCheckbox.setAttribute('id', 'woo_ml_subscribe');70 wooMlCheckoutCheckbox.setAttribute('type', 'checkbox');71 wooMlCheckoutCheckbox.setAttribute('value', wooMailerLitePublicData.checkboxSettings.preselect ? 1 : 0);72 wooMlCheckoutCheckbox.setAttribute('checked', wooMailerLitePublicData.checkboxSettings.preselect ? 'checked' : '');76 if (email !== null && !signup) { 77 const checkboxWrapper = document.createElement('div'); 78 checkboxWrapper.className = 'woo-ml-subscribe-wrapper'; 79 checkboxWrapper.style.marginTop = '1rem'; 80 const wooMlCheckoutCheckbox = document.createElement('input'); 81 wooMlCheckoutCheckbox.setAttribute('id', 'woo_ml_subscribe'); 82 wooMlCheckoutCheckbox.setAttribute('type', 'checkbox'); 83 wooMlCheckoutCheckbox.setAttribute('value', wooMailerLitePublicData.checkboxSettings.preselect ? 1 : 0); 84 wooMlCheckoutCheckbox.setAttribute('checked', wooMailerLitePublicData.checkboxSettings.preselect ? 'checked' : ''); 73 85 86 if (!wooMailerLitePublicData.checkboxSettings.hidden) { 87 const label = document.createElement('label'); 74 88 75 if (!wooMailerLitePublicData.checkboxSettings.hidden) { 76 const label = document.createElement('label'); 77 label.htmlFor = 'woo-ml-subscribe-checkbox'; 78 label.textContent = wooMailerLitePublicData.checkboxSettings.label ?? 'Yes, I want to receive your newsletter.'; 79 checkboxWrapper.appendChild(wooMlCheckoutCheckbox); 80 checkboxWrapper.appendChild(label); 81 // Insert the container after the email field’s wrapper 82 // email.closest('p').insertAdjacentElement('afterend', container); 83 } 84 const wrapper = email.closest('div') ?? email; 85 wrapper.parentNode.insertBefore(checkboxWrapper, wrapper.nextSibling); 86 // email.insertAdjacentElement('afterend', wooMlCheckoutCheckbox); 87 checkboxAdded = true; 88 triggerAddEvents(); 89 label.style.cursor = 'pointer'; 90 label.style.display = 'inline-flex'; 91 label.style.alignItems = 'center'; 92 label.style.gap = '0.5rem'; 93 label.htmlFor = 'woo_ml_subscribe'; 94 95 // Create text span for the label 96 const labelText = document.createElement('span'); 97 labelText.textContent = wooMailerLitePublicData.checkboxSettings.label ?? 'Yes, I want to receive your newsletter.'; 98 99 // Append checkbox first, then text 100 label.appendChild(wooMlCheckoutCheckbox); 101 label.appendChild(labelText); 102 checkboxWrapper.appendChild(label); 103 // Insert the container after the email field’s wrapper 104 // email.closest('p').insertAdjacentElement('afterend', container); 89 105 } 106 107 const wrapper = email.closest('div') ?? email; 108 wrapper.parentNode.insertBefore(checkboxWrapper, wrapper.nextSibling); 109 // email.insertAdjacentElement('afterend', wooMlCheckoutCheckbox); 110 signup = document.getElementById('woo_ml_subscribe'); 111 checkboxAdded = true; 112 triggerAddEvents(); 90 113 } 91 114 -
woo-mailerlite/trunk/readme.txt
r3346776 r3348600 6 6 Tested up to: 6.8.2 7 7 Requires PHP: 7.2.5 8 Stable tag: 3.0. 68 Stable tag: 3.0.7 9 9 License: GPLv3 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 85 85 == Changelog == 86 86 87 = 3.0.7 (22nd August 2025) = 88 * Bug fixes and improvements 89 87 90 = 3.0.6 (18th August 2025) = 88 91 * Bug fixes and improvements -
woo-mailerlite/trunk/woo-mailerlite.php
r3346776 r3348600 16 16 * Plugin URI: https://wordpress.org/plugins/woo-mailerlite/ 17 17 * Description: Official MailerLite integration for WooCommerce. Track sales and campaign ROI, import products details, automate emails based on purchases and seamlessly add your customers to your email marketing lists via WooCommerce's checkout process. 18 * Version: 3.0. 618 * Version: 3.0.7 19 19 * Author: MailerLite 20 20 * Author URI: https://mailerlite.com … … 40 40 * Update when you release new versions. 41 41 */ 42 define( 'WOO_MAILERLITE_VERSION', '3.0. 6' );42 define( 'WOO_MAILERLITE_VERSION', '3.0.7' ); 43 43 44 44 define('WOO_MAILERLITE_ASYNC_JOBS', false);
Note: See TracChangeset
for help on using the changeset viewer.