diff --git a/admin/controller/extension/module/retailcrm.php b/admin/controller/extension/module/retailcrm.php index d8d056a..8a47e69 100644 --- a/admin/controller/extension/module/retailcrm.php +++ b/admin/controller/extension/module/retailcrm.php @@ -54,13 +54,6 @@ class ControllerExtensionModuleRetailcrm extends Controller 'catalog/model/account/customer/addCustomer/after', 'extension/module/retailcrm/customer_create' ); - - $this->model_extension_event - ->addEvent( - 'retailcrm', - 'catalog/model/checkout/order/editOrder/after', - 'extension/module/retailcrm/order_edit' - ); } /** @@ -376,6 +369,7 @@ class ControllerExtensionModuleRetailcrm extends Controller $this->load->model('extension/retailcrm/order'); $this->model_extension_retailcrm_order->uploadToCrm($fullOrders); + $file = fopen(DIR_SYSTEM . '/cron/export_done.txt', "x"); } /** diff --git a/admin/model/extension/retailcrm/history.php b/admin/model/extension/retailcrm/history.php index 5e61bad..c963532 100644 --- a/admin/model/extension/retailcrm/history.php +++ b/admin/model/extension/retailcrm/history.php @@ -64,9 +64,8 @@ class ModelExtensionRetailcrmHistory extends Model $this->ocPayment = $this->model_extension_retailcrm_references ->getOpercartPaymentTypes(); - $this->ocDelivery = $this->model_extension_retailcrm_references - ->getOpercartDeliveryTypes(); - + $this->ocDelivery = $settings['retailcrm_delivery']; + $this->zones = $this->model_localisation_zone->getZones(); $updatedOrders = array(); diff --git a/admin/model/extension/retailcrm/order.php b/admin/model/extension/retailcrm/order.php index 2c27169..5edd1de 100644 --- a/admin/model/extension/retailcrm/order.php +++ b/admin/model/extension/retailcrm/order.php @@ -1,6 +1,7 @@ load->model('catalog/product'); diff --git a/admin/view/template/extension/module/retailcrm.tpl b/admin/view/template/extension/module/retailcrm.tpl index 9afdbdd..8703791 100644 --- a/admin/view/template/extension/module/retailcrm.tpl +++ b/admin/view/template/extension/module/retailcrm.tpl @@ -6,7 +6,7 @@
- + @@ -63,12 +63,7 @@
-

-
- - -
- + @@ -76,10 +71,14 @@
+

+
+ + +

-
@@ -142,7 +141,7 @@ var token = ''; $('#icml').on('click', function() { $.ajax({ - url: ''+'system/cron/icml.php', + url: '' + 'admin/index.php?route=extension/module/retailcrm/icml&token=' + token, beforeSend: function() { $('#icml').button('loading'); }, @@ -159,7 +158,7 @@ $('#export').on('click', function() { $.ajax({ - url: ''+'system/cron/export.php', + url: '' + 'admin/index.php?route=extension/module/retailcrm/export&token=' + token, beforeSend: function() { $('#export').button('loading'); }, @@ -178,7 +177,7 @@ var order_id = $('input[name=\'order_id\']').val(); if (order_id && order_id > 0) { $.ajax({ - url: ''+'admin/index.php?route=extension/module/retailcrm/exportOrder&token=' + token + '&order_id=' + order_id, + url: '' + 'admin/index.php?route=extension/module/retailcrm/exportOrder&token=' + token + '&order_id=' + order_id, beforeSend: function() { $('#export_order').button('loading'); }, @@ -205,3 +204,4 @@ } }); + diff --git a/catalog/controller/api/retailcrm.php b/catalog/controller/api/retailcrm.php index 00ad266..823258c 100644 --- a/catalog/controller/api/retailcrm.php +++ b/catalog/controller/api/retailcrm.php @@ -47,7 +47,6 @@ class ControllerApiRetailcrm extends Controller ); foreach ($shippingModules as $shippingModule) { - $this->load->model('extension/shipping/' . $shippingModule['code']); if ($this->config->get($shippingModule['code'] . '_status')) { diff --git a/catalog/model/extension/retailcrm/order.php b/catalog/model/extension/retailcrm/order.php index 7860ab4..5892a67 100644 --- a/catalog/model/extension/retailcrm/order.php +++ b/catalog/model/extension/retailcrm/order.php @@ -78,7 +78,12 @@ class ModelExtensionRetailcrmOrder extends Model { $order_data['shipping_iso_code_2'] = $shipping_country['iso_code_2']; } - $delivery_code = $order_data['shipping_code']; + if(isset($settings['retailcrm_delivery'][$order_data['shipping_code']])) { + $delivery_code = $order_data['shipping_code']; + } else { + $delivery_code = stristr($order_data['shipping_code'], '.', TRUE); + } + $order['delivery'] = array( 'code' => !empty($delivery_code) ? $settings['retailcrm_delivery'][$delivery_code] : '', 'cost' => $deliveryCost, @@ -109,6 +114,14 @@ class ModelExtensionRetailcrmOrder extends Model { $productOptions = $this->model_catalog_product->getProductOptions($product['product_id']); foreach($product['option'] as $option) { + if ($option['type'] == 'select' || $option['type'] == 'radio' || $option['type'] == 'checkbox') { + $properties[] = array( + 'code' => $option['product_option_value_id'], + 'name' => $option['name'], + 'value' => $option['value'] + ); + } + if(!in_array($option['type'], $offerOptions)) continue; foreach($productOptions as $productOption) { if($productOption['product_option_id'] = $option['product_option_id']) { @@ -130,7 +143,7 @@ class ModelExtensionRetailcrmOrder extends Model { $offerId = implode('_', $offerId); } - $order['items'][] = array( + $item = array( 'offer' => array( 'externalId' => !empty($offerId) ? $product['product_id'].'#'.$offerId : $product['product_id'] ), @@ -138,6 +151,10 @@ class ModelExtensionRetailcrmOrder extends Model { 'initialPrice' => $product['price'], 'quantity' => $product['quantity'], ); + + if (isset($properties)) $item['properties'] = $properties; + + $order['items'][] = $item; } if (isset($order_data['order_status_id']) && $order_data['order_status_id'] > 0) { @@ -169,8 +186,6 @@ class ModelExtensionRetailcrmOrder extends Model { $order = array(); $payment_code = $order_data['payment_code']; - $delivery_code = $order_data['shipping_code']; - $order['externalId'] = $order_id; $order['firstName'] = $order_data['firstname']; $order['lastName'] = $order_data['lastname']; @@ -195,6 +210,12 @@ class ModelExtensionRetailcrmOrder extends Model { $country = (isset($order_data['shipping_country'])) ? $order_data['shipping_country'] : '' ; + if(isset($settings['retailcrm_delivery'][$order_data['shipping_code']])) { + $delivery_code = $order_data['shipping_code']; + } else { + $delivery_code = stristr($order_data['shipping_code'], '.', TRUE); + } + $order['delivery'] = array( 'code' => !empty($delivery_code) ? $settings['retailcrm_delivery'][$delivery_code] : '', 'address' => array( @@ -228,6 +249,14 @@ class ModelExtensionRetailcrmOrder extends Model { $productOptions = $this->model_catalog_product->getProductOptions($product['product_id']); foreach($product['option'] as $option) { + if ($option['type'] == 'select' || $option['type'] == 'radio' || $option['type'] == 'checkbox') { + $properties[] = array( + 'code' => $option['product_option_value_id'], + 'name' => $option['name'], + 'value' => $option['value'] + ); + } + if(!in_array($option['type'], $offerOptions)) continue; foreach($productOptions as $productOption) { if($productOption['product_option_id'] = $option['product_option_id']) { @@ -249,7 +278,7 @@ class ModelExtensionRetailcrmOrder extends Model { $offerId = implode('_', $offerId); } - $order['items'][] = array( + $item = array( 'offer' => array( 'externalId' => !empty($offerId) ? $product['product_id'].'#'.$offerId : $product['product_id'] ), @@ -257,6 +286,10 @@ class ModelExtensionRetailcrmOrder extends Model { 'initialPrice' => $product['price'], 'quantity' => $product['quantity'], ); + + if (isset($properties)) $item['properties'] = $properties; + + $order['items'][] = $item; } if (isset($order_data['order_status_id']) && $order_data['order_status_id'] > 0) { diff --git a/system/cron/export.php b/system/cron/export.php index cbf86bf..5880920 100644 --- a/system/cron/export.php +++ b/system/cron/export.php @@ -1,4 +1,3 @@