From 382d25ce5596ea1e3011a1f8e3e9ace811c44af9 Mon Sep 17 00:00:00 2001 From: Uryvskiy Dima Date: Tue, 18 Jul 2023 18:13:07 +0300 Subject: [PATCH] ref #90632 Changed the logic of customer subscriptions to promotional newsletters --- CHANGELOG.md | 3 + VERSION | 2 +- resources/pot/retailcrm-es_ES.pot | 3 + resources/pot/retailcrm-ru_RU.pot | 3 + src/include/class-wc-retailcrm-base.php | 59 ++++++++++++++++++ src/include/class-wc-retailcrm-customers.php | 28 ++++++--- ...class-wc-retailcrm-wc-customer-builder.php | 8 ++- src/include/functions.php | 1 - src/languages/retailcrm-es_ES.mo | Bin 12036 -> 12190 bytes src/languages/retailcrm-ru_RU.mo | Bin 14840 -> 14984 bytes src/readme.txt | 5 +- src/retailcrm.php | 2 +- src/uninstall.php | 2 +- .../class-wc-retailcrm-test-case-helper.php | 3 + tests/test-wc-retailcrm-base.php | 14 +++++ tests/test-wc-retailcrm-customers.php | 3 + 16 files changed, 121 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b5af5b..6fed17c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2023-07-19 4.6.9 +* Changed the logic of customer subscriptions to promotional newsletters + ## 2023-06-27 4.6.8 * Added the ability to select CRM warehouses to synchronize the balance of offers diff --git a/VERSION b/VERSION index 45fc36e..a41324d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.6.8 \ No newline at end of file +4.6.9 \ No newline at end of file diff --git a/resources/pot/retailcrm-es_ES.pot b/resources/pot/retailcrm-es_ES.pot index 4d56e37..8e72c43 100644 --- a/resources/pot/retailcrm-es_ES.pot +++ b/resources/pot/retailcrm-es_ES.pot @@ -420,3 +420,6 @@ msgstr "Almacenes disponibles en CRM" msgid "Select warehouses to receive balances from CRM. To select several warehouses, hold down CTRL (for Windows and Linux) or ⌘ Command (for MacOS)" msgstr "Selecciona los almacenes para recibir el stock desde CRM. Para seleccionar varios mantén pulsado CTRL (para Windows y Linux) o ⌘ Command (para MacOS)" + +msgid "I agree to receive promotional newsletters" +msgstr "Estoy de acuerdo en recibir los boletines informativos" \ No newline at end of file diff --git a/resources/pot/retailcrm-ru_RU.pot b/resources/pot/retailcrm-ru_RU.pot index 4448b45..cbfb439 100644 --- a/resources/pot/retailcrm-ru_RU.pot +++ b/resources/pot/retailcrm-ru_RU.pot @@ -429,3 +429,6 @@ msgstr "Склады, доступные в CRM" msgid "Select warehouses to receive balances from CRM. To select several warehouses, hold down CTRL (for Windows and Linux) or ⌘ Command (for MacOS)" msgstr "Выберите склады для получения остатков из CRM. Для выбора нескольких складов зажмите CTRL (для Windows и Linux) или ⌘ Command (для MacOS)" + +msgid "I agree to receive promotional newsletters" +msgstr "Согласен на рекламно-информационные рассылки" diff --git a/src/include/class-wc-retailcrm-base.php b/src/include/class-wc-retailcrm-base.php index 6688077..78515be 100644 --- a/src/include/class-wc-retailcrm-base.php +++ b/src/include/class-wc-retailcrm-base.php @@ -99,6 +99,18 @@ if (!class_exists('WC_Retailcrm_Base')) { add_action('admin_enqueue_scripts', [$this, 'include_files_for_admin'], 101); add_action('woocommerce_new_order', [$this, 'create_order'], 11, 1); + // Subscribed hooks + add_action('register_form', [$this, 'subscribe_register_form'], 99); + add_action('woocommerce_register_form', [$this, 'subscribe_woocommerce_register_form'], 99); + + if (get_option('woocommerce_enable_signup_and_login_from_checkout') === static::YES) { + add_action( + 'woocommerce_before_checkout_registration_form', + [$this, 'subscribe_woocommerce_before_checkout_registration_form'], + 99 + ); + } + if ( !$this->get_option('deactivate_update_order') || $this->get_option('deactivate_update_order') == static::NO @@ -175,6 +187,34 @@ if (!class_exists('WC_Retailcrm_Base')) { return $settings; } + /** + * Displaying the checkbox in the WP registration form(wp-login.php). + * + */ + public function subscribe_register_form() + { + echo $this->getSubscribeCheckbox(); + } + + /** + * Displaying the checkbox in the WC registration form. + * + */ + public function subscribe_woocommerce_register_form() + { + echo $this->getSubscribeCheckbox(); + } + + /** + * Displaying the checkbox in the Checkout order form. + * + */ + public function subscribe_woocommerce_before_checkout_registration_form() + { + echo $this->getSubscribeCheckbox(); + } + + /** * If you change the time interval, need to clear the old cron tasks * @@ -356,6 +396,9 @@ if (!class_exists('WC_Retailcrm_Base')) { return; } + $post = $this->get_post_data(); + $this->customers->isSubscribed = !empty($post['subscribe']); + $this->customers->registerCustomer($customerId); } @@ -882,5 +925,21 @@ if (!class_exists('WC_Retailcrm_Base')) { 'default-crm-field#tags' => __('tags', 'retailcrm'), ]; } + + private function getSubscribeCheckbox() + { + $style = is_wplogin() + ? 'margin-left: 2em; display: block; position: relative; margin-top: -1.4em; line-height: 1.4em;' + : ''; + + return sprintf( + '
+ + +
', + $style, + __('I agree to receive promotional newsletters', 'retailcrm') + ); + } } } diff --git a/src/include/class-wc-retailcrm-customers.php b/src/include/class-wc-retailcrm-customers.php index c2927b9..0c0f87f 100644 --- a/src/include/class-wc-retailcrm-customers.php +++ b/src/include/class-wc-retailcrm-customers.php @@ -38,6 +38,9 @@ if (!class_exists('WC_Retailcrm_Customers')) : /**@var array */ private $customFields = []; + /**@var null */ + public $isSubscribed = null; + /** * WC_Retailcrm_Customers constructor. * @@ -95,6 +98,7 @@ if (!class_exists('WC_Retailcrm_Customers')) : if (!$this->retailcrm instanceof WC_Retailcrm_Proxy) { return null; } + $wcCustomer = new WC_Customer($customerId); $email = $wcCustomer->get_billing_email(); @@ -123,8 +127,8 @@ if (!class_exists('WC_Retailcrm_Customers')) : $builder = new WC_Retailcrm_WC_Customer_Builder(); $builder ->setWcCustomer($wcCustomer) - ->setPhones(isset($customer['phones']) ? $customer['phones'] : []) - ->setAddress(isset($customer['address']) ? $customer['address'] : false) + ->setPhones(!empty($customer['phones']) ? $customer['phones'] : []) + ->setAddress(!empty($customer['address']) ? $customer['address'] : false) ->build() ->getResult() ->save(); @@ -134,6 +138,11 @@ if (!class_exists('WC_Retailcrm_Customers')) : } else { $this->createCustomer($customerId); + $message = $this->isSubscribed + ? 'The client has agreed to receive promotional newsletter, email: ' + : 'The client refused to receive promotional newsletters, email: '; + + WC_Retailcrm_Logger::addCaller('subscribe', $message . $email); WC_Retailcrm_Logger::add('Customer was created, externalId: ' . $wcCustomer->get_id()); } } @@ -384,10 +393,6 @@ if (!class_exists('WC_Retailcrm_Customers')) : $firstName = $order->get_billing_first_name(); $lastName = $order->get_billing_last_name(); - if (empty($firstName)) { - $firstName = $customer->get_username(); - } - if (empty($email)) { $email = $order->get_billing_email(); } @@ -403,7 +408,7 @@ if (!class_exists('WC_Retailcrm_Customers')) : $customerData = [ 'createdAt' => $createdAt->date('Y-m-d H:i:s'), - 'firstName' => $firstName ? $firstName : $customer->get_username(), + 'firstName' => !empty($firstName) ? $firstName : $customer->get_username(), 'lastName' => $lastName, 'email' => $email, 'address' => $this->customer_address->build($customer, $order)->getData() @@ -413,6 +418,15 @@ if (!class_exists('WC_Retailcrm_Customers')) : $customerData['externalId'] = $customer->get_id(); } + // The guest client is unsubscribed by default + if ($customer->get_id() === 0 && $customer->get_date_created() === null) { + $customerData['subscribed'] = false; + } + + if ($this->isSubscribed !== null) { + $customerData['subscribed'] = $this->isSubscribed; + } + if (!empty($billingPhone)) { $customerData['phones'][] = [ 'number' => $billingPhone diff --git a/src/include/customer/woocommerce/class-wc-retailcrm-wc-customer-builder.php b/src/include/customer/woocommerce/class-wc-retailcrm-wc-customer-builder.php index a3052e5..6f8e824 100644 --- a/src/include/customer/woocommerce/class-wc-retailcrm-wc-customer-builder.php +++ b/src/include/customer/woocommerce/class-wc-retailcrm-wc-customer-builder.php @@ -144,7 +144,7 @@ class WC_Retailcrm_WC_Customer_Builder extends WC_Retailcrm_Abstract_Builder } /** - * Fill WC_Customer fields with customer data from retailCRM. + * Fill WC_Customer fields with customer data from RetailCRM. * If field is not present in retailCRM customer - it will remain unchanged. * * @return $this|\WC_Retailcrm_Builder_Interface @@ -152,11 +152,13 @@ class WC_Retailcrm_WC_Customer_Builder extends WC_Retailcrm_Abstract_Builder public function build() { $this->checkBuilderValidity(); - WC_Retailcrm_Logger::debug(__METHOD__, array('Building WC_Customer from data:', $this->data)); + + WC_Retailcrm_Logger::debug(__METHOD__, ['Building WC_Customer from data:', $this->data]); + $this->customer->set_first_name($this->dataValue('firstName', $this->customer->get_first_name())); $this->customer->set_last_name($this->dataValue('lastName', $this->customer->get_last_name())); $this->customer->set_billing_email($this->dataValue('email', $this->customer->get_billing_email())); - $phones = $this->dataValue('phones', array()); + $phones = $this->dataValue('phones', []); if ((is_array($phones) || $phones instanceof Countable) && count($phones) > 0) { $phoneData = reset($phones); diff --git a/src/include/functions.php b/src/include/functions.php index 893e2d7..b04493f 100644 --- a/src/include/functions.php +++ b/src/include/functions.php @@ -191,4 +191,3 @@ function writeBaseLogs($message) { WC_Retailcrm_Logger::addCaller(__METHOD__, $message); } - diff --git a/src/languages/retailcrm-es_ES.mo b/src/languages/retailcrm-es_ES.mo index 6da371735e1e701c967dd4904827215ee94b8e0e..1d0853ca465896b0306029a80ce08a13f06bc2d9 100644 GIT binary patch delta 3121 zcmY+^eQXp(7{~DkEH9-L+FB6Wf~(ltf=~nmDI!uR$V&l>r6^K*<(BrKy(@P|v50OF z(Mk;{BABvfU_Kh&&>gV)hZf*^>k1^)#~{_y+dEx3M>Vfc)%B4t?<$X5dL2h<_nJ z%i!W$F%QS%B+SJY9AM_zb}Bd1uouKZ|m>1=peee+4yw_izdx zMZIA^(s2jQ#SpH=VfY6slUa;j|L0&S{o8aZO4(MNgRi1Sd;$4c8oe=C%R`=FLs9J| zNRn)p-@XuaU%h|cibFYn4r}lrPR2aaG!3iKyOGLnDh%HCqi*;D3-AK!{~Qh@a0F`P zi%}`uilgu?)Bt}$-FFT(z<$}u_5vKk`55euA>`54luiDr+jDX0GccV6p*OF>XEBIcycbdHHnYDao|}U-SuyhRR)$&wRjBI%{mH*NTJASIff~pr zEXM748-9jL{b|(omvJ!mA>YGsI1a)^cssTrtJ`+r0z809c_xiiZ6WIVCXY&2D%()o z<$2T_zl2K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gp2KjOXPh~o`hGoZ&jD$*~asjl&_~x`O_iycXLw%hgMXwO%7p3Jc>#2B&K86FsYkQ zZIs3J?^iLq=2afeP0Unww~(?ZTbYcGW}cfvgD%UsfvcHzD`#8sN$E6ZD&{g@EM!LB z&TPB;nG`<6Ov%&Cns|-r=+8_CerN9APCq53v)00~%EMo!N$6bUsGq`~nd0+FE%pA^SbP9W9|F@|m zm9v=<+{L79HS^$eOvCRm_x-|*xXH-?wlGt7B-6lnrX!aznOecDod@gZ&+#DVZ?UDK zvRNgm{D)aILt1SuE@kHMea_?GJd9WCO)~N*kK{T|;dk_ka+n2l7SE(hsy(*Y&3D%1-+U5+>hzV zvCOWykX<>8nW}4+d^p+2^P^L0pEM?|yEzjk)XCsfcQnRQ|U@|zFX}FD9OVgSA7Syd!Mk}RV#k>kwF|M1_`rS&3g64Npni(BPFArTCLR% zx1pOjQ(RuVR9z#f&JfuF+3(9lvq(0t6Q_$2;u`UP$<(Hd6U#*gR!$H%ifePC+#+rk zyNNO4PLZjZBkmAaiUDG8F zAB$09p14({ED^KBB#|<>M!BHw;mm?d$&b$UA`36uGi9#0P-Gh(BP^$~pf-O0GC7$k zQjQY)iz|d5x^lZnxkOx=iZWXqTdmc8c=BVDl0DxbvXjmhR(N$AqWUjbOgT-oiT+8; WijJq6H+SiHqx(PIJO1dmzWG1sSpxI` diff --git a/src/languages/retailcrm-ru_RU.mo b/src/languages/retailcrm-ru_RU.mo index 3e7db14e5a85760c27f0f99f51c309b6f459dd16..60c038b836ae5be22e10d23bee012b32b4262d1c 100644 GIT binary patch delta 3107 zcmYk-3rv+|9LMp$C@P@n;htI?H3bzF@0mdgscB-Og7*vQ5djedyoAaDCGobJG3PR| zX|B1o6-rJ+pqknoZgtq2nbYjHHs^KLrp~OszjIzTU(WyiJn!?~p6CBO& Io$I|n zM|9e6YOns0hH6v~K0-C<1oE>cc75>@>iiv41OCHw>`gk< z!)2I+A7CDSi$gG(mnox*F^TuvN(yPX57mGla3hP_!(h6Sf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yxe;}@vc=PT5V z&!bX&9W^jNHi%Leij2jgP@6R!bzd>+E!v6;u?w}N!>CPq0hQU?sOLR#JgwB^;%Qul z8h{^nE47nQnTSWVr=v13AN3lRpi=2ZElm|_Z`7j(ydO1yw^8>WMLsch99zb*{--FY zqioWk*CG!!G8ZZXHK^CE0n@M#dBjdS?U!%`^*cBh3t5jkY(+i)z2hyML;WAr9>^k1 z+w}eyP?$l(5Gpm7Q4acq zs-F>5KesW>Lm`fZV>zrC>D$(01$rfjzi@UunQE@kz{PXCA~JbYa>|Ux$tO zF!kNoh{tg@Ci70WV+DFNql*++cKa8#D`VNZ8c+_BRVzjQYzrq{@5fX;jH~eiYG%na z-oO&Hm8&SWfVqeP%0xb*npUaOK~qMwdb$}L)lqm%{s6i z-$ivC#=EDP&A|rTh}u)%A&=T9GA0Wo@7g=Fu^8Ric{OOpO zYxW5B<+vF;aUTALOx|X&<>}MPu@^hA1H-sU6YEDU@ev%4S5U9}D6*Z*^E(9%Aex<` zwOxmi*os`TE>uUKp$2jbT{vsLSv58wW3@A=HNJ~0F=2skmp9@R>IblVoY_Y>k-Fa^ z?-F?|+*hzT)P+=JquN{yz-q@@)WEi&2DB5E%EPFPop9>cF^KvY(w{v}>?Hz;d_qST z(MU|!`>)aIc!tmt+&j4B&CFv?gVs;StAtYON3;_S#5#iSiq#UVfcGfntdutqtGq3~ z6XWuJ0qe1Bust{-LSL8rj~#g9`L>|#iOeR(n+Ru{+9q~SFIi?cTdaF7Ky+zLwy!lo`yhel)y1t3fcSQTPcd#iW tVNNThwZv0|cA<_ULLZ4VRXElYYX~>7a%eatKVT>=vN~qya_WZ>{{bZQ6Nmr+ diff --git a/src/readme.txt b/src/readme.txt index 02f7b30..628d205 100644 --- a/src/readme.txt +++ b/src/readme.txt @@ -5,7 +5,7 @@ Tags: Интеграция, Simla.com, simla Requires PHP: 7.0 Requires at least: 5.3 Tested up to: 6.2 -Stable tag: 4.6.8 +Stable tag: 4.6.9 License: GPLv1 or later License URI: http://www.gnu.org/licenses/gpl-1.0.html @@ -82,6 +82,9 @@ Asegúrate de tener una clave API específica para cada tienda. Las siguientes i == Changelog == += 4.6.9 = +* Changed the logic of customer subscriptions to promotional newsletters + = 4.6.8 = * Added the ability to select CRM warehouses to synchronize the balance of offers diff --git a/src/retailcrm.php b/src/retailcrm.php index ddc9bc8..1dbb47e 100644 --- a/src/retailcrm.php +++ b/src/retailcrm.php @@ -5,7 +5,7 @@ * Description: Integration plugin for WooCommerce & Simla.com * Author: RetailDriver LLC * Author URI: http://retailcrm.pro/ - * Version: 4.6.8 + * Version: 4.6.9 * Tested up to: 6.2 * WC requires at least: 5.4 * WC tested up to: 7.8 diff --git a/src/uninstall.php b/src/uninstall.php index 11dcd40..b1b18b3 100644 --- a/src/uninstall.php +++ b/src/uninstall.php @@ -16,7 +16,7 @@ * * @link https://wordpress.org/plugins/woo-retailcrm/ * - * @version 4.6.8 + * @version 4.6.9 * * @package RetailCRM */ diff --git a/tests/helpers/class-wc-retailcrm-test-case-helper.php b/tests/helpers/class-wc-retailcrm-test-case-helper.php index b64a301..7b1ebbe 100644 --- a/tests/helpers/class-wc-retailcrm-test-case-helper.php +++ b/tests/helpers/class-wc-retailcrm-test-case-helper.php @@ -83,6 +83,9 @@ class WC_Retailcrm_Test_Case_Helper extends WC_Unit_Test_Case update_option(WC_Retailcrm_Base::$option_key, $options); + //Need for subscribe_woocommerce_before_checkout_registration_form + update_option('woocommerce_enable_signup_and_login_from_checkout', 'yes'); + return $options; } diff --git a/tests/test-wc-retailcrm-base.php b/tests/test-wc-retailcrm-base.php index a9370f8..5b1e774 100644 --- a/tests/test-wc-retailcrm-base.php +++ b/tests/test-wc-retailcrm-base.php @@ -259,6 +259,20 @@ class WC_Retailcrm_Base_Test extends WC_Retailcrm_Test_Case_Helper ob_end_clean(); } + public function test_subscribed_checkbox() + { + ob_start(); + + $this->baseRetailcrm->subscribe_register_form(); + $this->baseRetailcrm->subscribe_woocommerce_register_form(); + $this->baseRetailcrm->subscribe_woocommerce_before_checkout_registration_form(); + + $this->assertContains('subscribeEmail', ob_get_contents()); + + ob_end_clean(); + } + + public function test_initialize_whatsapp() { ob_start(); diff --git a/tests/test-wc-retailcrm-customers.php b/tests/test-wc-retailcrm-customers.php index 001cba1..c0e3205 100644 --- a/tests/test-wc-retailcrm-customers.php +++ b/tests/test-wc-retailcrm-customers.php @@ -144,6 +144,8 @@ class WC_Retailcrm_Customers_Test extends WC_Retailcrm_Test_Case_Helper $crmCustomer = $this->getRetailcrmCustomer($retailcrm); + $crmCustomer->isSubscribed = true; + $id = $crmCustomer->registerCustomer($this->customer->get_id()); $customer = $crmCustomer->getCustomer(); @@ -158,6 +160,7 @@ class WC_Retailcrm_Customers_Test extends WC_Retailcrm_Test_Case_Helper $this->assertEquals($customer['firstName'], $this->customer->get_first_name()); $this->assertEquals($customer['email'], $this->customer->get_email()); $this->assertEquals($customer['customFields']['crm_customer'], 'test_custom_fields'); + $this->assertTrue($customer['subscribed']); } else { $this->assertEquals(null, $id); $this->assertEquals([], $customer);