1
0
mirror of synced 2025-01-19 01:11:42 +03:00

Weight and dimensions in icml (#41)

This commit is contained in:
Akolzin Dmitry 2017-12-18 15:19:04 +02:00 committed by Alex Lushpai
parent a06a7d5fba
commit 2aed9a81eb
4 changed files with 305 additions and 265 deletions

View File

@ -142,6 +142,7 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) :
$this->removeFuncsHook();
try {
if ($record['field'] == 'status' && !empty($record['newValue']) && !empty($record['oldValue'])) {
$newStatus = $record['newValue']['code'];
if (!empty($options[$newStatus]) && !empty($record['order']['externalId'])) {
@ -431,6 +432,13 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) :
$this->retailcrm->ordersFixExternalIds($ids);
}
} catch (Exception $exception) {
$logger = new WC_Logger();
$logger->add('retailcrm', sprintf("[%s] - %s", $exception->getMessage(), 'Exception in file - ' . $exception->getFile() . ' on line ' . $exception->getLine()));
continue;
}
$this->addFuncsHook();
}
}

View File

@ -240,10 +240,14 @@ if ( ! class_exists( 'WC_Retailcrm_Icml' ) ) :
array_walk($offer['params'], array($this, 'setOffersParams'), $e);
}
if ($offer['dimension']) {
if (array_key_exists('dimension', $offer)) {
$e->addChild('dimension', $offer['dimension']);
}
if (array_key_exists('weight', $offer)) {
$e->addChild('weight', $offer['weight']);
}
unset($offers[$key]);
}
}
@ -365,7 +369,9 @@ if ( ! class_exists( 'WC_Retailcrm_Icml' ) ) :
}
}
if ($product->get_type() == 'variable') continue;
if ($product->get_type() == 'variable') {
continue;
}
if ($product->get_type() == 'simple' || $parent && $parent->get_type() == 'variable') {
if ($this->get_parent_product($product) > 0) {
@ -406,10 +412,6 @@ if ( ! class_exists( 'WC_Retailcrm_Icml' ) ) :
$post->post_title . $attrName :
$post->post_title;
if ($product->get_weight() != '') {
$params[] = array('code' => 'weight', 'name' => 'Вес', 'value' => $product->get_weight());
}
if ($product->get_sku() != '') {
$params[] = array('code' => 'article', 'name' => 'Артикул', 'value' => $product->get_sku());
}
@ -417,15 +419,21 @@ if ( ! class_exists( 'WC_Retailcrm_Icml' ) ) :
$dimension = '';
if ($product->get_length() != '') {
$dimension = $product->get_length();
$dimension = wc_get_dimension($product->get_length(), 'cm');
}
if ($product->get_width() != '') {
$dimension .= '/' . $product->get_width();
$dimension .= '/' . wc_get_dimension($product->get_width(), 'cm');
}
if ($product->get_height() != '') {
$dimension .= '/' . $product->get_height();
$dimension .= '/' . wc_get_dimension($product->get_height(), 'cm');
}
$weight = '';
if ($product->get_weight() != '') {
$weight = wc_get_weight($product->get_weight(), 'kg');
}
$product_data = array(
@ -438,7 +446,8 @@ if ( ! class_exists( 'WC_Retailcrm_Icml' ) ) :
'url' => ($this->get_parent_product($product) > 0) ? $parent->get_permalink() : $product->get_permalink(),
'quantity' => is_null($product->get_stock_quantity()) ? 0 : $product->get_stock_quantity(),
'categoryId' => $term_list,
'dimension' => $dimension
'dimension' => $dimension,
'weight' => $weight
);
if (!empty($params)) {
@ -501,6 +510,15 @@ if ( ! class_exists( 'WC_Retailcrm_Icml' ) ) :
return $categories;
}
/**
* Get product id
*
* @global object $woocommerce
*
* @param object $product
*
* @return int
*/
private function get_parent_product($product) {
global $woocommerce;
if ( version_compare( $woocommerce->version, '3.0', '<' ) ) {
@ -510,6 +528,15 @@ if ( ! class_exists( 'WC_Retailcrm_Icml' ) ) :
}
}
/**
* Get product price
*
* @global object $woocommerce
*
* @param object $product
*
* @return float
*/
private function get_price_with_tax($product) {
global $woocommerce;
if ( version_compare( $woocommerce->version, '3.0', '<' ) ) {
@ -519,6 +546,11 @@ if ( ! class_exists( 'WC_Retailcrm_Icml' ) ) :
}
}
/**
* Get product statuses
*
* @return array
*/
private function checkPostStatuses() {
$options = get_option( 'woocommerce_integration-retailcrm_settings' );
$status_args = array();

View File

@ -1,6 +1,6 @@
<?php
/**
* Version: 2.0.0
* Version: 2.0.1
* Plugin Name: WooCommerce RetailCRM
* Plugin URI: https://wordpress.org/plugins/woo-retailcrm/
* Description: Integration plugin for WooCommerce & RetailCRM

View File

@ -15,7 +15,7 @@
*
*
* @link https://wordpress.org/plugins/woo-retailcrm/
* @since 2.0.0
* @since 2.0.1
*
* @package RetailCRM
*/