1
0
mirror of synced 2025-01-18 08:51:41 +03:00

Add generators in the ICML generation process

This commit is contained in:
Dima Uryvskiy 2022-09-30 17:50:15 +03:00 committed by GitHub
parent 222f5efde1
commit 769907d812
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
72 changed files with 672 additions and 616 deletions

View File

@ -1,3 +1,9 @@
## 2022-09-30 4.5.0
* Fix path for js scripts
* Migrating to PHP 7.0.
* Change logic work with ICML catalog: added streaming generation, added generators in the ICML generation process.
* Change logic work with address
## 2022-09-05 4.4.9 ## 2022-09-05 4.4.9
* Fix bug with product tax * Fix bug with product tax

View File

@ -1,7 +1,7 @@
[![Build Status](https://github.com/retailcrm/woocommerce-module/workflows/woo/badge.svg)](https://github.com/retailcrm/woocommerce-module/actions) [![Build Status](https://github.com/retailcrm/woocommerce-module/workflows/woo/badge.svg)](https://github.com/retailcrm/woocommerce-module/actions)
[![Coverage](https://img.shields.io/codecov/c/gh/retailcrm/woocommerce-module/master.svg?logo=github)](https://codecov.io/gh/retailcrm/woocommerce-module) [![Coverage](https://img.shields.io/codecov/c/gh/retailcrm/woocommerce-module/master.svg?logo=github)](https://codecov.io/gh/retailcrm/woocommerce-module)
[![GitHub release](https://img.shields.io/github/release/retailcrm/woocommerce-module.svg?logo=codecov)](https://github.com/retailcrm/woocommerce-module/releases) [![GitHub release](https://img.shields.io/github/release/retailcrm/woocommerce-module.svg?logo=codecov)](https://github.com/retailcrm/woocommerce-module/releases)
[![PHP version](https://img.shields.io/badge/PHP->=5.4-blue.svg?logo=php)](https://php.net/) [![PHP version](https://img.shields.io/badge/PHP->=7.0-blue.svg?logo=php)](https://php.net/)
Woocommerce-module Woocommerce-module
================== ==================

View File

@ -1 +1 @@
4.4.9 4.5.0

View File

@ -10,7 +10,8 @@
], ],
"minimum-stability": "dev", "minimum-stability": "dev",
"require": { "require": {
"ext-simplexml": "*" "ext-simplexml": "*",
"ext-xmlwriter": "*"
}, },
"require-dev": { "require-dev": {
"ext-json": "*", "ext-json": "*",

View File

@ -339,3 +339,6 @@ msgstr "Borrar"
msgid "Cron tasks cleared" msgid "Cron tasks cleared"
msgstr "Trabajos cron borrados" msgstr "Trabajos cron borrados"
msgid "Untitled"
msgstr "Intitulado"

View File

@ -348,3 +348,7 @@ msgstr "Очистить"
msgid "Cron tasks cleared" msgid "Cron tasks cleared"
msgstr "Cron задачи очищены" msgstr "Cron задачи очищены"
msgid "Untitled"
msgstr "Без названия"

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Abstract_Builder - Builds data for CRM. * Class WC_Retailcrm_Abstract_Builder - Builds data for CRM.
* *

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Abstracts_Address - Builds data for addresses orders/customers. * Class WC_Retailcrm_Abstracts_Address - Builds data for addresses orders/customers.
* *

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Abstracts_Data - Class manage different data. * Class WC_Retailcrm_Abstracts_Data - Class manage different data.
* *

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Abstracts_Settings - Settings plugin Simla. * Class WC_Retailcrm_Abstracts_Settings - Settings plugin Simla.
* *

View File

@ -1,17 +1,5 @@
<?php <?php
/**
* PHP version 5.6
*
* Class WC_Retailcrm_Client_V5 - Api Client V5 class.
*
* @category Integration
* @package WC_Retailcrm_Client
* @author RetailCRM <dev@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://retailcrm.ru/docs/Developers/ApiVersion5
*/
if (!class_exists('WC_Retailcrm_Request')) { if (!class_exists('WC_Retailcrm_Request')) {
include_once(WC_Integration_Retailcrm::checkCustomFile('include/api/class-wc-retailcrm-request.php')); include_once(WC_Integration_Retailcrm::checkCustomFile('include/api/class-wc-retailcrm-request.php'));
} }
@ -20,6 +8,17 @@ if (!class_exists('WC_Retailcrm_Response')) {
include_once(WC_Integration_Retailcrm::checkCustomFile('include/api/class-wc-retailcrm-response.php')); include_once(WC_Integration_Retailcrm::checkCustomFile('include/api/class-wc-retailcrm-response.php'));
} }
/**
* PHP version 7.0
*
* Class WC_Retailcrm_Client_V5 - Api Client V5 class.
*
* @category Integration
* @package WC_Retailcrm_Client
* @author RetailCRM <dev@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://retailcrm.ru/docs/Developers/ApiVersion5
*/
class WC_Retailcrm_Client_V5 class WC_Retailcrm_Client_V5
{ {
protected $client; protected $client;

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Exception_Curl. * Class WC_Retailcrm_Exception_Curl.
* *

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Exception_Json. * Class WC_Retailcrm_Exception_Json.
* *

View File

@ -1,17 +1,17 @@
<?php <?php
/**
* PHP version 5.6
*
* Class WC_Retailcrm_Proxy - RetailCRM Integration.
*
* @category Integration
* @package WC_Retailcrm_Proxy
* @author RetailCRM <dev@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://retailcrm.ru/docs/Developers/ApiVersion5
*/
if (!class_exists('WC_Retailcrm_Proxy')) : if (!class_exists('WC_Retailcrm_Proxy')) :
/**
* PHP version 7.0
*
* Class WC_Retailcrm_Proxy - RetailCRM Integration.
*
* @category Integration
* @package WC_Retailcrm_Proxy
* @author RetailCRM <dev@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://retailcrm.ru/docs/Developers/ApiVersion5
*/
class WC_Retailcrm_Proxy class WC_Retailcrm_Proxy
{ {
protected $retailcrm; protected $retailcrm;

View File

@ -1,15 +1,4 @@
<?php <?php
/**
* PHP version 5.6
*
* Class WC_Retailcrm_Request - Request class.
*
* @category Integration
* @package WC_Retailcrm_Request
* @author RetailCRM <dev@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://retailcrm.ru/docs/Developers/ApiVersion5
*/
if (!class_exists('WC_Retailcrm_Exception_Curl')) { if (!class_exists('WC_Retailcrm_Exception_Curl')) {
include_once(WC_Integration_Retailcrm::checkCustomFile('include/api/class-wc-retailcrm-exception-curl.php')); include_once(WC_Integration_Retailcrm::checkCustomFile('include/api/class-wc-retailcrm-exception-curl.php'));
@ -19,6 +8,17 @@ if (!class_exists('WC_Retailcrm_Response')) {
include_once(WC_Integration_Retailcrm::checkCustomFile('include/api/class-wc-retailcrm-response.php')); include_once(WC_Integration_Retailcrm::checkCustomFile('include/api/class-wc-retailcrm-response.php'));
} }
/**
* PHP version 7.0
*
* Class WC_Retailcrm_Request - Request class.
*
* @category Integration
* @package WC_Retailcrm_Request
* @author RetailCRM <dev@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://retailcrm.ru/docs/Developers/ApiVersion5
*/
class WC_Retailcrm_Request class WC_Retailcrm_Request
{ {
const METHOD_GET = 'GET'; const METHOD_GET = 'GET';

View File

@ -1,6 +1,11 @@
<?php <?php
if (!class_exists('WC_Retailcrm_Exception_Json')) {
include_once(WC_Integration_Retailcrm::checkCustomFile('include/api/class-wc-retailcrm-exception-json.php'));
}
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Response - Response class. * Class WC_Retailcrm_Response - Response class.
* *
@ -10,11 +15,6 @@
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://retailcrm.ru/docs/Developers/ApiVersion5 * @link http://retailcrm.ru/docs/Developers/ApiVersion5
*/ */
if (!class_exists('WC_Retailcrm_Exception_Json')) {
include_once(WC_Integration_Retailcrm::checkCustomFile('include/api/class-wc-retailcrm-exception-json.php'));
}
class WC_Retailcrm_Response implements \ArrayAccess class WC_Retailcrm_Response implements \ArrayAccess
{ {
// HTTP response status code // HTTP response status code

View File

@ -1,22 +1,21 @@
<?php <?php
/**
* PHP version 5.6
*
* Class WC_Retailcrm_Base - Main settings plugin.
*
* @category Integration
* @author RetailCRM <integration@retailcrm.ru>
* @license http://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see http://help.retailcrm.ru
*/
if (!class_exists('WC_Retailcrm_Base')) { if (!class_exists('WC_Retailcrm_Base')) {
if (!class_exists('WC_Retailcrm_Abstracts_Settings')) { if (!class_exists('WC_Retailcrm_Abstracts_Settings')) {
include_once(WC_Integration_Retailcrm::checkCustomFile('include/abstracts/class-wc-retailcrm-abstracts-settings.php')); include_once(WC_Integration_Retailcrm::checkCustomFile('include/abstracts/class-wc-retailcrm-abstracts-settings.php'));
} }
/**
* PHP version 7.0
*
* Class WC_Retailcrm_Base - Main settings plugin.
*
* @category Integration
* @author RetailCRM <integration@retailcrm.ru>
* @license http://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see http://help.retailcrm.ru
*/
class WC_Retailcrm_Base extends WC_Retailcrm_Abstracts_Settings class WC_Retailcrm_Base extends WC_Retailcrm_Abstracts_Settings
{ {
/** @var WC_Retailcrm_Proxy|WC_Retailcrm_Client_V5|bool */ /** @var WC_Retailcrm_Proxy|WC_Retailcrm_Client_V5|bool */

View File

@ -1,17 +1,17 @@
<?php <?php
/**
* PHP version 5.6
*
* Class WC_Retailcrm_Customers - Allows transfer data customers with CMS.
*
* @category Integration
* @author RetailCRM <integration@retailcrm.ru>
* @license http://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see http://help.retailcrm.ru
*/
if (!class_exists('WC_Retailcrm_Customers')) : if (!class_exists('WC_Retailcrm_Customers')) :
/**
* PHP version 7.0
*
* Class WC_Retailcrm_Customers - Allows transfer data customers with CMS.
*
* @category Integration
* @author RetailCRM <integration@retailcrm.ru>
* @license http://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see http://help.retailcrm.ru
*/
class WC_Retailcrm_Customers class WC_Retailcrm_Customers
{ {
/** @var bool | WC_Retailcrm_Proxy | \WC_Retailcrm_Client_V5 */ /** @var bool | WC_Retailcrm_Proxy | \WC_Retailcrm_Client_V5 */

View File

@ -1,6 +1,11 @@
<?php <?php
if (!defined('ABSPATH')) {
exit;
}
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Daemon_Collector - Integration with Daemon Collector. * Class WC_Retailcrm_Daemon_Collector - Integration with Daemon Collector.
* *
@ -10,11 +15,6 @@
* @link http://retailcrm.ru * @link http://retailcrm.ru
* @see http://help.retailcrm.ru * @see http://help.retailcrm.ru
*/ */
if (!defined('ABSPATH')) {
exit;
}
class WC_Retailcrm_Daemon_Collector { class WC_Retailcrm_Daemon_Collector {
/** @var self $instance */ /** @var self $instance */
private static $instance; private static $instance;

View File

@ -1,17 +1,17 @@
<?php <?php
/**
* PHP version 5.6
*
* Class WC_Retailcrm_Google_Analytics - Integration with Google Analytics.
*
* @category Integration
* @author RetailCRM <integration@retailcrm.ru>
* @license http://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see http://help.retailcrm.ru
*/
if (!class_exists('WC_Retailcrm_Google_Analytics')) { if (!class_exists('WC_Retailcrm_Google_Analytics')) {
/**
* PHP version 7.0
*
* Class WC_Retailcrm_Google_Analytics - Integration with Google Analytics.
*
* @category Integration
* @author RetailCRM <integration@retailcrm.ru>
* @license http://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see http://help.retailcrm.ru
*/
class WC_Retailcrm_Google_Analytics { class WC_Retailcrm_Google_Analytics {
private static $instance; private static $instance;
private $options; private $options;

View File

@ -1,18 +1,17 @@
<?php <?php
/**
* PHP version 5.6
*
* Class WC_Retailcrm_History - Allows transfer data orders/customers with CRM.
*
* @category Integration
* @author RetailCRM <integration@retailcrm.ru>
* @license http://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see http://help.retailcrm.ru
*/
if (!class_exists('WC_Retailcrm_History')) : if (!class_exists('WC_Retailcrm_History')) :
/**
* PHP version 7.0
*
* Class WC_Retailcrm_History - Allows transfer data orders/customers with CRM.
*
* @category Integration
* @author RetailCRM <integration@retailcrm.ru>
* @license http://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see http://help.retailcrm.ru
*/
class WC_Retailcrm_History class WC_Retailcrm_History
{ {
const PAGE_LIMIT = 25; const PAGE_LIMIT = 25;

View File

@ -1,25 +1,20 @@
<?php <?php
/**
* PHP version 5.6
*
* Class WC_Retailcrm_Icml - Generate ICML file (catalog).
*
* @category Integration
* @author RetailCRM <integration@retailcrm.ru>
* @license http://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see http://help.retailcrm.ru
*/
if (!class_exists('WC_Retailcrm_Icml')) : if (!class_exists('WC_Retailcrm_Icml')) :
/**
* PHP version 7.0
*
* Class WC_Retailcrm_Icml - Generate ICML file (catalog).
*
* @category Integration
* @author RetailCRM <integration@retailcrm.ru>
* @license http://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see http://help.retailcrm.ru
*/
class WC_Retailcrm_Icml class WC_Retailcrm_Icml
{ {
protected $shop; const OFFER_PROPERTIES = [
protected $file;
protected $tmpFile;
protected $properties = [
'name', 'name',
'productName', 'productName',
'price', 'price',
@ -31,19 +26,11 @@ if (!class_exists('WC_Retailcrm_Icml')) :
'productActivity' 'productActivity'
]; ];
protected $xml; protected $shop;
protected $file;
/** @var SimpleXMLElement $categories */ protected $tmpFile;
protected $categories;
/** @var SimpleXMLElement $categories */
protected $offers;
protected $chunk = 500;
protected $fileLifeTime = 3600;
/** @var array */
protected $settings; protected $settings;
protected $icmlWriter;
/** /**
* WC_Retailcrm_Icml constructor. * WC_Retailcrm_Icml constructor.
@ -51,410 +38,125 @@ if (!class_exists('WC_Retailcrm_Icml')) :
*/ */
public function __construct() public function __construct()
{ {
$this->settings = get_option(WC_Retailcrm_Base::$option_key); $this->shop = get_bloginfo('name');
$this->shop = get_bloginfo('name'); $this->file = ABSPATH . 'simla.xml';
$this->file = ABSPATH . 'simla.xml'; $this->tmpFile = sprintf('%s.tmp', $this->file);
$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);
} }
/** /**
* Generate file * Generate ICML catalog.
*/ */
public function generate() public function generate()
{ {
$categories = $this->get_wc_categories_taxonomies(); $this->icmlWriter->writeHead($this->shop);
if (file_exists($this->tmpFile)) { $categories = $this->prepareCategories();
if (filectime($this->tmpFile) + $this->fileLifeTime < time()) {
unlink($this->tmpFile); if (empty($categories)) {
$this->writeHead(); writeBaseLogs('Can`t get categories!');
} return;
} else {
$this->writeHead();
} }
try { $this->icmlWriter->writeCategories($categories);
if (!empty($categories)) {
$this->writeCategories($categories);
unset($categories);
}
$status_args = $this->checkPostStatuses(); $offers = $this->prepareOffers();
$this->get_wc_products_taxonomies($status_args);
$dom = dom_import_simplexml(simplexml_load_file($this->tmpFile))->ownerDocument; if (empty($offers)) {
writeBaseLogs('Can`t get offers!');
$dom->formatOutput = true; return;
$formatted = $dom->saveXML();
unset($dom, $this->xml);
file_put_contents($this->tmpFile, $formatted);
rename($this->tmpFile, $this->file);
} catch (Exception $e) {
unlink($this->tmpFile);
}
}
/**
* Load tmp data
*
* @return \SimpleXMLElement
*/
private function loadXml()
{
return new SimpleXMLElement(
$this->tmpFile,
LIBXML_NOENT | LIBXML_NOCDATA | LIBXML_COMPACT | LIBXML_PARSEHUGE,
true
);
}
/**
* Generate xml header
*/
private function writeHead()
{
$string = sprintf(
'<?xml version="1.0" encoding="UTF-8"?><yml_catalog date="%s"><shop><name>%s</name><categories/><offers/></shop></yml_catalog>',
current_time('Y-m-d H:i:s'),
html_entity_decode($this->shop)
);
file_put_contents($this->tmpFile, $string, LOCK_EX);
}
/**
* Write categories in file
*
* @param $categories
*/
private function writeCategories($categories)
{
$chunkCategories = array_chunk($categories, $this->chunk);
foreach ($chunkCategories as $categories) {
$this->xml = $this->loadXml();
$this->categories = $this->xml->shop->categories;
$this->addCategories($categories);
$this->xml->asXML($this->tmpFile);
} }
unset($this->categories); $this->icmlWriter->writeOffers($offers);
$this->icmlWriter->writeEnd();
$this->icmlWriter->formatXml($this->tmpFile);
rename($this->tmpFile, $this->file);
} }
/** /**
* Write products in file * Prepare WC offers for write.
*
* @param $offers
*/
private function writeOffers($offers)
{
$chunkOffers = array_chunk($offers, $this->chunk);
foreach ($chunkOffers as $offers) {
$this->xml = $this->loadXml();
$this->offers = $this->xml->shop->offers;
$this->addOffers($offers);
$this->xml->asXML($this->tmpFile);
}
unset($this->offers);
}
/**
* Add categories
*
* @param $categories
*/
private function addCategories($categories)
{
$categories = self::filterRecursive($categories);
foreach ($categories as $category) {
if (!array_key_exists('name', $category) || !array_key_exists('id', $category)) {
continue;
}
/** @var SimpleXMLElement $e */
/** @var SimpleXMLElement $cat */
$cat = $this->categories;
$e = $cat->addChild('category');
$e->addAttribute('id', $category['id']);
if (array_key_exists('parentId', $category) && $category['parentId'] > 0) {
$e->addAttribute('parentId', $category['parentId']);
}
$e->addChild('name', $category['name']);
if (array_key_exists('picture', $category)) {
$e->addChild('picture', $category['picture']);
}
}
}
/**
* Add offers
*
* @param $offers
*/
private function addOffers($offers)
{
$offers = self::filterRecursive($offers);
foreach ($offers as $key => $offer) {
if (!array_key_exists('id', $offer)) {
continue;
}
$e = $this->offers->addChild('offer');
$e->addAttribute('id', $offer['id']);
if (!array_key_exists('productId', $offer) || empty($offer['productId'])) {
$offer['productId'] = $offer['id'];
}
$e->addAttribute('productId', $offer['productId']);
if (!empty($offer['quantity'])) {
$e->addAttribute('quantity', (int) $offer['quantity']);
} else {
$e->addAttribute('quantity', 0);
}
if (isset($offer['categoryId']) && $offer['categoryId']) {
if (is_array($offer['categoryId'])) {
foreach ($offer['categoryId'] as $categoryId) {
$e->addChild('categoryId', $categoryId);
}
} else {
$e->addChild('categoryId', $offer['categoryId']);
}
}
if (!array_key_exists('name', $offer) || empty($offer['name'])) {
$offer['name'] = 'Без названия';
}
if (!array_key_exists('productName', $offer) || empty($offer['productName'])) {
$offer['productName'] = $offer['name'];
}
if (array_key_exists('picture', $offer) && !empty($offer['picture'])) {
foreach ($offer['picture'] as $urlImage) {
$e->addChild('picture', $urlImage);
}
}
unset($offer['id'], $offer['productId'], $offer['categoryId'], $offer['quantity'], $offer['picture']);
array_walk($offer, [$this, 'setOffersProperties'], $e);
if (array_key_exists('params', $offer) && !empty($offer['params'])) {
array_walk($offer['params'], [$this, 'setOffersParams'], $e);
}
if (array_key_exists('dimensions', $offer)) {
$e->addChild('dimensions', $offer['dimensions']);
}
if (array_key_exists('weight', $offer)) {
$e->addChild('weight', $offer['weight']);
}
if (array_key_exists('tax', $offer)) {
$e->addChild('vatRate', $offer['tax']);
}
unset($offers[$key]);
}
}
/**
* Set offer properties
*
* @param $value
* @param $key
* @param $e
*/
private function setOffersProperties($value, $key, &$e)
{
if (in_array($key, $this->properties) && $key != 'params') {
/** @var SimpleXMLElement $e */
$e->addChild($key, htmlspecialchars($value));
}
}
/**
* Set offer params
*
* @param $value
* @param $key
* @param $e
*/
private function setOffersParams($value, $key, &$e)
{
if (
array_key_exists('code', $value) &&
array_key_exists('name', $value) &&
array_key_exists('value', $value) &&
!empty($value['code']) &&
!empty($value['name']) &&
!empty($value['value'])
) {
/** @var SimpleXMLElement $e */
$param = $e->addChild('param', htmlspecialchars($value['value']));
$param->addAttribute('code', $value['code']);
$param->addAttribute('name', substr(htmlspecialchars($value['name']), 0, 200));
unset($key);
}
}
/**
* Filter result array
*
* @param $haystack
*
* @return mixed
*/
public static function filterRecursive($haystack)
{
foreach ($haystack as $key => $value) {
if (is_array($value)) {
$haystack[$key] = self::filterRecursive($haystack[$key]);
}
if (
is_null($haystack[$key])
|| $haystack[$key] === ''
|| (is_array($haystack[$key]) && count($haystack[$key]) == 0)
) {
unset($haystack[$key]);
} elseif (!is_array($value)) {
$haystack[$key] = trim($value);
}
}
return $haystack;
}
/**
* Get WC products
* *
* @return void * @return void
*/ */
private function get_wc_products_taxonomies($status_args) private function prepareOffers()
{ {
if (!$status_args) { $productStatuses = $this->getProductStatuses();
$status_args = ['publish'];
if (!$productStatuses) {
$productStatuses = ['publish'];
} }
$attribute_taxonomies = wc_get_attribute_taxonomies(); $page = 1;
$product_attributes = []; $offerAttributes = $this->getOfferAttributes();
foreach ($attribute_taxonomies as $product_attribute) { do {
$attribute_id = wc_attribute_taxonomy_name_by_id(intval($product_attribute->attribute_id)); $products = wc_get_products(
$product_attributes[$attribute_id] = $product_attribute->attribute_label; [
} 'limit' => 1000,
'status' => $productStatuses,
'page' => $page,
'paginate' => true,
]
);
$full_product_list = []; if (empty($products)) {
writeBaseLogs('Can`t get products!');
$products = wc_get_products( return;
[
'limit' => -1,
'status' => $status_args
]
);
foreach ($products as $offer) {
$type = $offer->get_type();
if (strpos($type, 'variable') !== false || strpos($type, 'variation') !== false) {
foreach ($offer->get_children() as $child_id) {
$child_product = wc_get_product($child_id);
if (!$child_product) {
continue;
}
$this->setOffer($full_product_list, $product_attributes, $child_product, $offer);
}
} else {
$this->setOffer($full_product_list, $product_attributes, $offer);
} }
}
if (isset($full_product_list) && $full_product_list) { foreach ($products->products as $offer) {
$this->writeOffers($full_product_list); $type = $offer->get_type();
unset($full_product_list);
} if (strpos($type, 'variable') !== false || strpos($type, 'variation') !== false) {
foreach ($offer->get_children() as $childId) {
$childProduct = wc_get_product($childId);
if (!$childProduct) {
continue;
}
yield $this->getOffer($offerAttributes, $childProduct, $offer);
}
} else {
yield $this->getOffer($offerAttributes, $offer);
}
}
$page++;
} while ($page <= $products->max_num_pages);
} }
/** /**
* Get WC categories * Get WC offer attributes.
* *
* @return array * @return array
*/ */
private function get_wc_categories_taxonomies() private function getOfferAttributes()
{ {
$categories = []; $offerAttributes = [];
$taxonomy = 'product_cat'; $attributeTaxonomies = wc_get_attribute_taxonomies();
$orderby = 'parent';
$show_count = 0; // 1 for yes, 0 for no
$pad_counts = 0; // 1 for yes, 0 for no
$hierarchical = 1; // 1 for yes, 0 for no
$title = '';
$empty = 0;
$args = [ foreach ($attributeTaxonomies as $productAttribute) {
'taxonomy' => $taxonomy, $attributeId = wc_attribute_taxonomy_name_by_id(intval($productAttribute->attribute_id));
'orderby' => $orderby, $offerAttributes[$attributeId] = $productAttribute->attribute_label;
'show_count' => $show_count,
'pad_counts' => $pad_counts,
'hierarchical' => $hierarchical,
'title_li' => $title,
'hide_empty' => $empty
];
$wcatTerms = get_categories($args);
foreach ($wcatTerms as $term) {
$category = [
'id' => $term->term_id,
'parentId' => $term->parent,
'name' => $term->name
];
$thumbnail_id = function_exists('get_term_meta')
? get_term_meta($term->term_id, 'thumbnail_id', true)
: get_woocommerce_term_meta($term->term_id, 'thumbnail_id', true);
$picture = wp_get_attachment_url($thumbnail_id);
if ($picture) {
$category['picture'] = $picture;
}
$categories[] = $category;
} }
return $categories; return $offerAttributes;
} }
/** /**
* Set offer for icml catalog * Get offer for ICML catalog
* *
* @param array $full_product_list * @param array $productAttributes
* @param array $product_attributes
* @param WC_Product $product * @param WC_Product $product
* @param bool | WC_Product_Variable $parent * @param bool | WC_Product_Variable $parent
* *
* @return void * @return array
*/ */
private function setOffer(&$full_product_list, $product_attributes, $product, $parent = false) private function getOffer(array $productAttributes, WC_Product $product, $parent = false)
{ {
$idImages = array_merge([$product->get_image_id()], $product->get_gallery_image_ids()); $idImages = array_merge([$product->get_image_id()], $product->get_gallery_image_ids());
@ -482,12 +184,12 @@ if (!class_exists('WC_Retailcrm_Icml')) :
$params = []; $params = [];
if (!empty($attributes)) { if (!empty($attributes)) {
foreach ($attributes as $attribute_name => $attribute) { foreach ($attributes as $attributeName => $attribute) {
$attributeValue = $product->get_attribute($attribute_name); $attributeValue = $product->get_attribute($attributeName);
if ($attribute['is_visible'] == 1 && !empty($attributeValue)) { if ($attribute['is_visible'] == 1 && !empty($attributeValue)) {
$params[] = [ $params[] = [
'code' => $attribute_name, 'code' => $attributeName,
'name' => $product_attributes[$attribute_name], 'name' => $productAttributes[$attributeName],
'value' => $attributeValue 'value' => $attributeValue
]; ];
} }
@ -550,10 +252,10 @@ if (!class_exists('WC_Retailcrm_Icml')) :
} }
if (isset($this->settings['product_description'])) { if (isset($this->settings['product_description'])) {
$productDescription = $this->getDescription($product); $productDescription = $this->getOfferDescription($product);
if (empty($productDescription) && $parent instanceof WC_Product_Variable) { if (empty($productDescription) && $parent instanceof WC_Product_Variable) {
$this->getDescription($parent); $this->getOfferDescription($parent);
} }
if ($productDescription != '') { if ($productDescription != '') {
@ -572,43 +274,91 @@ if (!class_exists('WC_Retailcrm_Icml')) :
); );
if (isset($productData)) { if (isset($productData)) {
$full_product_list[] = $productData; return $productData;
} }
unset($productData);
} }
/** /**
* Get product statuses * Get product statuses.
* *
* @return array * @return array
*/ */
private function checkPostStatuses() private function getProductStatuses()
{ {
$status_args = []; $statuses = [];
foreach (get_post_statuses() as $key => $value) { foreach (get_post_statuses() as $key => $value) {
if (isset($this->settings['p_' . $key]) && $this->settings['p_' . $key] == WC_Retailcrm_Base::YES) { if (isset($this->settings['p_' . $key]) && $this->settings['p_' . $key] == WC_Retailcrm_Base::YES) {
$status_args[] = $key; $statuses[] = $key;
} }
} }
return $status_args; return $statuses;
} }
/** /**
* Get product description * Get offer description.
* *
* @param WC_Product | WC_Product_Variable $product WC product. * @param WC_Product | WC_Product_Variable $product WC product.
* *
* @return string * @return string
*/ */
private function getDescription($product) private function getOfferDescription($product)
{ {
return $this->settings['product_description'] == 'full' return $this->settings['product_description'] == 'full'
? $product->get_description() ? $product->get_description()
: $product->get_short_description(); : $product->get_short_description();
} }
}
/**
* Prepare WC categories for write.
*
* @return array
*/
private function prepareCategories()
{
$categories = [];
$taxonomy = 'product_cat';
$orderby = 'parent';
$show_count = 0; // 1 for yes, 0 for no
$pad_counts = 0; // 1 for yes, 0 for no
$hierarchical = 1; // 1 for yes, 0 for no
$title = '';
$empty = 0;
$args = [
'taxonomy' => $taxonomy,
'orderby' => $orderby,
'show_count' => $show_count,
'pad_counts' => $pad_counts,
'hierarchical' => $hierarchical,
'title_li' => $title,
'hide_empty' => $empty
];
$wcTerms = get_categories($args);
foreach ($wcTerms as $term) {
$category = [
'id' => $term->term_id,
'parentId' => $term->parent,
'name' => $term->name
];
$thumbnailId = function_exists('get_term_meta')
? get_term_meta($term->term_id, 'thumbnail_id', true)
: get_woocommerce_term_meta($term->term_id, 'thumbnail_id', true);
$picture = wp_get_attachment_url($thumbnailId);
if ($picture) {
$category['picture'] = $picture;
}
$categories[] = $category;
}
return $categories;
}
}
endif; endif;

View File

@ -1,17 +1,17 @@
<?php <?php
/**
* PHP version 5.6
*
* Class WC_Retailcrm_Inventories - Allows manage stocks.
*
* @category Integration
* @author RetailCRM <integration@retailcrm.ru>
* @license http://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see http://help.retailcrm.ru
*/
if (!class_exists('WC_Retailcrm_Inventories')) : if (!class_exists('WC_Retailcrm_Inventories')) :
/**
* PHP version 7.0
*
* Class WC_Retailcrm_Inventories - Allows manage stocks.
*
* @category Integration
* @author RetailCRM <integration@retailcrm.ru>
* @license http://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see http://help.retailcrm.ru
*/
class WC_Retailcrm_Inventories class WC_Retailcrm_Inventories
{ {
/** @var WC_Retailcrm_Client_V5 */ /** @var WC_Retailcrm_Client_V5 */

View File

@ -1,17 +1,17 @@
<?php <?php
/**
* PHP version 5.6
*
* Class WC_Retailcrm_Orders - Allows transfer data orders with CMS.
*
* @category Integration
* @author RetailCRM <integration@retailcrm.ru>
* @license http://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see http://help.retailcrm.ru
*/
if (!class_exists('WC_Retailcrm_Orders')) : if (!class_exists('WC_Retailcrm_Orders')) :
/**
* PHP version 7.0
*
* Class WC_Retailcrm_Orders - Allows transfer data orders with CMS.
*
* @category Integration
* @author RetailCRM <integration@retailcrm.ru>
* @license http://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see http://help.retailcrm.ru
*/
class WC_Retailcrm_Orders class WC_Retailcrm_Orders
{ {
/** @var bool|WC_Retailcrm_Proxy|WC_Retailcrm_Client_V5 */ /** @var bool|WC_Retailcrm_Proxy|WC_Retailcrm_Client_V5 */

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Plugin - Internal plugin settings. * Class WC_Retailcrm_Plugin - Internal plugin settings.
* *
@ -79,7 +80,7 @@ class WC_Retailcrm_Plugin
public function activate() public function activate()
{ {
if (!class_exists('WC_Integration')) { if (!class_exists('WC_Integration')) {
add_action('admin_notices', array(new WC_Integration_Retailcrm(), 'woocommerce_missing_notice')); add_action('admin_notices', [new WC_Integration_Retailcrm(), 'woocommerce_missing_notice']);
return; return;
} }
@ -88,6 +89,10 @@ class WC_Retailcrm_Plugin
require_once(WC_Integration_Retailcrm::checkCustomFile('include/class-wc-retailcrm-icml.php')); require_once(WC_Integration_Retailcrm::checkCustomFile('include/class-wc-retailcrm-icml.php'));
} }
if (!class_exists('WC_Retailcrm_Icml_Writer')) {
require_once(WC_Integration_Retailcrm::checkCustomFile('include/icml/class-wc-retailcrm-icml-writer.php'));
}
if (!class_exists('WC_Retailcrm_Base')) { if (!class_exists('WC_Retailcrm_Base')) {
require_once(WC_Integration_Retailcrm::checkCustomFile('include/class-wc-retailcrm-base.php')); require_once(WC_Integration_Retailcrm::checkCustomFile('include/class-wc-retailcrm-base.php'));
} }

View File

@ -1,17 +1,17 @@
<?php <?php
/**
* PHP version 5.6
*
* Class WC_Retailcrm_Uploader - Allows upload archival orders/customers in CRM.
*
* @category Integration
* @author RetailCRM <integration@retailcrm.ru>
* @license http://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see http://help.retailcrm.ru
*/
if (class_exists('WC_Retailcrm_Uploader') === false) { if (class_exists('WC_Retailcrm_Uploader') === false) {
/**
* PHP version 7.0
*
* Class WC_Retailcrm_Uploader - Allows upload archival orders/customers in CRM.
*
* @category Integration
* @author RetailCRM <integration@retailcrm.ru>
* @license http://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see http://help.retailcrm.ru
*/
class WC_Retailcrm_Uploader class WC_Retailcrm_Uploader
{ {
const RETAILCRM_COUNT_OBJECT_UPLOAD = 50; const RETAILCRM_COUNT_OBJECT_UPLOAD = 50;

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Customer_Switcher - This component provides builder-like interface in order to make it easier to * Class WC_Retailcrm_Customer_Switcher - This component provides builder-like interface in order to make it easier to
* change customer & customer data in the order via retailCRM history. * change customer & customer data in the order via retailCRM history.

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_History_Assembler - Assembles history records into list which closely resembles * Class WC_Retailcrm_History_Assembler - Assembles history records into list which closely resembles
* orders & customers list output from API. * orders & customers list output from API.

View File

@ -1,18 +1,17 @@
<?php <?php
/**
* PHP version 5.6
*
* Class WC_Retailcrm_Logger - Allows display important debug information.
*
* @category Integration
* @author RetailCRM <integration@retailcrm.ru>
* @license http://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see http://help.retailcrm.ru
*/
if (!class_exists('WC_Retailcrm_Logger') && class_exists('WC_Log_Levels')) : if (!class_exists('WC_Retailcrm_Logger') && class_exists('WC_Log_Levels')) :
/** /**
* PHP version 7.0
*
* Class WC_Retailcrm_Logger - Allows display important debug information.
*
* @category Integration
* @author RetailCRM <integration@retailcrm.ru>
* @license http://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see http://help.retailcrm.ru
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
class WC_Retailcrm_Logger class WC_Retailcrm_Logger

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Customer_Address - Builds a billing address for a customer. * Class WC_Retailcrm_Customer_Address - Builds a billing address for a customer.
* *

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Customer_Corporate_Address - Builds a billing address for a corporate customer. * Class WC_Retailcrm_Customer_Corporate_Address - Builds a billing address for a corporate customer.
* *

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_WC_Customer_Builder - It converts retailCRM customer data (array) into WC_Customer. * Class WC_Retailcrm_WC_Customer_Builder - It converts retailCRM customer data (array) into WC_Customer.
* *

View File

@ -0,0 +1,253 @@
<?php
if (!class_exists('WC_Retailcrm_Icml_Writer')) :
/**
* PHP version 7.0
*
* Class WC_Retailcrm_Icml - Generate ICML file (catalog).
*
* @category Integration
* @author RetailCRM <integration@retailcrm.ru>
* @license http://retailcrm.ru Proprietary
* @link http://retailcrm.ru
* @see http://help.retailcrm.ru
*/
class WC_Retailcrm_Icml_Writer
{
private $writer;
public function __construct($tmpFile)
{
$this->writer = new \XMLWriter();
$this->writer->openUri($tmpFile);
}
/**
* Write HEAD in ICML catalog.
*
* @param string $shop
*
* @return void
*/
public function writeHead(string $shop)
{
$this->writer->startDocument('1.0', 'UTF-8');
$this->writer->startElement('yml_catalog'); // start <yml_catalog>
$this->writer->writeAttribute('date', date('Y-m-d H:i:s'));
$this->writer->startElement('shop'); // start <shop>
$this->writer->WriteElement('name', $shop);
}
/**
* Write categories in ICML catalog.
*
* @param array $categories
*
* @return void
*/
public function writeCategories(array $categories)
{
$this->writer->startElement('categories'); // start <categories>
$this->addCategories($categories);
$this->writer->endElement(); // end </categories>
}
/**
* Add category in ICML catalog.
*
* @param array $categories
*
* @return void
*/
private function addCategories(array $categories)
{
foreach ($categories as $category) {
if (!array_key_exists('name', $category) || !array_key_exists('id', $category)) {
continue;
}
$this->writer->startElement('category'); // start <category>
$this->writer->writeAttribute('id', $category['id']);
if (array_key_exists('parentId', $category) && 0 < $category['parentId']) {
$this->writer->writeAttribute('parentId', $category['parentId']);
}
$this->writer->writeElement('name', $category['name']);
if (array_key_exists('picture', $category) && $category['picture']) {
$this->writer->writeElement('picture', $category['picture']);
}
$this->writer->endElement(); // end </category>
}
}
/**
* Write offers in ICML catalog.
*
* @return void
*/
public function writeOffers($offers)
{
$this->writer->startElement('offers'); // start <offers>
$this->addOffers($offers);
$this->writer->endElement(); // end </offers>
}
/**
* Add offer in ICML catalog.
*
* @return void
*/
private function addOffers($offers)
{
foreach ($offers as $offer) {
if (!array_key_exists('id', $offer)) {
continue;
}
$this->writer->startElement('offer'); // start <offer>
if (!array_key_exists('productId', $offer) || empty($offer['productId'])) {
$offer['productId'] = $offer['id'];
}
$this->writer->writeAttribute('id', $offer['id']);
$this->writer->writeAttribute('productId', $offer['productId']);
$this->writer->writeAttribute('quantity', (int) $offer['quantity'] ?? 0);
if (isset($offer['categoryId'])) {
if (is_array($offer['categoryId'])) {
foreach ($offer['categoryId'] as $categoryId) {
$this->writer->writeElement('categoryId', $categoryId);
}
} else {
$this->writer->writeElement('categoryId', $offer['$categoryId']);
}
}
if (!empty($offer['picture'])) {
foreach ($offer['picture'] as $urlImage) {
$this->writer->writeElement('picture', $urlImage);
}
}
if (empty($offer['name'])) {
$offer['name'] = __('Untitled', 'retailcrm');
}
if (empty($offer['productName'])) {
$offer['productName'] = $offer['name'];
}
unset($offer['id'], $offer['productId'], $offer['categoryId'], $offer['quantity'], $offer['picture']);
$this->writeOffersProperties($offer);
if (!empty($offer['params'])) {
$this->writeOffersParams($offer['params']);
}
if (!empty($offer['dimensions'])) {
$this->writer->writeElement('dimensions', $offer['dimensions']);
}
if (!empty($offer['weight'])) {
$this->writer->writeElement('weight', $offer['weight']);
}
if (!empty($offer['tax'])) {
$this->writer->writeElement('vatRate', $offer['tax']);
}
$this->writer->endElement(); // end </offer>
}
}
/**
* Set offer properties.
*
* @param array $offerProperties
*
* @return void
*/
private function writeOffersProperties(array $offerProperties)
{
foreach ($offerProperties as $key => $value) {
if (!in_array($key, WC_Retailcrm_Icml::OFFER_PROPERTIES)) {
continue;
}
if (is_array($value)) {
foreach ($value as $element) {
$this->writer->writeElement($key, $element);
}
} else {
$this->writer->writeElement($key, $value);
}
}
}
/**
* Set offer params.
*
* @param array $offerParams
*
* @return void
*/
private function writeOffersParams(array $offerParams)
{
foreach ($offerParams as $param) {
if (
empty($param['code'])
|| empty($param['name'])
|| empty($param['value'])
) {
continue;
}
$this->writer->startElement('param'); // start <param>
$this->writer->writeAttribute('code', $param['code']);
$this->writer->writeAttribute('name', $param['name']);
$this->writer->text($param['value']);
$this->writer->endElement(); // end </param>
}
}
/**
* Write end tags in ICML catalog.
*
* @return void
*/
public function writeEnd()
{
$this->writer->endElement(); // end </yml_catalog>
$this->writer->endElement(); // end </shop>
$this->writer->endDocument();
}
/**
* Save ICML catalog.
*
* @return void
*/
public function formatXml($tmpfile)
{
$dom = dom_import_simplexml(simplexml_load_file($tmpfile))->ownerDocument;
$dom->formatOutput = true;
$formatted = $dom->saveXML();
unset($dom, $this->writer);
file_put_contents($tmpfile, $formatted);
}
}
endif;

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Interface WC_Retailcrm_Builder_Interface - Main interface for builders. All builders. * Interface WC_Retailcrm_Builder_Interface - Main interface for builders. All builders.
* *

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Customer_Switcher_Result - Holds modified order and customer which was set in the order. * Class WC_Retailcrm_Customer_Switcher_Result - Holds modified order and customer which was set in the order.
* If customer is null, then only order props was updated. Previous customer (if it was registered) * If customer is null, then only order props was updated. Previous customer (if it was registered)
@ -31,7 +32,8 @@ class WC_Retailcrm_Customer_Switcher_Result
$this->wcCustomer = $wcCustomer; $this->wcCustomer = $wcCustomer;
$this->wcOrder = $wcOrder; $this->wcOrder = $wcOrder;
if ((!is_null($this->wcCustomer) && !($this->wcCustomer instanceof WC_Customer)) if (
(!is_null($this->wcCustomer) && !($this->wcCustomer instanceof WC_Customer))
|| !($this->wcOrder instanceof WC_Order) || !($this->wcOrder instanceof WC_Order)
) { ) {
throw new \InvalidArgumentException(sprintf('Incorrect data provided to %s', __CLASS__)); throw new \InvalidArgumentException(sprintf('Incorrect data provided to %s', __CLASS__));

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Customer_Switcher_State - Holds WC_Retailcrm_Customer_Switcher state. * Class WC_Retailcrm_Customer_Switcher_State - Holds WC_Retailcrm_Customer_Switcher state.
* It exists only because we need to comply with builder interface. * It exists only because we need to comply with builder interface.
@ -14,13 +15,13 @@
class WC_Retailcrm_Customer_Switcher_State class WC_Retailcrm_Customer_Switcher_State
{ {
/** @var \WC_Order $wcOrder */ /** @var \WC_Order $wcOrder */
private $wcOrder; private $wcOrder;
/** @var array */ /** @var array */
private $newCustomer; private $newCustomer;
/** @var array */ /** @var array */
private $newContact; private $newContact;
/** @var string $newCompanyName */ /** @var string $newCompanyName */
private $newCompanyName; private $newCompanyName;
@ -183,4 +184,3 @@ class WC_Retailcrm_Customer_Switcher_State
} }
} }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Order_Address - Build address for CRM order. * Class WC_Retailcrm_Order_Address - Build address for CRM order.
* *

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Order_Item - Build items for CRM order. * Class WC_Retailcrm_Order_Item - Build items for CRM order.
* *

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Order_Payment - Build payments for CRM order. * Class WC_Retailcrm_Order_Payment - Build payments for CRM order.
* *

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Order - Build main data for CRM order. * Class WC_Retailcrm_Order - Build main data for CRM order.
* *

Binary file not shown.

Binary file not shown.

View File

@ -2,10 +2,10 @@
Contributors: Simla.com Contributors: Simla.com
Donate link: https://www.simla.com Donate link: https://www.simla.com
Tags: Интеграция, Simla.com, simla Tags: Интеграция, Simla.com, simla
Requires PHP: 5.6 Requires PHP: 7.0
Requires at least: 5.3 Requires at least: 5.3
Tested up to: 6.0 Tested up to: 6.0
Stable tag: 4.4.9 Stable tag: 4.5.0
License: GPLv1 or later License: GPLv1 or later
License URI: http://www.gnu.org/licenses/gpl-1.0.html License URI: http://www.gnu.org/licenses/gpl-1.0.html
@ -82,6 +82,12 @@ Asegúrate de tener una clave API específica para cada tienda. Las siguientes i
== Changelog == == Changelog ==
= 4.5.0 =
* Fix path for js scripts
* Migrating to PHP 7.0.
* Change logic work with ICML catalog: added streaming generation, added generators in the ICML generation process.
* Change logic work with address
= 4.4.9 = = 4.4.9 =
* Fix bug with product tax * Fix bug with product tax

View File

@ -5,7 +5,7 @@
* Description: Integration plugin for WooCommerce & Simla.com * Description: Integration plugin for WooCommerce & Simla.com
* Author: RetailDriver LLC * Author: RetailDriver LLC
* Author URI: http://retailcrm.pro/ * Author URI: http://retailcrm.pro/
* Version: 4.4.9 * Version: 4.5.0
* Tested up to: 6.0 * Tested up to: 6.0
* WC requires at least: 5.4 * WC requires at least: 5.4
* WC tested up to: 6.7 * WC tested up to: 6.7
@ -45,9 +45,9 @@ if (!class_exists( 'WC_Integration_Retailcrm')) :
if (class_exists( 'WC_Integration' )) { if (class_exists( 'WC_Integration' )) {
self::load_module(); self::load_module();
add_filter('woocommerce_integrations', array( $this, 'add_integration')); add_filter('woocommerce_integrations', [$this, 'add_integration']);
} else { } else {
add_action('admin_notices', array($this, 'woocommerce_missing_notice')); add_action('admin_notices', [$this, 'woocommerce_missing_notice']);
} }
} }
@ -117,6 +117,7 @@ if (!class_exists( 'WC_Integration_Retailcrm')) :
require_once(self::checkCustomFile('include/customer/class-wc-retailcrm-customer-address.php')); require_once(self::checkCustomFile('include/customer/class-wc-retailcrm-customer-address.php'));
require_once(self::checkCustomFile('include/customer/class-wc-retailcrm-customer-corporate-address.php')); require_once(self::checkCustomFile('include/customer/class-wc-retailcrm-customer-corporate-address.php'));
require_once(self::checkCustomFile('include/class-wc-retailcrm-icml.php')); require_once(self::checkCustomFile('include/class-wc-retailcrm-icml.php'));
require_once(self::checkCustomFile('include/icml/class-wc-retailcrm-icml-writer.php'));
require_once(self::checkCustomFile('include/class-wc-retailcrm-orders.php')); require_once(self::checkCustomFile('include/class-wc-retailcrm-orders.php'));
require_once(self::checkCustomFile('include/class-wc-retailcrm-customers.php')); require_once(self::checkCustomFile('include/class-wc-retailcrm-customers.php'));
require_once(self::checkCustomFile('include/class-wc-retailcrm-inventories.php')); require_once(self::checkCustomFile('include/class-wc-retailcrm-inventories.php'));
@ -186,10 +187,10 @@ if (!class_exists( 'WC_Integration_Retailcrm')) :
return wp_nonce_url( return wp_nonce_url(
add_query_arg( add_query_arg(
array( [
'action' => $action, 'action' => $action,
'plugin' => $pluginSlug 'plugin' => $pluginSlug
), ],
admin_url( 'update.php' ) admin_url( 'update.php' )
), ),
$action.'_'.$pluginSlug $action.'_'.$pluginSlug
@ -205,5 +206,5 @@ if (!class_exists( 'WC_Integration_Retailcrm')) :
$plugin->register_activation_hook(); $plugin->register_activation_hook();
$plugin->register_deactivation_hook(); $plugin->register_deactivation_hook();
add_action('plugins_loaded', array('WC_Integration_Retailcrm', 'get_instance'), 0); add_action('plugins_loaded', ['WC_Integration_Retailcrm', 'get_instance'], 0);
endif; endif;

View File

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

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Abstracts_Settings_Test - Testing WC_Retailcrm_Abstracts_Settings. * Class WC_Retailcrm_Abstracts_Settings_Test - Testing WC_Retailcrm_Abstracts_Settings.
* *

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Customer_Address_Test - Testing WC_Retailcrm_Customer_Address. * Class WC_Retailcrm_Customer_Address_Test - Testing WC_Retailcrm_Customer_Address.
* *

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Customer_Corporate_Address_Test - Testing WC_Retailcrm_Customer_Corporate_Address. * Class WC_Retailcrm_Customer_Corporate_Address_Test - Testing WC_Retailcrm_Customer_Corporate_Address.
* *

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_WC_Customer_Builder_Test - Testing WC_Retailcrm_WC_Customer_Builder. * Class WC_Retailcrm_WC_Customer_Builder_Test - Testing WC_Retailcrm_WC_Customer_Builder.
* *

View File

@ -3,7 +3,7 @@
namespace datasets; namespace datasets;
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class DataBaseRetailCrm - Data set for WC_Retailcrm_Base. * Class DataBaseRetailCrm - Data set for WC_Retailcrm_Base.
* *

View File

@ -3,7 +3,7 @@
namespace datasets; namespace datasets;
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class DataCustomersRetailCrm - Data set for WC_Retailcrm_Customers. * Class DataCustomersRetailCrm - Data set for WC_Retailcrm_Customers.
* *

View File

@ -3,7 +3,7 @@
namespace datasets; namespace datasets;
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class DataHistoryRetailCrm - Data set for WC_Retailcrm_History. * Class DataHistoryRetailCrm - Data set for WC_Retailcrm_History.
* *

View File

@ -3,7 +3,7 @@
namespace datasets; namespace datasets;
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class DataInventoriesRetailCrm - Data set for WC_Retailcrm_Inventories. * Class DataInventoriesRetailCrm - Data set for WC_Retailcrm_Inventories.
* *

View File

@ -1,6 +1,11 @@
<?php <?php
if (!defined( 'ABSPATH')) {
exit;
}
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Log_Handler_Stdout - Handles log entries by writing to a stdout. * Class WC_Retailcrm_Log_Handler_Stdout - Handles log entries by writing to a stdout.
* *
@ -10,11 +15,6 @@
* @link http://retailcrm.ru * @link http://retailcrm.ru
* @see http://help.retailcrm.ru * @see http://help.retailcrm.ru
*/ */
if (!defined( 'ABSPATH')) {
exit;
}
class WC_Retailcrm_Log_Handler_Stdout extends WC_Log_Handler class WC_Retailcrm_Log_Handler_Stdout extends WC_Log_Handler
{ {
/** /**

View File

@ -1,6 +1,11 @@
<?php <?php
if (!class_exists('WC_Retailcrm_Response')) {
require_once dirname(__FILE__) . '/../../src/include/api/class-wc-retailcrm-response.php';
}
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Response_Helper - Set response for mock object. * Class WC_Retailcrm_Response_Helper - Set response for mock object.
* *
@ -10,11 +15,6 @@
* @link http://retailcrm.ru * @link http://retailcrm.ru
* @see http://help.retailcrm.ru * @see http://help.retailcrm.ru
*/ */
if (!class_exists('WC_Retailcrm_Response')) {
require_once dirname(__FILE__) . '/../../src/include/api/class-wc-retailcrm-response.php';
}
class WC_Retailcrm_Response_Helper extends WC_Retailcrm_Response class WC_Retailcrm_Response_Helper extends WC_Retailcrm_Response
{ {
public function setResponse($response) public function setResponse($response)

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Test_Case_Helper - Helper for testing. * Class WC_Retailcrm_Test_Case_Helper - Helper for testing.
* *

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Customer_Switcher_Result_Test - Testing WC_Retailcrm_Customer_Switcher_Result. * Class WC_Retailcrm_Customer_Switcher_Result_Test - Testing WC_Retailcrm_Customer_Switcher_Result.
* *

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Customer_Switcher_State_Test - Testing WC_Retailcrm_Customer_Switcher_State. * Class WC_Retailcrm_Customer_Switcher_State_Test - Testing WC_Retailcrm_Customer_Switcher_State.
* *

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Order_Address_Test - Testing WC_Retailcrm_Order_Address. * Class WC_Retailcrm_Order_Address_Test - Testing WC_Retailcrm_Order_Address.
* *

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Order_Item_Test - Testing WC_Retailcrm_Order_Item. * Class WC_Retailcrm_Order_Item_Test - Testing WC_Retailcrm_Order_Item.
* *

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Order_Payment_Test - Testing WC_Retailcrm_Order_Payment. * Class WC_Retailcrm_Order_Payment_Test - Testing WC_Retailcrm_Order_Payment.
* *

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Order_Test - Testing WC_Retailcrm_Order. * Class WC_Retailcrm_Order_Test - Testing WC_Retailcrm_Order.
* *

View File

@ -3,7 +3,7 @@
use datasets\DataBaseRetailCrm; use datasets\DataBaseRetailCrm;
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Base_Test - Testing WC_Retailcrm_Base. * Class WC_Retailcrm_Base_Test - Testing WC_Retailcrm_Base.
* *

View File

@ -3,7 +3,7 @@
use datasets\DataCustomersRetailCrm; use datasets\DataCustomersRetailCrm;
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Customers_Test - Testing WC_Retailcrm_Customers. * Class WC_Retailcrm_Customers_Test - Testing WC_Retailcrm_Customers.
* *

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Daemon_Collector_Test - Testing WC_Retailcrm_Daemon_Collector. * Class WC_Retailcrm_Daemon_Collector_Test - Testing WC_Retailcrm_Daemon_Collector.
* *

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Google_Analytics_Test - Testing WC_Retailcrm_Google_Analytics. * Class WC_Retailcrm_Google_Analytics_Test - Testing WC_Retailcrm_Google_Analytics.
* *

View File

@ -3,7 +3,7 @@
use datasets\DataHistoryRetailCrm; use datasets\DataHistoryRetailCrm;
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_History_Test - Testing WC_Retailcrm_History. * Class WC_Retailcrm_History_Test - Testing WC_Retailcrm_History.
* *

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Icml_Test - Testing WC_Retailcrm_Icml. * Class WC_Retailcrm_Icml_Test - Testing WC_Retailcrm_Icml.
* *

View File

@ -3,7 +3,7 @@
use datasets\DataInventoriesRetailCrm; use datasets\DataInventoriesRetailCrm;
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Inventories_Test - Testing WC_Retailcrm_Inventories. * Class WC_Retailcrm_Inventories_Test - Testing WC_Retailcrm_Inventories.
* *

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Orders_Test - Testing WC_Retailcrm_Orders. * Class WC_Retailcrm_Orders_Test - Testing WC_Retailcrm_Orders.
* *

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Plugin_Test - Testing WC_Retailcrm_Plugin. * Class WC_Retailcrm_Plugin_Test - Testing WC_Retailcrm_Plugin.
* *

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHP version 5.6 * PHP version 7.0
* *
* Class WC_Retailcrm_Uploader_Test - Testing WC_Retailcrm_Uploader. * Class WC_Retailcrm_Uploader_Test - Testing WC_Retailcrm_Uploader.
* *