Plugin Directory

Changeset 3348600


Ignore:
Timestamp:
08/22/2025 11:20:09 AM (7 months ago)
Author:
mailerlite
Message:

updated to 3.0.7

Location:
woo-mailerlite/trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • woo-mailerlite/trunk/includes/api/WooMailerLiteClassicApi.php

    r3346776 r3348600  
    116116        return $this->get('/subscribers/' . $email);
    117117    }
     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    }
    118133}
  • woo-mailerlite/trunk/includes/common/WooMailerLiteQueryBuilder.php

    r3338878 r3348600  
    6666                            $model->attributes[$key] = json_decode($model->attributes[$key], true);
    6767                            break;
     68                        case 'boolean':
     69                            $model->attributes[$key] = (bool) $model->attributes[$key];
     70                            break;
    6871                    }
    6972                }
  • woo-mailerlite/trunk/includes/controllers/WooMailerLiteOrderController.php

    r3346776 r3348600  
    6363            $orderCustomer = [
    6464                '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,
    6767                'subscriber_fields' => $customerFields,
    6868                'total_spent' => ($customer->total_spent ?? $order->get_total()),
     
    131131                }
    132132                if ($this->apiClient()->isClassic()) {
    133                     $response = $this->apiClient()->searchSubscriber('gaurang+testabandonedcart40@mailerlite.com');
     133                    $response = $this->apiClient()->searchSubscriber($customer->email);
    134134                    if ($response->success) {
    135135                        $response->data->customer->subscriber->created_at = $response->data->date_created;
  • woo-mailerlite/trunk/includes/models/WooMailerLiteCart.php

    r3338878 r3348600  
    1313    ];
    1414
    15     protected $format = [
    16       'data' => 'array'
    17     ];
     15    protected $format = [
     16        'data' => 'array',
     17        'subscribe' => 'boolean',
     18    ];
    1819}
  • woo-mailerlite/trunk/includes/models/WooMailerLiteModel.php

    r3338878 r3348600  
    33class WooMailerLiteModel
    44{
    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;
    1111
    12     protected $table;
     12    protected $table;
    1313
    14     protected array $updateAttributes = [];
     14    protected array $updateAttributes = [];
    1515
    16     protected $casts = [];
     16    protected $casts = [];
    1717
    18     protected $format;
     18    protected $format;
    1919
    20     protected $removeEmpty = [];
     20    protected $removeEmpty = [];
    2121
    22     protected $isResource = false;
     22    protected $isResource = false;
    2323
    24     public static $customTablesEnabled;
     24    public static $customTablesEnabled;
    2525
    26     public function __construct($attributes = [])
    27     {
    28         $this->attributes = $attributes;
    29     }
     26    public function __construct($attributes = [])
     27    {
     28        $this->attributes = $attributes;
     29    }
    3030
    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)) {
    3434
    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    }
    5858
    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;
    6767
    68         } else {
    69             $this->attributes[$attribute] = $value;
    70         }
    71     }
     68        } else {
     69            $this->attributes[$attribute] = $value;
     70        }
     71    }
    7272
    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    }
    7777
    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    }
    8282
    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    }
    9987
    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]);
    103104
    104     public function exists()
    105     {
    106         return count($this->attributes) > 0;
    107     }
     105            }
     106        }
     107    }
    108108
    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    }
    114113
    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    }
    119119
    120     public function getTable()
    121     {
    122         return $this->table;
    123     }
     120    public function queryBuilder()
     121    {
     122        return new WooMailerLiteQueryBuilder($this);
     123    }
    124124
    125     public function isResource()
    126     {
    127         return $this->isResource;
    128     }
     125    public function getTable()
     126    {
     127        return $this->table;
     128    }
    129129
    130     public function getCastsArray()
    131     {
    132         return $this->casts;
    133     }
     130    public function isResource()
     131    {
     132        return $this->isResource;
     133    }
    134134
    135     public function getFormatArray()
    136     {
    137         return $this->format;
    138     }
     135    public function getCastsArray()
     136    {
     137        return $this->casts;
     138    }
    139139
    140     public function getRemoveEmptyArray()
    141     {
    142         return $this->removeEmpty;
    143     }
     140    public function getFormatArray()
     141    {
     142        return $this->format;
     143    }
    144144
    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    }
    149154}
  • woo-mailerlite/trunk/public/js/blocks-integration/woo-mailerlite-blocks.js

    r3338878 r3348600  
    1919            return el(
    2020                'div',
    21                 {},
    22             )
     21            );
    2322        }
    2423
     
    174173        }
    175174
    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        );
    177182    };
    178183
  • woo-mailerlite/trunk/public/js/woo-mailerlite-public.js

    r3346224 r3348600  
    66    let foundEmail = false;
    77    let checkboxAdded = false;
     8    let mailerLiteCheckoutBlockActive = null;
     9
    810    if (document.querySelector('[data-block-name="woocommerce/checkout"]')) {
    9         window.mailerlitePublicJsCaptured = false
    10         return
     11        window.mailerlitePublicJsCaptured = false;
    1112    } else {
    12         window.mailerlitePublicJsCaptured = true
     13        window.mailerlitePublicJsCaptured = true;
    1314    }
     15
    1416    if (wooMailerLitePublicData.checkboxSettings.enabled && document.body.classList.contains('woocommerce-checkout')) {
    1517        triggerAddEvents();
    1618    }
     19
    1720    var execute;
     21
    1822    if (wooMailerLitePublicData.checkboxSettings.preselect) {
    1923        jQuery('#woo_ml_subscribe').prop('checked', true);
    2024    }
     25
    2126    if (wooMailerLitePublicData?.checkboxSettings?.enabled) {
    2227        let retryCount = 0;
     
    3641
    3742    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)) {
    3951            return false;
    4052        }
     53
    4154        allowedInputs.forEach((val, key) => {
    4255            if (!foundEmail && val.match('email')) {
     
    5972        })
    6073
    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');
    6375
    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' : '');
    7385
     86            if (!wooMailerLitePublicData.checkboxSettings.hidden) {
     87                const label = document.createElement('label');
    7488
    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);
    89105            }
     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();
    90113        }
    91114
  • woo-mailerlite/trunk/readme.txt

    r3346776 r3348600  
    66Tested up to: 6.8.2
    77Requires PHP: 7.2.5
    8 Stable tag: 3.0.6
     8Stable tag: 3.0.7
    99License: GPLv3 or later
    1010License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    8585== Changelog ==
    8686
     87= 3.0.7 (22nd August 2025) =
     88* Bug fixes and improvements
     89
    8790= 3.0.6 (18th August 2025) =
    8891* Bug fixes and improvements
  • woo-mailerlite/trunk/woo-mailerlite.php

    r3346776 r3348600  
    1616 * Plugin URI:        https://wordpress.org/plugins/woo-mailerlite/
    1717 * 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.6
     18 * Version:           3.0.7
    1919 * Author:            MailerLite
    2020 * Author URI:        https://mailerlite.com
     
    4040 * Update when you release new versions.
    4141 */
    42 define( 'WOO_MAILERLITE_VERSION', '3.0.6' );
     42define( 'WOO_MAILERLITE_VERSION', '3.0.7' );
    4343
    4444define('WOO_MAILERLITE_ASYNC_JOBS', false);
Note: See TracChangeset for help on using the changeset viewer.