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

Merge pull request #57 from iyzoer/master

* Исправлена ошибка при активированном модуле без настроек
* Добавлен фильтр при формировании массива заказа
* Исправлена генерация icml с неполной картинкой товара
This commit is contained in:
Alex Lushpai 2018-04-10 11:09:27 +03:00 committed by GitHub
commit 7ad9ae7886
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 73 additions and 59 deletions

View File

@ -1,3 +1,8 @@
## 2018-03-22 v.2.1.4
* Исправлена ошибка при активированном модуле без настроек
* Добавлен фильтр при формировании массива заказа
* Исправлена генерация icml с неполной картинкой товара
## 2018-03-22 v.2.1.3 ## 2018-03-22 v.2.1.3
* Исправлена ошибка на php5.3 * Исправлена ошибка на php5.3

View File

@ -416,16 +416,16 @@ if ( ! class_exists( 'WC_Retailcrm_Icml' ) ) :
*/ */
private function setOffer(&$full_product_list, $product_attributes, $product, $parent = false) { private function setOffer(&$full_product_list, $product_attributes, $product, $parent = false) {
if ($parent) { if ($parent) {
$image = wp_get_attachment_image_src($product->get_image_id()); $image = wp_get_attachment_image_src($product->get_image_id(), 'full');
if (!$image) { if (!$image) {
$image = wp_get_attachment_image_src($parent->get_image_id()); $image = wp_get_attachment_image_src($parent->get_image_id(), 'full');
} }
$term_list = $parent->get_category_ids(); $term_list = $parent->get_category_ids();
$attributes = get_post_meta($parent->get_id(), '_product_attributes'); $attributes = get_post_meta($parent->get_id(), '_product_attributes');
} else { } else {
$image = wp_get_attachment_image_src($product->get_image_id()); $image = wp_get_attachment_image_src($product->get_image_id(), 'full');
$term_list = $product->get_category_ids(); $term_list = $product->get_category_ids();
$attributes = get_post_meta($product->get_id(), '_product_attributes'); $attributes = get_post_meta($product->get_id(), '_product_attributes');
} }

View File

@ -432,7 +432,7 @@ if ( ! class_exists( 'WC_Retailcrm_Orders' ) ) :
} }
} }
return $order_data; return apply_filters('retailcrm_process_order', $order_data);
} }
/** /**

View File

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Version: 2.1.3 * Version: 2.1.4
* Plugin Name: WooCommerce RetailCRM * Plugin Name: WooCommerce RetailCRM
* Plugin URI: https://wordpress.org/plugins/woo-retailcrm/ * Plugin URI: https://wordpress.org/plugins/woo-retailcrm/
* Description: Integration plugin for WooCommerce & RetailCRM * Description: Integration plugin for WooCommerce & RetailCRM
@ -362,66 +362,74 @@ function update_order($order_id) {
} }
function initialize_analytics() { function initialize_analytics() {
$options = array_filter(get_option( 'woocommerce_integration-retailcrm_settings' )); $options = get_option('woocommerce_integration-retailcrm_settings');
if (isset($options['ua']) && $options['ua'] == 'yes') { if ($options && is_array($options)) {
?> $options = array_filter($options);
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '<?php echo $options['ua_code']; ?>', 'auto'); if (isset($options['ua']) && $options['ua'] == 'yes') {
?>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
function getRetailCrmCookie(name) { ga('create', '<?php echo $options['ua_code']; ?>', 'auto');
var matches = document.cookie.match(new RegExp(
'(?:^|; )' + name + '=([^;]*)'
));
return matches ? decodeURIComponent(matches[1]) : '';
}
ga('set', 'dimension<?php echo $options['ua_custom']; ?>', getRetailCrmCookie('_ga')); function getRetailCrmCookie(name) {
ga('send', 'pageview'); var matches = document.cookie.match(new RegExp(
</script> '(?:^|; )' + name + '=([^;]*)'
<?php ));
return matches ? decodeURIComponent(matches[1]) : '';
}
ga('set', 'dimension<?php echo $options['ua_custom']; ?>', getRetailCrmCookie('_ga'));
ga('send', 'pageview');
</script>
<?php
}
} }
} }
function send_analytics() { function send_analytics() {
$options = array_filter(get_option( 'woocommerce_integration-retailcrm_settings' )); $options = get_option('woocommerce_integration-retailcrm_settings');
if (isset($_GET['key']) && isset($options['ua']) && $options['ua'] == 'yes') { if ($options && is_array($options)) {
$orderid = wc_get_order_id_by_order_key($_GET['key']); $options = array_filter($options);
$order = new WC_Order($orderid);
foreach ($order->get_items() as $item) { if (isset($_GET['key']) && isset($options['ua']) && $options['ua'] == 'yes') {
$uid = ($item['variation_id'] > 0) ? $item['variation_id'] : $item['product_id'] ; $orderid = wc_get_order_id_by_order_key($_GET['key']);
$_product = wc_get_product($uid); $order = new WC_Order($orderid);
if ($_product) { foreach ($order->get_items() as $item) {
$order_item = array( $uid = ($item['variation_id'] > 0) ? $item['variation_id'] : $item['product_id'] ;
'id' => $uid, $_product = wc_get_product($uid);
'name' => $item['name'], if ($_product) {
'price' => (float)$_product->get_price(), $order_item = array(
'quantity' => $item['qty'], 'id' => $uid,
); 'name' => $item['name'],
'price' => (float)$_product->get_price(),
'quantity' => $item['qty'],
);
$order_items[] = $order_item;
}
} }
$order_items[] = $order_item;
}
$url = parse_url(get_site_url()); $url = parse_url(get_site_url());
$domain = $url['host']; $domain = $url['host'];
?> ?>
<script type="text/javascript"> <script type="text/javascript">
ga('require', 'ecommerce', 'ecommerce.js'); ga('require', 'ecommerce', 'ecommerce.js');
ga('ecommerce:addTransaction', { ga('ecommerce:addTransaction', {
'id': <?php echo $order->get_id(); ?>, 'id': <?php echo $order->get_id(); ?>,
'affiliation': '<?php echo $domain; ?>', 'affiliation': '<?php echo $domain; ?>',
'revenue': <?php echo $order->get_total(); ?>, 'revenue': <?php echo $order->get_total(); ?>,
'shipping': <?php echo $order->get_total_tax(); ?>, 'shipping': <?php echo $order->get_total_tax(); ?>,
'tax': <?php echo $order->get_shipping_total(); ?> 'tax': <?php echo $order->get_shipping_total(); ?>
}); });
<?php <?php
foreach ($order_items as $item) {?> foreach ($order_items as $item) {?>
ga('ecommerce:addItem', { ga('ecommerce:addItem', {
'id': <?php echo $order->get_id(); ?>, 'id': <?php echo $order->get_id(); ?>,
'sku': <?php echo $item['id']; ?>, 'sku': <?php echo $item['id']; ?>,
@ -429,11 +437,12 @@ function send_analytics() {
'price': <?php echo $item['price']; ?>, 'price': <?php echo $item['price']; ?>,
'quantity': <?php echo $item['quantity']; ?> 'quantity': <?php echo $item['quantity']; ?>
}); });
<?php
}?>
ga('ecommerce:send');
</script>
<?php <?php
}?> }
ga('ecommerce:send');
</script>
<?php
} }
} }

View File

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