Changeset 3443312
- Timestamp:
- 01/20/2026 01:50:47 PM (2 months ago)
- Location:
- mergado-marketing-pack/trunk
- Files:
-
- 3 added
- 15 edited
-
README.txt (modified) (3 diffs)
-
admin/js/mergado-marketing-pack-admin-wizard.js (modified) (2 diffs)
-
admin/templates/partials/tabs-adsys/adsys-biano.php (modified) (4 diffs)
-
includes/class-mergado-marketing-pack.php (modified) (3 diffs)
-
mergado-marketing-pack.php (modified) (3 diffs)
-
migrations/v4.2.1.php (added)
-
src/Helper/BlockFieldHelper.php (added)
-
src/Service/Ean/Plugins/DefaultWoocommerceGtin.php (modified) (2 diffs)
-
src/Service/External/ArukeresoFamily/AbstractArukeresoFamilyServiceIntegration.php (modified) (6 diffs)
-
src/Service/External/Biano/BianoService.php (modified) (5 diffs)
-
src/Service/External/Biano/BianoServiceIntegration.php (modified) (3 diffs)
-
src/Service/External/Biano/BianoStarService.php (modified) (1 diff)
-
src/Service/External/Biano/BianoStarServiceIntegration.php (modified) (6 diffs)
-
src/Service/External/Google/GoogleAnalytics/GA4/Ga4ServiceIntegration.php (modified) (1 diff)
-
src/Service/External/Heureka/HeurekaServiceIntegration.php (modified) (6 diffs)
-
src/Service/External/Zbozi/ZboziServiceIntegration.php (modified) (8 diffs)
-
src/Service/MigrationService.php (modified) (1 diff)
-
src/Service/OptOutService.php (added)
Legend:
- Unmodified
- Added
- Removed
-
mergado-marketing-pack/trunk/README.txt
r3327281 r3443312 1 1 === Mergado Pack === 2 Stable tag: 4.2. 02 Stable tag: 4.2.1 3 3 Contributors: mergado 4 4 Donate link: https://pack.mergado.com/woocommerce 5 5 Tags: woocommerce, marketing, xml, export, feed 6 6 Requires at least: 4.5.1 7 Tested up to: 6. 87 Tested up to: 6.9 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 269 269 == Changelog == 270 270 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 271 277 = 4.2.0 = 272 278 * NEW: Product feed - Brand element implemented … … 760 766 * First plugin version 761 767 * Another change. 762 763 764 -
mergado-marketing-pack/trunk/admin/js/mergado-marketing-pack-admin-wizard.js
r2909979 r3443312 14 14 15 15 if (actionToDo === 'mmpSaveWpCron') { 16 mmpWizard.saveWpCron(feedType);16 await mmpWizard.saveWpCron(feedType); 17 17 } else if (actionToDo === 'mmpSaveWpCronAndGo') { 18 18 var result = mmpWizard.setWizardCompleted(feedType); 19 19 20 20 if (result) { 21 mmpWizard.saveWpCron(feedType);21 await mmpWizard.saveWpCron(feedType); 22 22 window.location.href = $($this).attr('data-go-to-link'); 23 23 } … … 79 79 } 80 80 , 81 saveWpCron: function(feedType) {81 saveWpCron: async function(feedType) { 82 82 var tab4a = this.getWizardStep4a(feedType); 83 83 -
mergado-marketing-pack/trunk/admin/templates/partials/tabs-adsys/adsys-biano.php
r3327281 r3443312 28 28 29 29 <?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']); 33 36 ?> 34 37 … … 36 39 <th> 37 40 <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; ?> 39 42 </label> 40 43 </th> … … 43 46 id="<?php echo $activeLangName; ?>" 44 47 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; ?>" 46 49 data-mmp-check-field="<?php echo BianoService::ACTIVE ?>" 47 <?php if ($ bianoService->getActiveLang($lang)=== 1) { ?>50 <?php if ($isLangActive === 1) { ?> 48 51 checked="checked" 49 52 <?php } ?>> … … 52 55 id="<?php echo $activeMerchantId; ?>" 53 56 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; ?>" 55 58 placeholder="<?php echo __('Insert code here', 'mergado-marketing-pack') ?>" 56 value="<?php echo $ bianoService->getMerchantId($lang); ?>">59 value="<?php echo $merchantId; ?>"> 57 60 </td> 58 61 </tr> -
mergado-marketing-pack/trunk/includes/class-mergado-marketing-pack.php
r3267637 r3443312 459 459 }, 99); 460 460 461 /**462 * ANALYTICS463 */464 465 // GTAG466 add_action( 'woocommerce_after_shipping_rate', [$this->ga4ServiceIntegration, "actionShippingRate"], 99);467 468 461 /** 469 462 * Cart/checkout page … … 532 525 add_action('admin_head', [$this->ga4ServiceIntegration, 'pushRefundEvent']); 533 526 534 //Checkout steps/options - checkbox s - not part of GDPR527 //Checkout steps/options - checkboxes - not part of GDPR 535 528 add_action("woocommerce_review_order_before_submit", [$this->heurekaServiceIntegration, "addVerifyOptOutCheckbox"], 10); 536 529 add_action("woocommerce_review_order_before_submit", [$this->zboziServiceIntegration, "addCheckboxVerifyOptIn"], 10); … … 546 539 add_action("woocommerce_checkout_update_order_meta", [$this->pazaruvajServiceIntegration, "setOrderMetaData"], 10); 547 540 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 548 550 //add_action('woocommerce_after_single_product', [$this, 'adWordsRemarketingProduct'], 99); TODO: delete function in future 549 551 //add_action('woocommerce_after_cart', [$this, 'adsRemarketingCart'], 99); TODO: delete function in future -
mergado-marketing-pack/trunk/mergado-marketing-pack.php
r3327281 r3443312 17 17 * Plugin URI: https://www.mergado.cz 18 18 * Description: Earn more on price comparator sites. <strong>REQUIRES: Woocommerce</strong> 19 * Version: 4.2. 019 * Version: 4.2.1 20 20 * Author: Mergado technologies, s. r. o. 21 21 * Author URI: https://www.mergado.cz … … 26 26 * 27 27 * WC requires at least: 3.0 28 * WC tested up to: 9.8.528 * WC tested up to: 10.4.3 29 29 */ 30 30 … … 46 46 } 47 47 48 define('PLUGIN_VERSION', '4.2. 0');48 define('PLUGIN_VERSION', '4.2.1'); 49 49 define( '__MERGADO_DIR__', plugin_dir_path( __FILE__ ) ); 50 50 define( '__MERGADO_BASE_FILE__', plugin_dir_path( __FILE__ ) . 'mergado-marketing-pack.php' ); -
mergado-marketing-pack/trunk/src/Service/Ean/Plugins/DefaultWoocommerceGtin.php
r3267637 r3443312 21 21 public function isActive(): bool 22 22 { 23 return true; 23 if ( defined('WOOCOMMERCE_VERSION') ) { 24 return version_compare(WOOCOMMERCE_VERSION, '9.2', '>='); 25 } 26 27 return false; // WooCommerce not active 24 28 } 25 29 … … 41 45 return [ 42 46 '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'), 44 48 'hasFields' => $this->getPluginDataForSubselect() 45 49 ]; -
mergado-marketing-pack/trunk/src/Service/External/ArukeresoFamily/AbstractArukeresoFamilyServiceIntegration.php
r3267637 r3443312 9 9 use Mergado\Service\External\HeurekaGroup\AbstractHeurekaGroupServiceIntegration; 10 10 use Mergado\Service\LogService; 11 use Mergado\Service\OptOutService; 11 12 use Mergado\Utils\TemplateLoader; 12 13 use Throwable; … … 14 15 abstract class AbstractArukeresoFamilyServiceIntegration extends AbstractHeurekaGroupServiceIntegration 15 16 { 17 /** 18 * @var ArukeresoService|PazaruvajService|CompariService 19 */ 16 20 private $service; 17 21 … … 21 25 private $logger; 22 26 27 /** 28 * @var OptOutService 29 */ 30 private $optOutService; 31 23 32 public function __construct($service) 24 33 { 25 34 $this->service = $service; 35 $this->optOutService = OptOutService::getInstance(); 26 36 $this->logger = LogService::getInstance(); 27 37 … … 32 42 public function setOrderMetaData($orderId): void 33 43 { 44 $this->optOutService->saveOrderMeta($orderId, $this->service::FRONTEND_CHECKBOX); 45 } 46 47 public function addCheckboxVerifyOptOut(): void 48 { 34 49 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 ); 39 56 } 40 57 } catch (Throwable $e) { … … 43 60 } 44 61 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 46 67 { 47 68 try { 48 69 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 ); 69 74 } 70 75 } catch (Throwable $e) { 71 76 $this->logger->error($e->getMessage(), ['exception' => $e]); 72 77 } 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; 73 96 } 74 97 … … 106 129 try { 107 130 $order = wc_get_order($orderId); 108 $confirmed = $order->get_meta($this->service::FRONTEND_CHECKBOX, true);109 131 110 if (empty($confirmed) && $this->service->isActive()) { 132 $isOptedOut = $this->optOutService->isOptedOut($order, $this->service::FRONTEND_CHECKBOX); 133 134 if (!$isOptedOut && $this->service->isActive()) { 111 135 $products = []; 112 136 -
mergado-marketing-pack/trunk/src/Service/External/Biano/BianoService.php
r3327281 r3443312 27 27 public const ACTIVE_LANG = 'biano-form-active-lang'; 28 28 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 ], 39 69 ]; 70 40 71 public const CONVERSION_VAT_INCL = 'biano-vat-included'; 41 72 public const COMPOSITE_ID_ENABLED = 'mmp-biano-composite-id-enabled'; … … 45 76 ******************************************************************************************************************/ 46 77 47 public function isActive( $lang): bool78 public function isActive(string $langIso): bool 48 79 { 49 80 $active = $this->getActive(); 50 $merchantId = $this->getMerchantId($lang );51 $activeLanguage = $this->getActiveLang($lang );81 $merchantId = $this->getMerchantId($langIso); 82 $activeLanguage = $this->getActiveLang($langIso); 52 83 53 84 return $active === 1 && $merchantId && $merchantId !== '' && $activeLanguage === 1; … … 73 104 } 74 105 75 public function getActiveLang(string $lang ): int106 public function getActiveLang(string $langIso): int 76 107 { 77 if ('' === trim($lang )) {108 if ('' === trim($langIso)) { 78 109 return 0; 79 110 } 80 111 81 return (int)get_option(self::getActiveLangName($lang ), 0);112 return (int)get_option(self::getActiveLangName($langIso), 0); 82 113 } 83 114 84 public function getMerchantId(string $lang ): string115 public function getMerchantId(string $langIso): string 85 116 { 86 if ('' === trim($lang )) {117 if ('' === trim($langIso)) { 87 118 return ''; 88 119 } 89 120 90 return get_option(self::getMerchantIdName($lang ), '');121 return get_option(self::getMerchantIdName($langIso), ''); 91 122 } 92 123 … … 102 133 103 134 /******************************************************************************************************************* 104 * GET NAMES135 * HELPERS 105 136 ******************************************************************************************************************/ 106 137 107 public static function getMerchantIdName(string $lang ): string138 public static function getMerchantIdName(string $langKey): string 108 139 { 109 return self::MERCHANT_ID . '-' . $lang ;140 return self::MERCHANT_ID . '-' . $langKey; 110 141 } 111 142 112 public static function getActiveLangName(string $lang ): string143 public static function getActiveLangName(string $langKey): string 113 144 { 114 return self::ACTIVE_LANG . '-' . $lang ;145 return self::ACTIVE_LANG . '-' . $langKey; 115 146 } 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 116 159 117 160 /******************************************************************************************************************* … … 125 168 126 169 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']); 129 172 } 130 173 -
mergado-marketing-pack/trunk/src/Service/External/Biano/BianoServiceIntegration.php
r3327281 r3443312 41 41 { 42 42 $this->bianoService = BianoService::getInstance(); 43 $this->lang = LanguageHelper::getLang ();43 $this->lang = LanguageHelper::getLangIso(); 44 44 $this->cookieService = CookieService::getInstance(); 45 45 $this->logger = LogService::getInstance(); … … 49 49 { 50 50 try { 51 51 52 if(!$this->bianoService->isActive($this->lang)) { 52 53 return; … … 54 55 55 56 $templatePathDefault = __DIR__ . '/templates/initDefault.php'; 56 $templatePathFallback = __DIR__ . '/templates/iInitFallback.php';57 57 58 58 $merchantId = $this->bianoService->getMerchantId($this->lang); 59 59 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); 75 67 ?> 76 68 -
mergado-marketing-pack/trunk/src/Service/External/Biano/BianoStarService.php
r2998630 r3443312 42 42 * Check of Biano activation is omitted because this function is used only inside Biano call. 43 43 */ 44 public function isActive(string $lang ): bool44 public function isActive(string $langIso): bool 45 45 { 46 46 $active = $this->getActive(); 47 47 $bianoService = BianoService::getInstance(); 48 48 49 return $active === 1 && $bianoService->isActive($lang );49 return $active === 1 && $bianoService->isActive($langIso); 50 50 } 51 51 -
mergado-marketing-pack/trunk/src/Service/External/Biano/BianoStarServiceIntegration.php
r3192320 r3443312 5 5 use Mergado\Helper\LanguageHelper; 6 6 use Mergado\Service\LogService; 7 use Mergado\Service\OptOutService; 7 8 use Mergado\Traits\SingletonTrait; 8 9 use Throwable; … … 28 29 private $lang; 29 30 31 /** 32 * @var OptOutService 33 */ 34 private $optOutService; 35 30 36 public const BIANO_STAR_CHECKBOX = 'mmp_order_biano_star_checkbox'; 31 37 … … 33 39 { 34 40 $this->bianoStarService = BianoStarService::getInstance(); 35 $this->lang = LanguageHelper::getLang ();41 $this->lang = LanguageHelper::getLangIso(); 36 42 $this->logger = LogService::getInstance(); 43 $this->optOutService = OptOutService::getInstance(); 37 44 } 38 45 … … 46 53 try { 47 54 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]); 68 56 } 69 57 } catch (Throwable $e) { … … 72 60 } 73 61 74 public function setOrderMeta($orderId): void62 public function addCheckboxVerifyOptOutForBlocks(): void 75 63 { 76 64 try { 77 // Set to order meta if user want zbozi review email78 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 ); 82 70 } 83 71 } catch (Throwable $e) { … … 86 74 } 87 75 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 88 99 public function shouldBeSent($orderId): bool 89 100 { 90 101 if ($this->bianoStarService->isActive($this->lang)) { 102 91 103 $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); 97 105 } 98 106 -
mergado-marketing-pack/trunk/src/Service/External/Google/GoogleAnalytics/GA4/Ga4ServiceIntegration.php
r3192320 r3443312 890 890 } 891 891 892 public function actionShippingRate($method): void893 {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 905 892 private function getShippingMethods(): array 906 893 { -
mergado-marketing-pack/trunk/src/Service/External/Heureka/HeurekaServiceIntegration.php
r3267637 r3443312 22 22 use Mergado\Service\External\HeurekaGroup\AbstractHeurekaGroupServiceIntegration; 23 23 use Mergado\Service\LogService; 24 use Mergado\Service\OptOutService; 24 25 use Mergado\Traits\SingletonTrait; 25 26 use Mergado\Utils\TemplateLoader; … … 42 43 */ 43 44 private $logger; 45 46 private const VERIFY_OPT_OUT_CHECKBOX_ID = 'heureka-verify-checkbox'; 47 48 /** 49 * @var OptOutService 50 */ 51 private $optOutService; 44 52 45 53 public function __construct() … … 49 57 $this->cookieService = CookieService::getInstance(); 50 58 $this->logger = LogService::getInstance(); 59 $this->optOutService = OptOutService::getInstance(); 51 60 52 61 parent::__construct($this->getActiveService(), $this->logger); … … 105 114 try { 106 115 $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) { 110 120 $service = $this->getActiveService(); 111 121 112 122 if ($service && $service->isVerifiedActive()) { 113 $url = $this->getRequestURL($service->getUrl(), $service->getVerifiedCode(), $orderId);123 $url = $this->getRequestURL($service->getUrl(), $service->getVerifiedCode(), $orderId); 114 124 $this->sendRequest($url); 115 125 } … … 244 254 245 255 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 ); 267 281 } 268 282 } catch (Throwable $e) { … … 276 290 public function setOrderMetaData($orderId): void 277 291 { 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; 287 310 } 288 311 } -
mergado-marketing-pack/trunk/src/Service/External/Zbozi/ZboziServiceIntegration.php
r3192320 r3443312 17 17 namespace Mergado\Service\External\Zbozi; 18 18 19 use Exception;20 use Mergado\Exception\ZboziException;21 use Mergado\Includes\Services\Zbozi\Zbozi;22 19 use Mergado\Service\CookieService; 23 20 use Mergado\Service\LogService; 21 use Mergado\Service\OptOutService; 24 22 use Mergado\Traits\SingletonTrait; 25 23 use Mergado\Utils\TemplateLoader; … … 38 36 39 37 /** 38 * @var OptOutService 39 */ 40 private $optOutService; 41 42 /** 40 43 * @var LogService 41 44 */ 42 45 private $logger; 46 47 private const VERIFY_CHECKBOX_FIELD_ID = 'zbozi-verify-checkbox'; 43 48 44 49 public function __construct() … … 47 52 $this->cookieService = CookieService::getInstance(); 48 53 $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 67 59 * 68 60 * @return void … … 72 64 try { 73 65 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); 99 112 } 100 113 … … 129 142 try { 130 143 $order = wc_get_order($orderId); 131 $confirmed = $order->get_meta('zbozi-verify-checkbox', true);132 144 133 145 $id = $this->zboziService->getId(); … … 137 149 if ($this->zboziService->isActive()) { 138 150 if ($this->zboziService->isAdvanced()) { 151 $isOptedOut = $this->optOutService->isOptedOut($order, self::VERIFY_CHECKBOX_FIELD_ID); 152 139 153 // Extended process 140 154 $zbozi = new \Mergado\Service\External\Zbozi\Zbozi($id, $secret); … … 179 193 ]; 180 194 181 if ( empty($confirmed)) {195 if (!$isOptedOut) { 182 196 $zboziOrderData['email'] = $order->get_billing_email(); 183 197 } … … 190 204 191 205 $zbozi->setOrder($zboziOrderData); 192 193 206 $zbozi->send(); 194 207 -
mergado-marketing-pack/trunk/src/Service/MigrationService.php
r3185508 r3443312 51 51 MigrationUtils::migrateOnExactOrLowerVersionAndSkipNewInstallations('4.0.0', $initialDbVersion, null,true); 52 52 MigrationUtils::migrateAlways('4.0.0', 'v4.0.0_a'); 53 MigrationUtils::migrateAlways('4.2.1', 'v4.2.1'); 53 54 } 54 55 }
Note: See TracChangeset
for help on using the changeset viewer.