Add generators in the ICML generation process
This commit is contained in:
parent
222f5efde1
commit
769907d812
@ -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
|
||||
* Fix bug with product tax
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
[![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)
|
||||
[![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
|
||||
==================
|
||||
|
@ -10,7 +10,8 @@
|
||||
],
|
||||
"minimum-stability": "dev",
|
||||
"require": {
|
||||
"ext-simplexml": "*"
|
||||
"ext-simplexml": "*",
|
||||
"ext-xmlwriter": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-json": "*",
|
||||
|
@ -339,3 +339,6 @@ msgstr "Borrar"
|
||||
|
||||
msgid "Cron tasks cleared"
|
||||
msgstr "Trabajos cron borrados"
|
||||
|
||||
msgid "Untitled"
|
||||
msgstr "Intitulado"
|
@ -348,3 +348,7 @@ msgstr "Очистить"
|
||||
|
||||
msgid "Cron tasks cleared"
|
||||
msgstr "Cron задачи очищены"
|
||||
|
||||
msgid "Untitled"
|
||||
msgstr "Без названия"
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Abstract_Builder - Builds data for CRM.
|
||||
*
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Abstracts_Address - Builds data for addresses orders/customers.
|
||||
*
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Abstracts_Data - Class manage different data.
|
||||
*
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Abstracts_Settings - Settings plugin Simla.
|
||||
*
|
||||
|
@ -1,17 +1,5 @@
|
||||
<?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')) {
|
||||
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'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
protected $client;
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Exception_Curl.
|
||||
*
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Exception_Json.
|
||||
*
|
||||
|
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP version 5.6
|
||||
|
||||
if (!class_exists('WC_Retailcrm_Proxy')) :
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Proxy - RetailCRM Integration.
|
||||
*
|
||||
@ -10,8 +12,6 @@
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
if (!class_exists('WC_Retailcrm_Proxy')) :
|
||||
class WC_Retailcrm_Proxy
|
||||
{
|
||||
protected $retailcrm;
|
||||
|
@ -1,15 +1,4 @@
|
||||
<?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')) {
|
||||
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'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
const METHOD_GET = 'GET';
|
||||
|
@ -1,6 +1,11 @@
|
||||
<?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.
|
||||
*
|
||||
@ -10,11 +15,6 @@
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @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
|
||||
{
|
||||
// HTTP response status code
|
||||
|
@ -1,7 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
if (!class_exists('WC_Retailcrm_Base')) {
|
||||
if (!class_exists('WC_Retailcrm_Abstracts_Settings')) {
|
||||
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.
|
||||
*
|
||||
@ -11,12 +16,6 @@
|
||||
* @link http://retailcrm.ru
|
||||
* @see http://help.retailcrm.ru
|
||||
*/
|
||||
|
||||
if (!class_exists('WC_Retailcrm_Base')) {
|
||||
if (!class_exists('WC_Retailcrm_Abstracts_Settings')) {
|
||||
include_once(WC_Integration_Retailcrm::checkCustomFile('include/abstracts/class-wc-retailcrm-abstracts-settings.php'));
|
||||
}
|
||||
|
||||
class WC_Retailcrm_Base extends WC_Retailcrm_Abstracts_Settings
|
||||
{
|
||||
/** @var WC_Retailcrm_Proxy|WC_Retailcrm_Client_V5|bool */
|
||||
|
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP version 5.6
|
||||
|
||||
if (!class_exists('WC_Retailcrm_Customers')) :
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Customers - Allows transfer data customers with CMS.
|
||||
*
|
||||
@ -10,8 +12,6 @@
|
||||
* @link http://retailcrm.ru
|
||||
* @see http://help.retailcrm.ru
|
||||
*/
|
||||
|
||||
if (!class_exists('WC_Retailcrm_Customers')) :
|
||||
class WC_Retailcrm_Customers
|
||||
{
|
||||
/** @var bool | WC_Retailcrm_Proxy | \WC_Retailcrm_Client_V5 */
|
||||
|
@ -1,6 +1,11 @@
|
||||
<?php
|
||||
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Daemon_Collector - Integration with Daemon Collector.
|
||||
*
|
||||
@ -10,11 +15,6 @@
|
||||
* @link http://retailcrm.ru
|
||||
* @see http://help.retailcrm.ru
|
||||
*/
|
||||
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class WC_Retailcrm_Daemon_Collector {
|
||||
/** @var self $instance */
|
||||
private static $instance;
|
||||
|
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP version 5.6
|
||||
|
||||
if (!class_exists('WC_Retailcrm_Google_Analytics')) {
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Google_Analytics - Integration with Google Analytics.
|
||||
*
|
||||
@ -10,8 +12,6 @@
|
||||
* @link http://retailcrm.ru
|
||||
* @see http://help.retailcrm.ru
|
||||
*/
|
||||
|
||||
if (!class_exists('WC_Retailcrm_Google_Analytics')) {
|
||||
class WC_Retailcrm_Google_Analytics {
|
||||
private static $instance;
|
||||
private $options;
|
||||
|
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
if (!class_exists('WC_Retailcrm_History')) :
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_History - Allows transfer data orders/customers with CRM.
|
||||
*
|
||||
@ -11,8 +12,6 @@
|
||||
* @link http://retailcrm.ru
|
||||
* @see http://help.retailcrm.ru
|
||||
*/
|
||||
|
||||
if (!class_exists('WC_Retailcrm_History')) :
|
||||
class WC_Retailcrm_History
|
||||
{
|
||||
const PAGE_LIMIT = 25;
|
||||
|
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
if (!class_exists('WC_Retailcrm_Icml')) :
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Icml - Generate ICML file (catalog).
|
||||
*
|
||||
@ -11,15 +12,9 @@
|
||||
* @link http://retailcrm.ru
|
||||
* @see http://help.retailcrm.ru
|
||||
*/
|
||||
|
||||
if (!class_exists('WC_Retailcrm_Icml')) :
|
||||
class WC_Retailcrm_Icml
|
||||
{
|
||||
protected $shop;
|
||||
protected $file;
|
||||
protected $tmpFile;
|
||||
|
||||
protected $properties = [
|
||||
const OFFER_PROPERTIES = [
|
||||
'name',
|
||||
'productName',
|
||||
'price',
|
||||
@ -31,19 +26,11 @@ if (!class_exists('WC_Retailcrm_Icml')) :
|
||||
'productActivity'
|
||||
];
|
||||
|
||||
protected $xml;
|
||||
|
||||
/** @var SimpleXMLElement $categories */
|
||||
protected $categories;
|
||||
|
||||
/** @var SimpleXMLElement $categories */
|
||||
protected $offers;
|
||||
|
||||
protected $chunk = 500;
|
||||
protected $fileLifeTime = 3600;
|
||||
|
||||
/** @var array */
|
||||
protected $shop;
|
||||
protected $file;
|
||||
protected $tmpFile;
|
||||
protected $settings;
|
||||
protected $icmlWriter;
|
||||
|
||||
/**
|
||||
* WC_Retailcrm_Icml constructor.
|
||||
@ -51,410 +38,125 @@ if (!class_exists('WC_Retailcrm_Icml')) :
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->settings = get_option(WC_Retailcrm_Base::$option_key);
|
||||
$this->shop = get_bloginfo('name');
|
||||
$this->file = ABSPATH . 'simla.xml';
|
||||
$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()
|
||||
{
|
||||
$categories = $this->get_wc_categories_taxonomies();
|
||||
$this->icmlWriter->writeHead($this->shop);
|
||||
|
||||
if (file_exists($this->tmpFile)) {
|
||||
if (filectime($this->tmpFile) + $this->fileLifeTime < time()) {
|
||||
unlink($this->tmpFile);
|
||||
$this->writeHead();
|
||||
}
|
||||
} else {
|
||||
$this->writeHead();
|
||||
$categories = $this->prepareCategories();
|
||||
|
||||
if (empty($categories)) {
|
||||
writeBaseLogs('Can`t get categories!');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!empty($categories)) {
|
||||
$this->writeCategories($categories);
|
||||
unset($categories);
|
||||
$this->icmlWriter->writeCategories($categories);
|
||||
|
||||
$offers = $this->prepareOffers();
|
||||
|
||||
if (empty($offers)) {
|
||||
writeBaseLogs('Can`t get offers!');
|
||||
return;
|
||||
}
|
||||
|
||||
$status_args = $this->checkPostStatuses();
|
||||
$this->get_wc_products_taxonomies($status_args);
|
||||
$this->icmlWriter->writeOffers($offers);
|
||||
|
||||
$dom = dom_import_simplexml(simplexml_load_file($this->tmpFile))->ownerDocument;
|
||||
$this->icmlWriter->writeEnd();
|
||||
$this->icmlWriter->formatXml($this->tmpFile);
|
||||
|
||||
$dom->formatOutput = true;
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write products in file
|
||||
*
|
||||
* @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
|
||||
* Prepare WC offers for write.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function get_wc_products_taxonomies($status_args)
|
||||
private function prepareOffers()
|
||||
{
|
||||
if (!$status_args) {
|
||||
$status_args = ['publish'];
|
||||
$productStatuses = $this->getProductStatuses();
|
||||
|
||||
if (!$productStatuses) {
|
||||
$productStatuses = ['publish'];
|
||||
}
|
||||
|
||||
$attribute_taxonomies = wc_get_attribute_taxonomies();
|
||||
$product_attributes = [];
|
||||
|
||||
foreach ($attribute_taxonomies as $product_attribute) {
|
||||
$attribute_id = wc_attribute_taxonomy_name_by_id(intval($product_attribute->attribute_id));
|
||||
$product_attributes[$attribute_id] = $product_attribute->attribute_label;
|
||||
}
|
||||
|
||||
$full_product_list = [];
|
||||
$page = 1;
|
||||
$offerAttributes = $this->getOfferAttributes();
|
||||
|
||||
do {
|
||||
$products = wc_get_products(
|
||||
[
|
||||
'limit' => -1,
|
||||
'status' => $status_args
|
||||
'limit' => 1000,
|
||||
'status' => $productStatuses,
|
||||
'page' => $page,
|
||||
'paginate' => true,
|
||||
]
|
||||
);
|
||||
|
||||
foreach ($products as $offer) {
|
||||
if (empty($products)) {
|
||||
writeBaseLogs('Can`t get products!');
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($products->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) {
|
||||
foreach ($offer->get_children() as $childId) {
|
||||
$childProduct = wc_get_product($childId);
|
||||
|
||||
if (!$childProduct) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->setOffer($full_product_list, $product_attributes, $child_product, $offer);
|
||||
yield $this->getOffer($offerAttributes, $childProduct, $offer);
|
||||
}
|
||||
} else {
|
||||
$this->setOffer($full_product_list, $product_attributes, $offer);
|
||||
yield $this->getOffer($offerAttributes, $offer);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($full_product_list) && $full_product_list) {
|
||||
$this->writeOffers($full_product_list);
|
||||
unset($full_product_list);
|
||||
}
|
||||
$page++;
|
||||
} while ($page <= $products->max_num_pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get WC categories
|
||||
* Get WC offer attributes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function get_wc_categories_taxonomies()
|
||||
private function getOfferAttributes()
|
||||
{
|
||||
$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;
|
||||
$offerAttributes = [];
|
||||
$attributeTaxonomies = wc_get_attribute_taxonomies();
|
||||
|
||||
$args = [
|
||||
'taxonomy' => $taxonomy,
|
||||
'orderby' => $orderby,
|
||||
'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;
|
||||
foreach ($attributeTaxonomies as $productAttribute) {
|
||||
$attributeId = wc_attribute_taxonomy_name_by_id(intval($productAttribute->attribute_id));
|
||||
$offerAttributes[$attributeId] = $productAttribute->attribute_label;
|
||||
}
|
||||
|
||||
$categories[] = $category;
|
||||
}
|
||||
|
||||
return $categories;
|
||||
return $offerAttributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set offer for icml catalog
|
||||
* Get offer for ICML catalog
|
||||
*
|
||||
* @param array $full_product_list
|
||||
* @param array $product_attributes
|
||||
* @param array $productAttributes
|
||||
* @param WC_Product $product
|
||||
* @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());
|
||||
|
||||
@ -482,12 +184,12 @@ if (!class_exists('WC_Retailcrm_Icml')) :
|
||||
$params = [];
|
||||
|
||||
if (!empty($attributes)) {
|
||||
foreach ($attributes as $attribute_name => $attribute) {
|
||||
$attributeValue = $product->get_attribute($attribute_name);
|
||||
foreach ($attributes as $attributeName => $attribute) {
|
||||
$attributeValue = $product->get_attribute($attributeName);
|
||||
if ($attribute['is_visible'] == 1 && !empty($attributeValue)) {
|
||||
$params[] = [
|
||||
'code' => $attribute_name,
|
||||
'name' => $product_attributes[$attribute_name],
|
||||
'code' => $attributeName,
|
||||
'name' => $productAttributes[$attributeName],
|
||||
'value' => $attributeValue
|
||||
];
|
||||
}
|
||||
@ -550,10 +252,10 @@ if (!class_exists('WC_Retailcrm_Icml')) :
|
||||
}
|
||||
|
||||
if (isset($this->settings['product_description'])) {
|
||||
$productDescription = $this->getDescription($product);
|
||||
$productDescription = $this->getOfferDescription($product);
|
||||
|
||||
if (empty($productDescription) && $parent instanceof WC_Product_Variable) {
|
||||
$this->getDescription($parent);
|
||||
$this->getOfferDescription($parent);
|
||||
}
|
||||
|
||||
if ($productDescription != '') {
|
||||
@ -572,43 +274,91 @@ if (!class_exists('WC_Retailcrm_Icml')) :
|
||||
);
|
||||
|
||||
if (isset($productData)) {
|
||||
$full_product_list[] = $productData;
|
||||
return $productData;
|
||||
}
|
||||
|
||||
unset($productData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get product statuses
|
||||
* Get product statuses.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function checkPostStatuses()
|
||||
private function getProductStatuses()
|
||||
{
|
||||
$status_args = [];
|
||||
$statuses = [];
|
||||
|
||||
foreach (get_post_statuses() as $key => $value) {
|
||||
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.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getDescription($product)
|
||||
private function getOfferDescription($product)
|
||||
{
|
||||
return $this->settings['product_description'] == 'full'
|
||||
? $product->get_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;
|
||||
|
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP version 5.6
|
||||
|
||||
if (!class_exists('WC_Retailcrm_Inventories')) :
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Inventories - Allows manage stocks.
|
||||
*
|
||||
@ -10,8 +12,6 @@
|
||||
* @link http://retailcrm.ru
|
||||
* @see http://help.retailcrm.ru
|
||||
*/
|
||||
|
||||
if (!class_exists('WC_Retailcrm_Inventories')) :
|
||||
class WC_Retailcrm_Inventories
|
||||
{
|
||||
/** @var WC_Retailcrm_Client_V5 */
|
||||
|
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP version 5.6
|
||||
|
||||
if (!class_exists('WC_Retailcrm_Orders')) :
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Orders - Allows transfer data orders with CMS.
|
||||
*
|
||||
@ -10,8 +12,6 @@
|
||||
* @link http://retailcrm.ru
|
||||
* @see http://help.retailcrm.ru
|
||||
*/
|
||||
|
||||
if (!class_exists('WC_Retailcrm_Orders')) :
|
||||
class WC_Retailcrm_Orders
|
||||
{
|
||||
/** @var bool|WC_Retailcrm_Proxy|WC_Retailcrm_Client_V5 */
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Plugin - Internal plugin settings.
|
||||
*
|
||||
@ -79,7 +80,7 @@ class WC_Retailcrm_Plugin
|
||||
public function activate()
|
||||
{
|
||||
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;
|
||||
}
|
||||
@ -88,6 +89,10 @@ class WC_Retailcrm_Plugin
|
||||
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')) {
|
||||
require_once(WC_Integration_Retailcrm::checkCustomFile('include/class-wc-retailcrm-base.php'));
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP version 5.6
|
||||
|
||||
if (class_exists('WC_Retailcrm_Uploader') === false) {
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Uploader - Allows upload archival orders/customers in CRM.
|
||||
*
|
||||
@ -10,8 +12,6 @@
|
||||
* @link http://retailcrm.ru
|
||||
* @see http://help.retailcrm.ru
|
||||
*/
|
||||
|
||||
if (class_exists('WC_Retailcrm_Uploader') === false) {
|
||||
class WC_Retailcrm_Uploader
|
||||
{
|
||||
const RETAILCRM_COUNT_OBJECT_UPLOAD = 50;
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?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
|
||||
* change customer & customer data in the order via retailCRM history.
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_History_Assembler - Assembles history records into list which closely resembles
|
||||
* orders & customers list output from API.
|
||||
|
@ -1,6 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP version 5.6
|
||||
|
||||
if (!class_exists('WC_Retailcrm_Logger') && class_exists('WC_Log_Levels')) :
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Logger - Allows display important debug information.
|
||||
*
|
||||
@ -9,10 +12,6 @@
|
||||
* @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')) :
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class WC_Retailcrm_Logger
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Customer_Address - Builds a billing address for a customer.
|
||||
*
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Customer_Corporate_Address - Builds a billing address for a corporate customer.
|
||||
*
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_WC_Customer_Builder - It converts retailCRM customer data (array) into WC_Customer.
|
||||
*
|
||||
|
253
src/include/icml/class-wc-retailcrm-icml-writer.php
Normal file
253
src/include/icml/class-wc-retailcrm-icml-writer.php
Normal 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;
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Interface WC_Retailcrm_Builder_Interface - Main interface for builders. All builders.
|
||||
*
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?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.
|
||||
* 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->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)
|
||||
) {
|
||||
throw new \InvalidArgumentException(sprintf('Incorrect data provided to %s', __CLASS__));
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Customer_Switcher_State - Holds WC_Retailcrm_Customer_Switcher state.
|
||||
* It exists only because we need to comply with builder interface.
|
||||
@ -183,4 +184,3 @@ class WC_Retailcrm_Customer_Switcher_State
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Order_Address - Build address for CRM order.
|
||||
*
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Order_Item - Build items for CRM order.
|
||||
*
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Order_Payment - Build payments for CRM order.
|
||||
*
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Order - Build main data for CRM order.
|
||||
*
|
||||
|
Binary file not shown.
Binary file not shown.
@ -2,10 +2,10 @@
|
||||
Contributors: Simla.com
|
||||
Donate link: https://www.simla.com
|
||||
Tags: Интеграция, Simla.com, simla
|
||||
Requires PHP: 5.6
|
||||
Requires PHP: 7.0
|
||||
Requires at least: 5.3
|
||||
Tested up to: 6.0
|
||||
Stable tag: 4.4.9
|
||||
Stable tag: 4.5.0
|
||||
License: GPLv1 or later
|
||||
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 ==
|
||||
= 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 =
|
||||
* Fix bug with product tax
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Description: Integration plugin for WooCommerce & Simla.com
|
||||
* Author: RetailDriver LLC
|
||||
* Author URI: http://retailcrm.pro/
|
||||
* Version: 4.4.9
|
||||
* Version: 4.5.0
|
||||
* Tested up to: 6.0
|
||||
* WC requires at least: 5.4
|
||||
* WC tested up to: 6.7
|
||||
@ -45,9 +45,9 @@ if (!class_exists( 'WC_Integration_Retailcrm')) :
|
||||
|
||||
if (class_exists( 'WC_Integration' )) {
|
||||
self::load_module();
|
||||
add_filter('woocommerce_integrations', array( $this, 'add_integration'));
|
||||
add_filter('woocommerce_integrations', [$this, 'add_integration']);
|
||||
} 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-corporate-address.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-customers.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(
|
||||
add_query_arg(
|
||||
array(
|
||||
[
|
||||
'action' => $action,
|
||||
'plugin' => $pluginSlug
|
||||
),
|
||||
],
|
||||
admin_url( 'update.php' )
|
||||
),
|
||||
$action.'_'.$pluginSlug
|
||||
@ -205,5 +206,5 @@ if (!class_exists( 'WC_Integration_Retailcrm')) :
|
||||
$plugin->register_activation_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;
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @link https://wordpress.org/plugins/woo-retailcrm/
|
||||
*
|
||||
* @version 4.4.9
|
||||
* @version 4.5.0
|
||||
*
|
||||
* @package RetailCRM
|
||||
*/
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Abstracts_Settings_Test - Testing WC_Retailcrm_Abstracts_Settings.
|
||||
*
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Customer_Address_Test - Testing WC_Retailcrm_Customer_Address.
|
||||
*
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Customer_Corporate_Address_Test - Testing WC_Retailcrm_Customer_Corporate_Address.
|
||||
*
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_WC_Customer_Builder_Test - Testing WC_Retailcrm_WC_Customer_Builder.
|
||||
*
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace datasets;
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class DataBaseRetailCrm - Data set for WC_Retailcrm_Base.
|
||||
*
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace datasets;
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class DataCustomersRetailCrm - Data set for WC_Retailcrm_Customers.
|
||||
*
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace datasets;
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class DataHistoryRetailCrm - Data set for WC_Retailcrm_History.
|
||||
*
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace datasets;
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class DataInventoriesRetailCrm - Data set for WC_Retailcrm_Inventories.
|
||||
*
|
||||
|
@ -1,6 +1,11 @@
|
||||
<?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.
|
||||
*
|
||||
@ -10,11 +15,6 @@
|
||||
* @link http://retailcrm.ru
|
||||
* @see http://help.retailcrm.ru
|
||||
*/
|
||||
|
||||
if (!defined( 'ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class WC_Retailcrm_Log_Handler_Stdout extends WC_Log_Handler
|
||||
{
|
||||
/**
|
||||
|
@ -1,6 +1,11 @@
|
||||
<?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.
|
||||
*
|
||||
@ -10,11 +15,6 @@
|
||||
* @link http://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
|
||||
{
|
||||
public function setResponse($response)
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Test_Case_Helper - Helper for testing.
|
||||
*
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Customer_Switcher_Result_Test - Testing WC_Retailcrm_Customer_Switcher_Result.
|
||||
*
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Customer_Switcher_State_Test - Testing WC_Retailcrm_Customer_Switcher_State.
|
||||
*
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Order_Address_Test - Testing WC_Retailcrm_Order_Address.
|
||||
*
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Order_Item_Test - Testing WC_Retailcrm_Order_Item.
|
||||
*
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Order_Payment_Test - Testing WC_Retailcrm_Order_Payment.
|
||||
*
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Order_Test - Testing WC_Retailcrm_Order.
|
||||
*
|
||||
|
@ -3,7 +3,7 @@
|
||||
use datasets\DataBaseRetailCrm;
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Base_Test - Testing WC_Retailcrm_Base.
|
||||
*
|
||||
|
@ -3,7 +3,7 @@
|
||||
use datasets\DataCustomersRetailCrm;
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Customers_Test - Testing WC_Retailcrm_Customers.
|
||||
*
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Daemon_Collector_Test - Testing WC_Retailcrm_Daemon_Collector.
|
||||
*
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Google_Analytics_Test - Testing WC_Retailcrm_Google_Analytics.
|
||||
*
|
||||
|
@ -3,7 +3,7 @@
|
||||
use datasets\DataHistoryRetailCrm;
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_History_Test - Testing WC_Retailcrm_History.
|
||||
*
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Icml_Test - Testing WC_Retailcrm_Icml.
|
||||
*
|
||||
|
@ -3,7 +3,7 @@
|
||||
use datasets\DataInventoriesRetailCrm;
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Inventories_Test - Testing WC_Retailcrm_Inventories.
|
||||
*
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Orders_Test - Testing WC_Retailcrm_Orders.
|
||||
*
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Plugin_Test - Testing WC_Retailcrm_Plugin.
|
||||
*
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class WC_Retailcrm_Uploader_Test - Testing WC_Retailcrm_Uploader.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user