Plugin Directory

Changeset 3443312


Ignore:
Timestamp:
01/20/2026 01:50:47 PM (2 months ago)
Author:
mergado
Message:

4.2.1

Location:
mergado-marketing-pack/trunk
Files:
3 added
15 edited

Legend:

Unmodified
Added
Removed
  • mergado-marketing-pack/trunk/README.txt

    r3327281 r3443312  
    11=== Mergado Pack ===
    2 Stable tag: 4.2.0
     2Stable tag: 4.2.1
    33Contributors: mergado
    44Donate link: https://pack.mergado.com/woocommerce
    55Tags: woocommerce, marketing, xml, export, feed
    66Requires at least: 4.5.1
    7 Tested up to: 6.8
     7Tested up to: 6.9
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    269269== Changelog ==
    270270
     271= 4.2.1 =
     272* NEW: Implement checkboxes for Checkout blocks (Heureka, Arukereso, Pazaruvaj, Compari, Zbozi, Biano Star)
     273* IMPROVEMENT: Prevent EAN field usage before Wordpress v9.2
     274* FIX: Biano - failed to initialize for Greece
     275* FIX: Firefox - cron wizard save requests failed
     276
    271277= 4.2.0 =
    272278* NEW: Product feed - Brand element implemented
     
    760766* First plugin version
    761767* Another change.
    762 
    763 
    764 
  • mergado-marketing-pack/trunk/admin/js/mergado-marketing-pack-admin-wizard.js

    r2909979 r3443312  
    1414
    1515      if (actionToDo === 'mmpSaveWpCron') {
    16         mmpWizard.saveWpCron(feedType);
     16        await mmpWizard.saveWpCron(feedType);
    1717      } else if (actionToDo === 'mmpSaveWpCronAndGo') {
    1818        var result = mmpWizard.setWizardCompleted(feedType);
    1919
    2020        if (result) {
    21           mmpWizard.saveWpCron(feedType);
     21          await mmpWizard.saveWpCron(feedType);
    2222          window.location.href = $($this).attr('data-go-to-link');
    2323        }
     
    7979       }
    8080       ,
    81        saveWpCron: function(feedType) {
     81       saveWpCron: async function(feedType) {
    8282         var tab4a = this.getWizardStep4a(feedType);
    8383
  • mergado-marketing-pack/trunk/admin/templates/partials/tabs-adsys/adsys-biano.php

    r3327281 r3443312  
    2828
    2929        <?php
    30         foreach (BianoService::LANGUAGES as $lang => $domain):
    31             $activeLangName = BianoService::getActiveLangName($lang);
    32             $activeMerchantId = BianoService::getMerchantIdName($lang);
     30        foreach (BianoService::LANGUAGES as $countryCode => $values):
     31            $activeLangName = BianoService::getActiveLangName($values['language_code']);
     32            $activeMerchantId = BianoService::getMerchantIdName($values['language_code']);
     33
     34            $isLangActive = $bianoService->getActiveLang($values['language_code']);
     35            $merchantId = $bianoService->getMerchantId($values['language_code']);
    3336            ?>
    3437
     
    3639                <th>
    3740                    <label for="<?php echo $activeLangName; ?>">
    38                         <?php echo __('Biano pixel', 'mergado-marketing-pack') ?> - <?php echo $lang; ?>
     41                        <?php echo __('Biano pixel', 'mergado-marketing-pack') ?> - <?php echo $countryCode; ?>
    3942                    </label>
    4043                </th>
     
    4346                           id="<?php echo $activeLangName; ?>"
    4447                           name="<?php echo $activeLangName; ?>"
    45                            data-mmp-check-main="<?php echo BianoService::ACTIVE ?>-<?php echo $lang; ?>"
     48                           data-mmp-check-main="<?php echo BianoService::ACTIVE ?>-<?php echo $countryCode; ?>"
    4649                           data-mmp-check-field="<?php echo BianoService::ACTIVE ?>"
    47                         <?php if ($bianoService->getActiveLang($lang) === 1) { ?>
     50                        <?php if ($isLangActive === 1) { ?>
    4851                            checked="checked"
    4952                        <?php } ?>>
     
    5255                           id="<?php echo $activeMerchantId; ?>"
    5356                           name="<?php echo $activeMerchantId; ?>"
    54                            data-mmp-check-field="<?php echo BianoService::ACTIVE ?>-<?php echo $lang; ?>"
     57                           data-mmp-check-field="<?php echo BianoService::ACTIVE ?>-<?php echo $countryCode; ?>"
    5558                           placeholder="<?php echo __('Insert code here', 'mergado-marketing-pack') ?>"
    56                            value="<?php echo $bianoService->getMerchantId($lang); ?>">
     59                           value="<?php echo $merchantId; ?>">
    5760                </td>
    5861            </tr>
  • mergado-marketing-pack/trunk/includes/class-mergado-marketing-pack.php

    r3267637 r3443312  
    459459        }, 99);
    460460
    461         /**
    462          * ANALYTICS
    463          */
    464 
    465         // GTAG
    466         add_action( 'woocommerce_after_shipping_rate', [$this->ga4ServiceIntegration, "actionShippingRate"], 99);
    467 
    468461        /**
    469462         * Cart/checkout page
     
    532525        add_action('admin_head', [$this->ga4ServiceIntegration, 'pushRefundEvent']);
    533526
    534         //Checkout steps/options - checkboxs - not part of GDPR
     527        //Checkout steps/options - checkboxes - not part of GDPR
    535528        add_action("woocommerce_review_order_before_submit", [$this->heurekaServiceIntegration, "addVerifyOptOutCheckbox"], 10);
    536529        add_action("woocommerce_review_order_before_submit", [$this->zboziServiceIntegration, "addCheckboxVerifyOptIn"], 10);
     
    546539        add_action("woocommerce_checkout_update_order_meta", [$this->pazaruvajServiceIntegration, "setOrderMetaData"], 10);
    547540
     541
     542        add_action( "init", [$this->heurekaServiceIntegration, "addCheckboxVerifyOptOutForBlocks"], 10);
     543        add_action( "init", [$this->zboziServiceIntegration, "addCheckboxVerifyOptOutForBlocks"], 10);
     544        add_action("init", [$this->bianoStarServiceIntegration, "addCheckboxVerifyOptOutForBlocks"], 10);
     545
     546        add_action("init", [$this->arukeresoServiceIntegration, "addCheckboxVerifyOptOutForBlocks"], 10);
     547        add_action("init", [$this->compariServiceIntegration, "addCheckboxVerifyOptOutForBlocks"], 10);
     548        add_action("init", [$this->pazaruvajServiceIntegration, "addCheckboxVerifyOptOutForBlocks"], 10);
     549
    548550        //add_action('woocommerce_after_single_product', [$this, 'adWordsRemarketingProduct'], 99); TODO: delete function in future
    549551        //add_action('woocommerce_after_cart', [$this, 'adsRemarketingCart'], 99); TODO: delete function in future
  • mergado-marketing-pack/trunk/mergado-marketing-pack.php

    r3327281 r3443312  
    1717 * Plugin URI:        https://www.mergado.cz
    1818 * Description:       Earn more on price comparator sites. <strong>REQUIRES: Woocommerce</strong>
    19  * Version:           4.2.0
     19 * Version:           4.2.1
    2020 * Author:            Mergado technologies, s. r. o.
    2121 * Author URI:        https://www.mergado.cz
     
    2626 *
    2727 * WC requires at least: 3.0
    28  * WC tested up to: 9.8.5
     28 * WC tested up to: 10.4.3
    2929 */
    3030
     
    4646}
    4747
    48 define('PLUGIN_VERSION', '4.2.0');
     48define('PLUGIN_VERSION', '4.2.1');
    4949define( '__MERGADO_DIR__', plugin_dir_path( __FILE__ ) );
    5050define( '__MERGADO_BASE_FILE__', plugin_dir_path( __FILE__ ) . 'mergado-marketing-pack.php' );
  • mergado-marketing-pack/trunk/src/Service/Ean/Plugins/DefaultWoocommerceGtin.php

    r3267637 r3443312  
    2121    public function isActive(): bool
    2222    {
    23         return true;
     23        if ( defined('WOOCOMMERCE_VERSION') ) {
     24            return version_compare(WOOCOMMERCE_VERSION, '9.2', '>=');
     25        }
     26
     27        return false; // WooCommerce not active
    2428    }
    2529
     
    4145        return [
    4246            'active' => $this->isActive(),
    43             'name' => __('Default woocommerce product field - GTIN, UPC, EAN, or ISBN', 'mergado-marketing-pack'),
     47            'name' => __('Default woocommerce product field - GTIN, UPC, EAN, or ISBN ( Woocommerce version 9.2+ )', 'mergado-marketing-pack'),
    4448            'hasFields' => $this->getPluginDataForSubselect()
    4549        ];
  • mergado-marketing-pack/trunk/src/Service/External/ArukeresoFamily/AbstractArukeresoFamilyServiceIntegration.php

    r3267637 r3443312  
    99use Mergado\Service\External\HeurekaGroup\AbstractHeurekaGroupServiceIntegration;
    1010use Mergado\Service\LogService;
     11use Mergado\Service\OptOutService;
    1112use Mergado\Utils\TemplateLoader;
    1213use Throwable;
     
    1415abstract class AbstractArukeresoFamilyServiceIntegration extends AbstractHeurekaGroupServiceIntegration
    1516{
     17    /**
     18     * @var ArukeresoService|PazaruvajService|CompariService
     19     */
    1620    private $service;
    1721
     
    2125    private $logger;
    2226
     27    /**
     28     * @var OptOutService
     29     */
     30    private $optOutService;
     31
    2332    public function __construct($service)
    2433    {
    2534        $this->service = $service;
     35        $this->optOutService = OptOutService::getInstance();
    2636        $this->logger = LogService::getInstance();
    2737
     
    3242    public function setOrderMetaData($orderId): void
    3343    {
     44        $this->optOutService->saveOrderMeta($orderId, $this->service::FRONTEND_CHECKBOX);
     45    }
     46
     47    public function addCheckboxVerifyOptOut(): void
     48    {
    3449        try {
    35             if (isset($_POST[$this->service::FRONTEND_CHECKBOX]) && $_POST[$this->service::FRONTEND_CHECKBOX]) {
    36                 $order = wc_get_order($orderId);
    37                 $order->update_meta_data($this->service::FRONTEND_CHECKBOX, esc_attr($_POST[$this->service::FRONTEND_CHECKBOX]));
    38                 $order->save();
     50            if ($this->service->isActive()) {
     51                $this->optOutService->renderCheckbox(
     52                    $this->service::FRONTEND_CHECKBOX,
     53                    $this->getCheckboxText(),
     54                    [$this->service::FRONTEND_CHECKBOX]
     55                );
    3956            }
    4057        } catch (Throwable $e) {
     
    4360    }
    4461
    45     public function addCheckboxVerifyOptOut(): void
     62    /**
     63     * Register checkbox for block checkout (WC 8.9+)
     64     * Should be called in 'init' hook
     65     */
     66    public function addCheckboxVerifyOptOutForBlocks(): void
    4667    {
    4768        try {
    4869            if ($this->service->isActive()) {
    49                 $lang = get_locale();
    50                 $defaultText = stripslashes($this->service->getOptOut('en_US'));
    51                 $checkboxText = stripslashes($this->service->getOptOut($lang));
    52 
    53                 if ($checkboxText === 0 || trim($checkboxText) === '') {
    54                     $checkboxText = $defaultText;
    55                 }
    56 
    57                 if ($checkboxText === 0 || trim($checkboxText) === '') {
    58                     $checkboxText = $this->service::DEFAULT_OPT;
    59                 }
    60 
    61                 woocommerce_form_field($this->service::FRONTEND_CHECKBOX, array( // CSS ID
    62                     'type' => 'checkbox',
    63                     'class' => array('form-row', $this->service::FRONTEND_CHECKBOX), // CSS Class
    64                     'label_class' => array('woocommerce-form__label woocommerce-form__label-for-checkbox checkbox'),
    65                     'input_class' => array('woocommerce-form__input woocommerce-form__input-checkbox input-checkbox'),
    66                     'required' => false, // Mandatory or Optional
    67                     'label' => $checkboxText,
    68                 ));
     70                $this->optOutService->registerBlockCheckbox(
     71                    $this->service::FRONTEND_CHECKBOX,
     72                    $this->getCheckboxText()
     73                );
    6974            }
    7075        } catch (Throwable $e) {
    7176            $this->logger->error($e->getMessage(), ['exception' => $e]);
    7277        }
     78    }
     79
     80    protected function getCheckboxText()
     81    {
     82        $lang = get_locale();
     83
     84        $defaultText = stripslashes($this->service->getOptOut('en_US'));
     85        $checkboxText = stripslashes($this->service->getOptOut($lang));
     86
     87        if ($checkboxText === 0 || trim($checkboxText) === '') {
     88            $checkboxText = $defaultText;
     89        }
     90
     91        if ($checkboxText === 0 || trim($checkboxText) === '') {
     92            $checkboxText = $this->service::DEFAULT_OPT;
     93        }
     94
     95        return $checkboxText;
    7396    }
    7497
     
    106129        try {
    107130            $order = wc_get_order($orderId);
    108             $confirmed = $order->get_meta($this->service::FRONTEND_CHECKBOX, true);
    109131
    110             if (empty($confirmed) && $this->service->isActive()) {
     132            $isOptedOut = $this->optOutService->isOptedOut($order, $this->service::FRONTEND_CHECKBOX);
     133
     134            if (!$isOptedOut && $this->service->isActive()) {
    111135                $products = [];
    112136
  • mergado-marketing-pack/trunk/src/Service/External/Biano/BianoService.php

    r3327281 r3443312  
    2727    public const ACTIVE_LANG = 'biano-form-active-lang';
    2828    public const LANGUAGES = [
    29         'CZ' => 'cz',
    30         'SK' => 'sk',
    31         'RO' => 'ro',
    32         'NL' => 'nl',
    33         'HU' => 'hu',
    34         'BG' => 'bg',
    35         'GR' => 'gr',
    36         'PL' => 'com/pl',
    37         'IT' => 'it',
    38         'PT' => 'pt',
     29        'CZ' => [
     30            'domain' => 'cz',
     31            'language_code' => 'cs'
     32        ],
     33        'SK' => [
     34            'domain' => 'sk',
     35            'language_code' => 'sk'
     36        ],
     37        'RO' => [
     38            'domain' => 'ro',
     39            'language_code' => 'ro'
     40        ],
     41        'NL' => [
     42            'domain' => 'nl',
     43            'language_code' => 'nl'
     44        ],
     45        'HU' => [
     46            'domain' => 'hu',
     47            'language_code' => 'hu'
     48        ],
     49        'BG' => [
     50            'domain' => 'bg',
     51            'language_code' => 'bg'
     52        ],
     53        'GR' => [
     54            'domain' => 'gr',
     55            'language_code' => 'el'
     56        ],
     57        'PL' => [
     58            'domain' => 'com/pl',
     59            'language_code' => 'pl'
     60        ],
     61        'IT' => [
     62            'domain' => 'it',
     63            'language_code' => 'it'
     64        ],
     65        'PT' => [
     66            'domain' => 'pt',
     67            'language_code' => 'pt'
     68        ],
    3969    ];
     70
    4071    public const CONVERSION_VAT_INCL = 'biano-vat-included';
    4172    public const COMPOSITE_ID_ENABLED = 'mmp-biano-composite-id-enabled';
     
    4576     ******************************************************************************************************************/
    4677
    47     public function isActive($lang): bool
     78    public function isActive(string $langIso): bool
    4879    {
    4980        $active = $this->getActive();
    50         $merchantId = $this->getMerchantId($lang);
    51         $activeLanguage = $this->getActiveLang($lang);
     81        $merchantId = $this->getMerchantId($langIso);
     82        $activeLanguage = $this->getActiveLang($langIso);
    5283
    5384        return $active === 1 && $merchantId && $merchantId !== '' && $activeLanguage === 1;
     
    73104    }
    74105
    75     public function getActiveLang(string $lang): int
     106    public function getActiveLang(string $langIso): int
    76107    {
    77         if ('' === trim($lang)) {
     108        if ('' === trim($langIso)) {
    78109            return 0;
    79110        }
    80111
    81         return (int)get_option(self::getActiveLangName($lang), 0);
     112        return (int)get_option(self::getActiveLangName($langIso), 0);
    82113    }
    83114
    84     public function getMerchantId(string $lang): string
     115    public function getMerchantId(string $langIso): string
    85116    {
    86         if ('' === trim($lang)) {
     117        if ('' === trim($langIso)) {
    87118            return '';
    88119        }
    89120
    90         return get_option(self::getMerchantIdName($lang), '');
     121        return get_option(self::getMerchantIdName($langIso), '');
    91122    }
    92123
     
    102133
    103134    /*******************************************************************************************************************
    104      * GET NAMES
     135     * HELPERS
    105136     ******************************************************************************************************************/
    106137
    107     public static function getMerchantIdName(string $lang): string
     138    public static function getMerchantIdName(string $langKey): string
    108139    {
    109         return self::MERCHANT_ID . '-' . $lang;
     140        return self::MERCHANT_ID . '-' . $langKey;
    110141    }
    111142
    112     public static function getActiveLangName(string $lang): string
     143    public static function getActiveLangName(string $langKey): string
    113144    {
    114         return self::ACTIVE_LANG . '-' . $lang;
     145        return self::ACTIVE_LANG . '-' . $langKey;
    115146    }
     147
     148    public static function getDomainByLangIso(string $langIso): ?string
     149    {
     150        foreach(self::LANGUAGES as $key => $item) {
     151            if (strtoupper($item['language_code']) === strtoupper($langIso)) {
     152                return $item['domain'];
     153            }
     154        }
     155
     156        return null;
     157    }
     158
    116159
    117160    /*******************************************************************************************************************
     
    125168
    126169        foreach (self::LANGUAGES as $key => $item) {
    127             $inputs[] = self::getMerchantIdName($key);
    128             $checkboxes[] = self::getActiveLangName($key);
     170            $inputs[] = self::getMerchantIdName($item['language_code']);
     171            $checkboxes[] = self::getActiveLangName($item['language_code']);
    129172        }
    130173
  • mergado-marketing-pack/trunk/src/Service/External/Biano/BianoServiceIntegration.php

    r3327281 r3443312  
    4141    {
    4242        $this->bianoService = BianoService::getInstance();
    43         $this->lang = LanguageHelper::getLang();
     43        $this->lang = LanguageHelper::getLangIso();
    4444        $this->cookieService = CookieService::getInstance();
    4545        $this->logger = LogService::getInstance();
     
    4949    {
    5050        try {
     51
    5152            if(!$this->bianoService->isActive($this->lang)) {
    5253                return;
     
    5455
    5556            $templatePathDefault = __DIR__ . '/templates/initDefault.php';
    56             $templatePathFallback = __DIR__ . '/templates/iInitFallback.php';
    5757
    5858            $merchantId = $this->bianoService->getMerchantId($this->lang);
    5959
    60             // Default solution
    61             if (array_key_exists($this->lang, BianoService::LANGUAGES)) {
    62 
    63                 $templateVariables = [
    64                     'merchantId' => $merchantId,
    65                     'consent' => $this->cookieService->advertisementEnabled() ? 'true' : 'false',
    66                     'domain' => BianoService::LANGUAGES[$this->lang]
    67                 ];
    68 
    69                 echo TemplateLoader::getTemplate($templatePathDefault, $templateVariables);
    70 
    71                 // Fallback solution for other languages
    72             } else {
    73                 echo TemplateLoader::getTemplate($templatePathFallback, []);
    74             }
     60            $templateVariables = [
     61                'merchantId' => $merchantId,
     62                'consent' => $this->cookieService->advertisementEnabled() ? 'true' : 'false',
     63                'domain' => BianoService::getDomainByLangIso($this->lang)
     64            ];
     65
     66            echo TemplateLoader::getTemplate($templatePathDefault, $templateVariables);
    7567            ?>
    7668
  • mergado-marketing-pack/trunk/src/Service/External/Biano/BianoStarService.php

    r2998630 r3443312  
    4242     * Check of Biano activation is omitted because this function is used only inside Biano call.
    4343     */
    44     public function isActive(string $lang): bool
     44    public function isActive(string $langIso): bool
    4545    {
    4646        $active = $this->getActive();
    4747        $bianoService = BianoService::getInstance();
    4848
    49         return $active === 1 && $bianoService->isActive($lang);
     49        return $active === 1 && $bianoService->isActive($langIso);
    5050    }
    5151
  • mergado-marketing-pack/trunk/src/Service/External/Biano/BianoStarServiceIntegration.php

    r3192320 r3443312  
    55use Mergado\Helper\LanguageHelper;
    66use Mergado\Service\LogService;
     7use Mergado\Service\OptOutService;
    78use Mergado\Traits\SingletonTrait;
    89use Throwable;
     
    2829    private $lang;
    2930
     31    /**
     32     * @var OptOutService
     33     */
     34    private $optOutService;
     35
    3036    public const BIANO_STAR_CHECKBOX = 'mmp_order_biano_star_checkbox';
    3137
     
    3339    {
    3440        $this->bianoStarService = BianoStarService::getInstance();
    35         $this->lang = LanguageHelper::getLang();
     41        $this->lang = LanguageHelper::getLangIso();
    3642        $this->logger = LogService::getInstance();
     43        $this->optOutService = OptOutService::getInstance();
    3744    }
    3845
     
    4653        try {
    4754            if ($this->bianoStarService->isActive($this->lang)) {
    48                 $lang = get_locale();
    49                 $defaultText = stripslashes($this->bianoStarService->getOptOut('en_US'));
    50                 $checkboxText = stripslashes($this->bianoStarService->getOptOut($lang));
    51 
    52                 if (trim($checkboxText) === '') {
    53                     $checkboxText = $defaultText;
    54                 }
    55 
    56                 if (trim($checkboxText) === '') {
    57                     $checkboxText = BianoStarService::DEFAULT_OPT;
    58                 }
    59 
    60                 woocommerce_form_field(self::BIANO_STAR_CHECKBOX, array( // CSS ID
    61                     'type' => 'checkbox',
    62                     'class' => array('form-row' . ' ' . self::BIANO_STAR_CHECKBOX), // CSS Class
    63                     'label_class' => array('woocommerce-form__label woocommerce-form__label-for-checkbox checkbox'),
    64                     'input_class' => array('woocommerce-form__input woocommerce-form__input-checkbox input-checkbox'),
    65                     'required' => false, // Mandatory or Optional
    66                     'label' => $checkboxText,
    67                 ));
     55                $this->optOutService->renderCheckbox(self::BIANO_STAR_CHECKBOX, $this->getCheckboxText(), [self::BIANO_STAR_CHECKBOX]);
    6856            }
    6957        } catch (Throwable $e) {
     
    7260    }
    7361
    74     public function setOrderMeta($orderId): void
     62    public function addCheckboxVerifyOptOutForBlocks(): void
    7563    {
    7664        try {
    77             // Set to order meta if user want zbozi review email
    78             if (isset($_POST[self::BIANO_STAR_CHECKBOX]) && $_POST[self::BIANO_STAR_CHECKBOX]) {
    79                 $order = wc_get_order($orderId);
    80                 $order->update_meta_data(self::BIANO_STAR_CHECKBOX, esc_attr($_POST[self::BIANO_STAR_CHECKBOX]));
    81                 $order->save();
     65            if ($this->bianoStarService->isActive($this->lang)) {
     66                $this->optOutService->registerBlockCheckbox(
     67                    self::BIANO_STAR_CHECKBOX,
     68                    $this->getCheckboxText()
     69                );
    8270            }
    8371        } catch (Throwable $e) {
     
    8674    }
    8775
     76    private function getCheckboxText(): string
     77    {
     78        $lang = get_locale();
     79
     80        $defaultText = stripslashes($this->bianoStarService->getOptOut('en_US'));
     81        $checkboxText = stripslashes($this->bianoStarService->getOptOut($lang));
     82
     83        if (trim($checkboxText) === '') {
     84            $checkboxText = $defaultText;
     85        }
     86
     87        if (trim($checkboxText) === '') {
     88            $checkboxText = BianoStarService::DEFAULT_OPT;
     89        }
     90
     91        return $checkboxText;
     92    }
     93
     94    public function setOrderMeta($orderId): void
     95    {
     96        $this->optOutService->saveOrderMeta($orderId, self::BIANO_STAR_CHECKBOX);
     97    }
     98
    8899    public function shouldBeSent($orderId): bool
    89100    {
    90101        if ($this->bianoStarService->isActive($this->lang)) {
     102
    91103            $order = wc_get_order($orderId);
    92             $confirmed = $order->get_meta(self::BIANO_STAR_CHECKBOX, true);
    93 
    94             if (empty($confirmed)) {
    95                 return true;
    96             }
     104            return !$this->optOutService->isOptedOut($order, self::BIANO_STAR_CHECKBOX);
    97105        }
    98106
  • mergado-marketing-pack/trunk/src/Service/External/Google/GoogleAnalytics/GA4/Ga4ServiceIntegration.php

    r3192320 r3443312  
    890890    }
    891891
    892     public function actionShippingRate($method): void
    893     {
    894         try {
    895             if (!$this->ga4Service->isActiveEcommerce()) {
    896                 return;
    897             }
    898 
    899             echo sprintf('<div class="mergado-shipping-rate-label" style="display: none !important;">%s</div>', $method->get_label());
    900         } catch (Throwable $e) {
    901             $this->logger->error($e->getMessage(), ['exception' => $e]);
    902         }
    903     }
    904 
    905892    private function getShippingMethods(): array
    906893    {
  • mergado-marketing-pack/trunk/src/Service/External/Heureka/HeurekaServiceIntegration.php

    r3267637 r3443312  
    2222use Mergado\Service\External\HeurekaGroup\AbstractHeurekaGroupServiceIntegration;
    2323use Mergado\Service\LogService;
     24use Mergado\Service\OptOutService;
    2425use Mergado\Traits\SingletonTrait;
    2526use Mergado\Utils\TemplateLoader;
     
    4243     */
    4344    private $logger;
     45
     46    private const VERIFY_OPT_OUT_CHECKBOX_ID = 'heureka-verify-checkbox';
     47
     48    /**
     49     * @var OptOutService
     50     */
     51    private $optOutService;
    4452
    4553    public function __construct()
     
    4957        $this->cookieService = CookieService::getInstance();
    5058        $this->logger = LogService::getInstance();
     59        $this->optOutService = OptOutService::getInstance();
    5160
    5261        parent::__construct($this->getActiveService(), $this->logger);
     
    105114        try {
    106115            $order = wc_get_order($orderId);
    107             $confirmed = $order->get_meta('heureka-verify-checkbox', true);
    108 
    109             if (empty($confirmed)) {
     116
     117            $isOptedOut = $this->optOutService->isOptedOut($order, self::VERIFY_OPT_OUT_CHECKBOX_ID);
     118
     119            if (!$isOptedOut) {
    110120                $service = $this->getActiveService();
    111121
    112122                if ($service && $service->isVerifiedActive()) {
    113                     $url = $this->getRequestURL($service->getUrl(),$service->getVerifiedCode(), $orderId);
     123                    $url = $this->getRequestURL($service->getUrl(), $service->getVerifiedCode(), $orderId);
    114124                    $this->sendRequest($url);
    115125                }
     
    244254
    245255            if ($service && $service->isVerifiedActive()) {
    246                 $lang = get_locale();
    247 
    248                 $defaultText = stripslashes(get_option('heureka-verify-opt-out-text-en_US', 0));
    249                 $checkboxText = stripslashes(get_option('heureka-verify-opt-out-text-' . $lang, 0));
    250 
    251                 if ($checkboxText === 0 || trim($checkboxText) === '') {
    252                     $checkboxText = $defaultText;
    253                 }
    254 
    255                 if ($checkboxText === 0 || trim($checkboxText) === '') {
    256                     $checkboxText = AbstractBaseHeurekaService::DEFAULT_OPT;
    257                 }
    258 
    259                 woocommerce_form_field('heureka-verify-checkbox', array( // CSS ID
    260                     'type' => 'checkbox',
    261                     'class' => array('form-row heureka-verify-checkbox'), // CSS Class
    262                     'label_class' => array('woocommerce-form__label woocommerce-form__label-for-checkbox checkbox'),
    263                     'input_class' => array('woocommerce-form__input woocommerce-form__input-checkbox input-checkbox'),
    264                     'required' => false, // Mandatory or Optional
    265                     'label' => $checkboxText,
    266                 ));
     256                $this->optOutService->renderCheckbox(
     257                    self::VERIFY_OPT_OUT_CHECKBOX_ID,
     258                    $this->getCheckboxText(),
     259                    ['heureka-verify-checkbox']
     260                );
     261            }
     262        } catch (Throwable $e) {
     263            $this->logger->error($e->getMessage(), ['exception' => $e]);
     264        }
     265    }
     266
     267    /**
     268     * Register checkbox for block checkout (WC 8.9+)
     269     * Should be called in 'init' hook
     270     */
     271    public function addCheckboxVerifyOptOutForBlocks(): void
     272    {
     273        try {
     274            $service = $this->getActiveService();
     275
     276            if ($service && $service->isVerifiedActive()) {
     277                $this->optOutService->registerBlockCheckbox(
     278                    self::VERIFY_OPT_OUT_CHECKBOX_ID,
     279                    $this->getCheckboxText()
     280                );
    267281            }
    268282        } catch (Throwable $e) {
     
    276290    public function setOrderMetaData($orderId): void
    277291    {
    278         try {
    279             if (isset($_POST['heureka-verify-checkbox']) && $_POST['heureka-verify-checkbox']) {
    280                 $order = wc_get_order($orderId);
    281                 $order->update_meta_data('heureka-verify-checkbox', esc_attr($_POST['heureka-verify-checkbox']));
    282                 $order->save();
    283             }
    284         } catch (Throwable $e) {
    285             $this->logger->error($e->getMessage(), ['exception' => $e]);
    286         }
     292        $this->optOutService->saveOrderMeta($orderId, self::VERIFY_OPT_OUT_CHECKBOX_ID);
     293    }
     294
     295    protected function getCheckboxText(): string
     296    {
     297        $lang = get_locale();
     298        $defaultText = stripslashes(get_option('heureka-verify-opt-out-text-en_US', 0));
     299        $checkboxText = stripslashes(get_option('heureka-verify-opt-out-text-' . $lang, 0));
     300
     301        if ($checkboxText === 0 || trim($checkboxText) === '') {
     302            $checkboxText = $defaultText;
     303        }
     304
     305        if ($checkboxText === 0 || trim($checkboxText) === '') {
     306            $checkboxText = AbstractBaseHeurekaService::DEFAULT_OPT;
     307        }
     308
     309        return $checkboxText;
    287310    }
    288311}
  • mergado-marketing-pack/trunk/src/Service/External/Zbozi/ZboziServiceIntegration.php

    r3192320 r3443312  
    1717namespace Mergado\Service\External\Zbozi;
    1818
    19 use Exception;
    20 use Mergado\Exception\ZboziException;
    21 use Mergado\Includes\Services\Zbozi\Zbozi;
    2219use Mergado\Service\CookieService;
    2320use Mergado\Service\LogService;
     21use Mergado\Service\OptOutService;
    2422use Mergado\Traits\SingletonTrait;
    2523use Mergado\Utils\TemplateLoader;
     
    3836
    3937    /**
     38     * @var OptOutService
     39     */
     40    private $optOutService;
     41
     42    /**
    4043     * @var LogService
    4144     */
    4245    private $logger;
     46
     47    private const VERIFY_CHECKBOX_FIELD_ID = 'zbozi-verify-checkbox';
    4348
    4449    public function __construct()
     
    4752        $this->cookieService = CookieService::getInstance();
    4853        $this->logger = LogService::getInstance();
    49     }
    50 
    51     // Set to order meta if user want zbozi review email
    52     public function setOrderMetaData($orderId): void
    53     {
    54         try {
    55             if (isset($_POST['zbozi-verify-checkbox']) && $_POST['zbozi-verify-checkbox']) {
    56                 $order = wc_get_order($orderId);
    57                 $order->update_meta_data('zbozi-verify-checkbox', esc_attr($_POST['zbozi-verify-checkbox']));
    58                 $order->save();
    59             }
    60         } catch (Throwable $e) {
    61             $this->logger->error($e->getMessage(), ['exception' => $e]);
    62         }
    63     }
    64 
    65     /**
    66      * Add opt-out checkbox to checkout
     54        $this->optOutService = OptOutService::getInstance();
     55    }
     56
     57    /**
     58     * Add an opt-out checkbox to checkout
    6759     *
    6860     * @return void
     
    7264        try {
    7365            if ($this->zboziService->isActive()) {
    74                 $lang = get_locale();
    75 
    76                 $defaultText = stripslashes($this->zboziService->getOptOut('en_US'));
    77                 $checkboxText = stripslashes($this->zboziService->getOptOut($lang));
    78 
    79                 if ($checkboxText === 0 || trim($checkboxText) === '') {
    80                     $checkboxText = $defaultText;
    81                 }
    82 
    83                 if ($checkboxText === 0 || trim($checkboxText) === '') {
    84                     $checkboxText = ZboziService::DEFAULT_OPT;
    85                 }
    86 
    87                 woocommerce_form_field('zbozi-verify-checkbox', array( // CSS ID
    88                     'type' => 'checkbox',
    89                     'class' => array('form-row zbozi-verify-checkbox'), // CSS Class
    90                     'label_class' => array('woocommerce-form__label woocommerce-form__label-for-checkbox checkbox'),
    91                     'input_class' => array('woocommerce-form__input woocommerce-form__input-checkbox input-checkbox'),
    92                     'required' => false, // Mandatory or Optional
    93                     'label' => $checkboxText,
    94                 ));
    95             }
    96         } catch (Throwable $e) {
    97             $this->logger->error($e->getMessage(), ['exception' => $e]);
    98         }
     66                $this->optOutService->renderCheckbox(
     67                    self::VERIFY_CHECKBOX_FIELD_ID,
     68                    $this->getCheckboxText(),
     69                    [self::VERIFY_CHECKBOX_FIELD_ID]
     70                );
     71            }
     72        } catch (Throwable $e) {
     73            $this->logger->error($e->getMessage(), ['exception' => $e]);
     74        }
     75    }
     76
     77    public function addCheckboxVerifyOptOutForBlocks(): void
     78    {
     79        try {
     80            if ($this->zboziService->isActive()) {
     81                $this->optOutService->registerBlockCheckbox(
     82                    self::VERIFY_CHECKBOX_FIELD_ID,
     83                    $this->getCheckboxText()
     84                );
     85            }
     86        } catch (Throwable $e) {
     87            $this->logger->error($e->getMessage(), ['exception' => $e]);
     88        }
     89    }
     90
     91    private function getCheckboxText(): string
     92    {
     93        $lang = get_locale();
     94
     95        $defaultText = stripslashes($this->zboziService->getOptOut('en_US'));
     96        $checkboxText = stripslashes($this->zboziService->getOptOut($lang));
     97
     98        if ($checkboxText === 0 || trim($checkboxText) === '') {
     99            $checkboxText = $defaultText;
     100        }
     101
     102        if ($checkboxText === 0 || trim($checkboxText) === '') {
     103            $checkboxText = ZboziService::DEFAULT_OPT;
     104        }
     105
     106        return $checkboxText;
     107    }
     108
     109    public function setOrderMetaData($orderId): void
     110    {
     111        $this->optOutService->saveOrderMeta($orderId, self::VERIFY_CHECKBOX_FIELD_ID);
    99112    }
    100113
     
    129142        try {
    130143            $order = wc_get_order($orderId);
    131             $confirmed = $order->get_meta('zbozi-verify-checkbox', true);
    132144
    133145            $id = $this->zboziService->getId();
     
    137149            if ($this->zboziService->isActive()) {
    138150                if ($this->zboziService->isAdvanced()) {
     151                    $isOptedOut = $this->optOutService->isOptedOut($order, self::VERIFY_CHECKBOX_FIELD_ID);
     152
    139153                    // Extended process
    140154                    $zbozi = new \Mergado\Service\External\Zbozi\Zbozi($id, $secret);
     
    179193                    ];
    180194
    181                     if (empty($confirmed)) {
     195                    if (!$isOptedOut) {
    182196                        $zboziOrderData['email'] = $order->get_billing_email();
    183197                    }
     
    190204
    191205                    $zbozi->setOrder($zboziOrderData);
    192 
    193206                    $zbozi->send();
    194207
  • mergado-marketing-pack/trunk/src/Service/MigrationService.php

    r3185508 r3443312  
    5151        MigrationUtils::migrateOnExactOrLowerVersionAndSkipNewInstallations('4.0.0', $initialDbVersion, null,true);
    5252        MigrationUtils::migrateAlways('4.0.0', 'v4.0.0_a');
     53        MigrationUtils::migrateAlways('4.2.1', 'v4.2.1');
    5354    }
    5455}
Note: See TracChangeset for help on using the changeset viewer.