1
0
mirror of synced 2025-01-29 22:31:42 +03:00

ref #95242 Support for services in ICML (#329)

This commit is contained in:
Kocmonavtik 2024-04-24 12:12:43 +03:00 committed by GitHub
parent 90d7e1f866
commit 8627548d7c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 84 additions and 8 deletions

View File

@ -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

View File

@ -47,4 +47,3 @@ coverage:
build_archive:
zip -r $(ARCHIVE_NAME) ./src/*

View File

@ -1 +1 @@
4.7.6
4.7.7

View File

@ -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"
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"

View File

@ -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 как услуги"

View File

@ -144,6 +144,18 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
),
];
$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,

View File

@ -36,6 +36,8 @@ if (!class_exists('WC_Retailcrm_Icml')) :
protected $icmlWriter;
protected $unloadServices = false;
/**
* WC_Retailcrm_Icml constructor.
*
@ -47,6 +49,10 @@ if (!class_exists('WC_Retailcrm_Icml')) :
$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 @@ if (!class_exists('WC_Retailcrm_Icml')) :
'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() !== '') {

View File

@ -121,6 +121,7 @@ if (!class_exists('WC_Retailcrm_Icml_Writer')) :
$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'])) {

View File

@ -197,6 +197,9 @@ return [
"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",

Binary file not shown.

View File

@ -196,6 +196,9 @@ return [
"Требуется API ключ с доступом к одному магазину",
"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" =>
"Валюта сайта отличается от валюты магазина в 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",

Binary file not shown.

View File

@ -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

View File

@ -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

View File

@ -16,7 +16,7 @@
*
* @link https://wordpress.org/plugins/woo-retailcrm/
*
* @version 4.7.6
* @version 4.7.7
*
* @package RetailCRM
*/

View File

@ -80,6 +80,7 @@ class WC_Retailcrm_Test_Case_Helper extends WC_Unit_Test_Case
'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);

View File

@ -17,6 +17,9 @@ class WC_Retailcrm_Icml_Test extends WC_Retailcrm_Test_Case_Helper
{
WC_Helper_Product::create_simple_product();
WC_Helper_Product::create_variation_product();
$this->createVirtualProduct();
$this->setOptions();
}
public function testGenerate()
@ -35,9 +38,9 @@ class WC_Retailcrm_Icml_Test extends WC_Retailcrm_Test_Case_Helper
$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 @@ class WC_Retailcrm_Icml_Test extends WC_Retailcrm_Test_Case_Helper
$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);
}
}