From 8627548d7c29dc1a13fcaa018fbb1e47e4e1dd90 Mon Sep 17 00:00:00 2001 From: Kocmonavtik <61938582+Kocmonavtik@users.noreply.github.com> Date: Wed, 24 Apr 2024 12:12:43 +0300 Subject: [PATCH] ref #95242 Support for services in ICML (#329) --- CHANGELOG.md | 3 ++ Makefile | 1 - VERSION | 2 +- resources/pot/retailcrm-es_ES.pot | 8 ++++- resources/pot/retailcrm-ru_RU.pot | 6 ++++ .../class-wc-retailcrm-abstracts-settings.php | 12 +++++++ src/include/class-wc-retailcrm-icml.php | 9 ++++- .../icml/class-wc-retailcrm-icml-writer.php | 1 + src/languages/retailcrm-es_ES.l10n.php | 3 ++ src/languages/retailcrm-es_ES.mo | Bin 13327 -> 13576 bytes src/languages/retailcrm-ru_RU.l10n.php | 3 ++ src/languages/retailcrm-ru_RU.mo | Bin 16456 -> 16757 bytes src/readme.txt | 5 ++- src/retailcrm.php | 2 +- src/uninstall.php | 2 +- .../class-wc-retailcrm-test-case-helper.php | 1 + tests/test-wc-retailcrm-icml.php | 34 +++++++++++++++++- 17 files changed, 84 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3fadc9a..78c06d48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2024-04-23 4.7.7 +* Added transfer of services via ICML catalog + ## 2024-04-22 4.7.6 * Support WP 6.5 diff --git a/Makefile b/Makefile index 1faab505..67c45200 100644 --- a/Makefile +++ b/Makefile @@ -47,4 +47,3 @@ coverage: build_archive: zip -r $(ARCHIVE_NAME) ./src/* - diff --git a/VERSION b/VERSION index 54608049..32b93c0c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.7.6 +4.7.7 diff --git a/resources/pot/retailcrm-es_ES.pot b/resources/pot/retailcrm-es_ES.pot index 19988df7..970ebdc7 100644 --- a/resources/pot/retailcrm-es_ES.pot +++ b/resources/pot/retailcrm-es_ES.pot @@ -443,4 +443,10 @@ msgid "API key with one-shop access required" msgstr "Se requiere clave API con acceso a una tienda" msgid "The currency of the site differs from the currency of the store in CRM. For the integration to work correctly, the currencies in CRM and CMS must match" -msgstr "La moneda del sitio web es distinto a la tienda del CRM. Para el funcionamiento correcto de la integración, las monedas del CMS y CRM deben coincid" \ No newline at end of file +msgstr "La moneda del sitio web es distinto a la tienda del CRM. Para el funcionamiento correcto de la integración, las monedas del CMS y CRM deben coincid" + +msgid "Uploading services" +msgstr "Descarga de servicios" + +msgid "Goods with the 'virtual' option enabled will be uploaded to Simla as services" +msgstr "Los bienes con la opción 'virtual' activada se cargarán en Simla como servicios" diff --git a/resources/pot/retailcrm-ru_RU.pot b/resources/pot/retailcrm-ru_RU.pot index 8d451705..b353e9a0 100644 --- a/resources/pot/retailcrm-ru_RU.pot +++ b/resources/pot/retailcrm-ru_RU.pot @@ -453,3 +453,9 @@ msgstr "Требуется API ключ с доступом к одному ма msgid "The currency of the site differs from the currency of the store in CRM. For the integration to work correctly, the currencies in CRM and CMS must match" msgstr "Валюта сайта отличается от валюты магазина в CRM. Для корректной работы интеграции, валюты в CRM и CMS должны совпадать" + +msgid "Uploading services" +msgstr "Выгрузка услуг" + +msgid "Goods with the 'virtual' option enabled will be uploaded to Simla as services" +msgstr "Товары с включенной опцией 'виртуальные' будут выгружаться в CRM как услуги" diff --git a/src/include/abstracts/class-wc-retailcrm-abstracts-settings.php b/src/include/abstracts/class-wc-retailcrm-abstracts-settings.php index 3c0c4465..ba8bbef2 100644 --- a/src/include/abstracts/class-wc-retailcrm-abstracts-settings.php +++ b/src/include/abstracts/class-wc-retailcrm-abstracts-settings.php @@ -144,6 +144,18 @@ public function init_form_fields() ), ]; + $this->form_fields['icml_unload_services'] = [ + 'label' => __('Enabled', 'retailcrm'), + 'title' => __('Uploading services', 'retailcrm'), + 'class' => 'checkbox', + 'type' => 'checkbox', + 'desc_tip' => true, + 'description' => __( + "Goods with the 'virtual' option enabled will be uploaded to Simla as services", + "retailcrm" + ), + ]; + foreach (get_post_statuses() as $statusKey => $statusValue) { $this->form_fields['p_' . $statusKey] = [ 'title' => $statusValue, diff --git a/src/include/class-wc-retailcrm-icml.php b/src/include/class-wc-retailcrm-icml.php index ee21a861..5d0875fa 100644 --- a/src/include/class-wc-retailcrm-icml.php +++ b/src/include/class-wc-retailcrm-icml.php @@ -36,6 +36,8 @@ class WC_Retailcrm_Icml protected $icmlWriter; + protected $unloadServices = false; + /** * WC_Retailcrm_Icml constructor. * @@ -47,6 +49,10 @@ public function __construct() $this->tmpFile = sprintf('%s.tmp', $this->file); $this->settings = get_option(WC_Retailcrm_Base::$option_key); $this->icmlWriter = new WC_Retailcrm_Icml_Writer($this->tmpFile); + $this->unloadServices = ( + isset($this->settings['icml_unload_services']) + && $this->settings['icml_unload_services'] === WC_Retailcrm_Base::YES + ); } public function changeBindBySku($useXmlId) @@ -252,7 +258,8 @@ private function getOffer(array $productAttributes, WC_Product $product, $parent 'categoryId' => $termList, 'dimensions' => $dimensions, 'weight' => $weight, - 'tax' => isset($tax) ? $tax['rate'] : 'none' + 'tax' => isset($tax) ? $tax['rate'] : 'none', + 'type' => ($this->unloadServices && $product->is_virtual()) ? 'service' : 'product', ]; if ($product->get_sku() !== '') { diff --git a/src/include/icml/class-wc-retailcrm-icml-writer.php b/src/include/icml/class-wc-retailcrm-icml-writer.php index 5980223c..fa705025 100644 --- a/src/include/icml/class-wc-retailcrm-icml-writer.php +++ b/src/include/icml/class-wc-retailcrm-icml-writer.php @@ -121,6 +121,7 @@ private function addOffers($offers) $this->writer->writeAttribute('id', $offer['id']); $this->writer->writeAttribute('productId', $offer['productId']); $this->writer->writeAttribute('quantity', (int) $offer['quantity'] ?? 0); + $this->writer->writeAttribute('type', $offer['type']); if (isset($offer['categoryId'])) { if (is_array($offer['categoryId'])) { diff --git a/src/languages/retailcrm-es_ES.l10n.php b/src/languages/retailcrm-es_ES.l10n.php index f5b710e0..e3fb869c 100644 --- a/src/languages/retailcrm-es_ES.l10n.php +++ b/src/languages/retailcrm-es_ES.l10n.php @@ -197,6 +197,9 @@ "Se requiere clave API con acceso a una tienda", "The currency of the site differs from the currency of the store in CRM. For the integration to work correctly, the currencies in CRM and CMS must match" => "La moneda del sitio web es distinto a la tienda del CRM. Para el funcionamiento correcto de la integración, las monedas del CMS y CRM deben coincid", + "Uploading services" => "Descarga de servicios", + "Goods with the 'virtual' option enabled will be uploaded to Simla as services" => + "Los bienes con la opción 'virtual' activada se cargarán en Simla como servicios" ], "language" => "es", "x-generator" => "GlotPress/2.4.0-alpha", diff --git a/src/languages/retailcrm-es_ES.mo b/src/languages/retailcrm-es_ES.mo index 30154f7d1dff520e05ab0a8d08b4663497b14d3c..3b176fa7e3896dce16b8ba6d7e623916cdaae174 100644 GIT binary patch delta 3392 zcmYk;drZ}39LMoTL~e>)yo;9~Do}VqF|XkbFNg{VC>e@+IOhn*kfWRcG{+@co9eml!~t2sh?DW<~QsS=h~(NG!w@d=XOb(U4+;HMx+=%MnFfPF3s0Qz2FYMBtz$DcDWTYXJi4mBOylNI> zB0BBsTI|ntBlf|g7)}4?Qz{x+E2_cYQ6qnV`a&GjO2Bl~z_O4>CI^$T#C~3n8b}k) z#1Bw2y^SMq7>#?d5QpRE7)k%;CKbJK7qf8yy=ed|FdsLdM%;$HVy>fRcn@jYJjOW~ z$8`0)1j(|gKt1=PzTaqHAI3bcPhcRO%0ntEF{OtwGjKbq!8YX2#Ptl#cqr=qOiaZx z)bmChg$Gd+xq!;(eayr@teXZr5B0qzsDTE0k$*kd!;RbV;}NQ+vX5A$f7xk+W4*Zi{GF+ zx?*47LJi~|X5eESh8gT&rFs$SeHR|UdK`rDtmjC~z=2qXY1j~;!aL>|Dg$3&3Eo33 z!CZDAeVAs{7ms5Yo<|+KHdF?#pi+JVHNz-&qB5C)Oy2ZGJngZD5SzeN4wMRQXopw_q_s>7*Rj`L9&_!yP3bEuSGM@{G^GA8rT zzTcnxYeLDWjE=@$^lx&g@Qx`%eIbC#z)?)W4^eA;3Dwax)PNqLIX&W;j>l{)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xMBji?N7Mon2GvStF- zPDLX>gBnpU>Vof(cadGhx-hfLsE(HL7)t3%REO=T>kgwjJb{|yGpOx(9+m1FsO=k> z6goZ<7ij;_prSWiqjMK(Zd*|ueuQhW2bF;_+?AwQCMwm%s3-Cveb^>p$1fg>Zk*?*xqyPQ>il|CCTfxOZEdOKUmYIhKoefZLR`fj(EvU~&E3DK4&x_<<~{|d z(k?-5-)7W(4x(1~In)a)g0vLjG}M3ssNHrDmBF)V;VP|#^{D;pM|O&} zqf&buv+y+P32wOKQM}MupEepdU^c3QBX|fuMGbTbo$3B7QRg=VsOZFY)ZDgX6dpnC z{}ZTze1S38kCAvCHFY;pt38!1p#jWtR^S2J4M-}`^)ZOhy*0He z+#>i-O(RwiT7SW^-KmbNT>UNuRFol=MInMyq3S52!5!P^T!2b7GZTDulV+PibP^;x z_)iD~OR)b+*I4fqONb{3t^TKo5rm(ZN$e(e5!;BN1WU$}h&jY8LghK)C1NiTPLvRu z##f0Vg4t9F*kgQa-t*L? "Валюта сайта отличается от валюты магазина в CRM. Для корректной работы интеграции, валюты в CRM и CMS должны совпадать", + "Uploading services" => "Выгрузка услуг", + "Goods with the 'virtual' option enabled will be uploaded to Simla as services" => + "Товары с включенной опцией 'виртуальные' будут выгружаться в CRM как услуги" ], "language" => "ru", "x-generator" => "GlotPress/2.4.0-alpha", diff --git a/src/languages/retailcrm-ru_RU.mo b/src/languages/retailcrm-ru_RU.mo index 4249a72d103a3bdb3201064cc25bd9eb398aa3d3..a0b0cf3044c0f91b24f60ae87114514694ecd825 100644 GIT binary patch delta 3462 zcmYk;c~F&A7{~F0g1Dh9B7zGqg5r{zxa5ipDVpKFl!giddF9Ggx#I3s+!rwSWz3qg z(WYi3iAiac$;mQHyBB9PH2cG9#+lU7rd%d#`u^_w>Ui>bKj&TUdCz&yIWJvU6Y_Uy zi0_x^(7lGDLmT4jP-DJDcOwpz%}tF7$1T_acVc7w0{LgoacF`+VspHK@%V>xJuJeQ zD9)p>6((bQ9EAOi@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Q{Dl*g|b_I$*lSNyqZJZY*|YOk8m&7^NvfZ z7Zm3;7?d;E$MuEQy>HI{lCFxiVSZRkC!}mJ9u58Yy#1_fxdS@g9yTpi^uiYX=X1d;N%Q#G|6X|%f$g4Ny!8&CtZT7Czezm$5 ztY*1M%oWDfm8pk#qu3;Nh<@Tsky4Z0t}~y;kbEf%#DyZWKUF?bRqkb$BWs*uzy81E zC}uOJSe32~mnHqQ$O|W>L#*nmc|m3Uw^fb1ctcgUROQR!j;furYB|eNu~KXlXNV7% z9#tcIB1iPHsvX)zmNvzHEw^>m@>Z1p6&ha=UlLi*)5O=sXT){l9x+oa7UzglCA+?_ zm?K7s)nbddR-~*Ev&GOfl(8c3|CG;(Y|i0X|CH7`<#wJWa#T{Li+SP}F-FW1SBVW` zpg2{URdNbaJ}YumQ})y;JK0m*Dz=LU#As0)?`x#^qBvD@uD>B##GN9$`CRega$nWx z&o+^XKr+&wWagv@h>%Z K?w|VG?*9XuJ2Vsk diff --git a/src/readme.txt b/src/readme.txt index f3aebb36..060325a9 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.5 -Stable tag: 4.7.6 +Stable tag: 4.7.7 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.7.7 = +* Added transfer of services via ICML catalog + = 4.7.6 = * Support WP 6.5 diff --git a/src/retailcrm.php b/src/retailcrm.php index 7d485866..63a02982 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.7.6 + * Version: 4.7.7 * Tested up to: 6.5 * Requires Plugins: woocommerce * WC requires at least: 5.4 diff --git a/src/uninstall.php b/src/uninstall.php index fc47ecb1..cf4acb97 100644 --- a/src/uninstall.php +++ b/src/uninstall.php @@ -16,7 +16,7 @@ * * @link https://wordpress.org/plugins/woo-retailcrm/ * - * @version 4.7.6 + * @version 4.7.7 * * @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 a099ac27..2c09d1c9 100644 --- a/tests/helpers/class-wc-retailcrm-test-case-helper.php +++ b/tests/helpers/class-wc-retailcrm-test-case-helper.php @@ -80,6 +80,7 @@ protected function setOptions() 'product_description' => 'full', 'stores_for_uploading' => ['woocommerce', 'main'], 'woo_coupon_apply_field' => 'testField', + 'icml_unload_services' => 'yes' ]; update_option(WC_Retailcrm_Base::$option_key, $options); diff --git a/tests/test-wc-retailcrm-icml.php b/tests/test-wc-retailcrm-icml.php index ff751c61..f55574d0 100644 --- a/tests/test-wc-retailcrm-icml.php +++ b/tests/test-wc-retailcrm-icml.php @@ -17,6 +17,9 @@ public function setUp() { WC_Helper_Product::create_simple_product(); WC_Helper_Product::create_variation_product(); + + $this->createVirtualProduct(); + $this->setOptions(); } public function testGenerate() @@ -35,9 +38,9 @@ public function testGenerate() $this->assertNotEmpty($xmlArray['shop']['categories']['category']); $this->assertCount(2, $xmlArray['shop']['categories']['category']); $this->assertNotEmpty($xmlArray['shop']['offers']['offer']); - $this->assertCount(7, $xmlArray['shop']['offers']['offer']); $this->assertNotEmpty($xmlArray['shop']['offers']['offer'][0]); $this->assertNotEmpty($xmlArray['shop']['offers']['offer'][1]); + $this->assertNotEmpty($xmlArray['shop']['offers']['offer'][2]); foreach ($xmlArray['shop']['offers']['offer'] as $product) { $this->assertNotEmpty($product['name']); @@ -48,6 +51,35 @@ public function testGenerate() $this->assertNotEmpty($product['vatRate']); $this->assertEquals('none', $product['vatRate']); $this->assertContains('Dummy', $product['productName']); + $this->assertNotEmpty($product['@attributes']['type']); } + + $attributesList = array_column($xmlArray['shop']['offers']['offer'], '@attributes'); + $typeList = array_column($attributesList, 'type'); + + $this->assertContains('service', $typeList); + } + + private function createVirtualProduct() + { + $product = wp_insert_post([ + 'post_title' => 'Dummy Product', + 'post_type' => 'product', + 'post_status' => 'publish', + ]); + + update_post_meta($product, '_price', '10'); + update_post_meta($product, '_regular_price', '10'); + update_post_meta($product, '_sale_price', ''); + update_post_meta($product, '_sku', 'DUMMY SKU'); + update_post_meta($product, '_manage_stock', 'no'); + update_post_meta($product, '_tax_status', 'taxable'); + update_post_meta($product, '_downloadable', 'no'); + update_post_meta($product, '_virtual', 'yes'); + update_post_meta($product, '_stock_status', 'instock'); + update_post_meta($product, '_weight', '1.1'); + wp_set_object_terms($product, 'simple', 'product_type'); + + return new WC_Product_Simple($product); } }