diff --git a/CHANGELOG.md b/CHANGELOG.md
index bfbb5d3..b7227ec 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+## v.2.2.2
+* Добавлена передача комментария клиента при создании заказа
+* Добавлена передача дополнительного номера телефона в заказе и клиенте при создании заказа
+* Добавлен перевод на испанкий язык
+
## v.2.2.0
* Добавлена выгрузка истории изменений по клиентам
* Добавлена проверка имени и значения свойств товара перед отправкой заказа
diff --git a/VERSION b/VERSION
index fae692e..7e541ae 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.2.1
\ No newline at end of file
+2.2.2
\ No newline at end of file
diff --git a/retailcrm/lib/RetailcrmHistory.php b/retailcrm/lib/RetailcrmHistory.php
index 4b640fa..8eaf410 100644
--- a/retailcrm/lib/RetailcrmHistory.php
+++ b/retailcrm/lib/RetailcrmHistory.php
@@ -8,8 +8,8 @@ class RetailcrmHistory
/**
* Get customers history
- *
- * @return string
+ *
+ * @return mixed
*/
public static function customersHistory()
{
@@ -122,6 +122,8 @@ class RetailcrmHistory
* Update last sync id
*/
Configuration::updateValue('RETAILCRM_LAST_CUSTOMERS_SYNC', $sinceid);
+
+ return true;
} else {
return 'Nothing to sync';
}
@@ -129,8 +131,8 @@ class RetailcrmHistory
/**
* Get orders history
- *
- * @return string
+ *
+ * @return mixed
*/
public static function ordersHistory()
{
@@ -193,14 +195,14 @@ class RetailcrmHistory
$payment = $paymentCRM['type'];
} elseif (isset($order['payments']) && count($order['payments']) > 1) {
foreach ($order['payments'] as $paymentCRM) {
- if ($payment['status'] != 'paid') {
+ if ($paymentCRM['status'] != 'paid') {
$payment = $paymentCRM['type'];
}
}
}
}
- if (array_key_exists($payment, $payments) && $payments[$payment] != '') {
+ if (array_key_exists($payment, $payments) && !empty($payments[$payment])) {
if (Module::getInstanceByName($payments[$payment])) {
$paymentType = Module::getModuleName($payments[$payment]);
} else {
@@ -236,7 +238,7 @@ class RetailcrmHistory
}
}
- if (!$deliveryType) {
+ if (!isset($deliveryType) || !$deliveryType) {
if ($deliveryDefault) {
$deliveryType = $deliveryDefault;
} else {
@@ -384,19 +386,29 @@ class RetailcrmHistory
);
$combinationPrice = Combination::getPrice($product_attribute_id);
- $productPrice = $combinationPrice > 0 ? $product->getPrice()+ $combinationPrice : $product->getPrice();
+ $productPrice = $combinationPrice > 0 ? $product->getPrice() + $combinationPrice : $product->getPrice();
} else {
$productName = htmlspecialchars(strip_tags($product->name));
$productPrice = $product->getPrice();
}
$product_list[] = array(
- 'product' => $product,
- 'product_attribute_id' => $product_attribute_id,
- 'product_price' => $product->price,
- 'product_price_inc_tax' => $productPrice,
- 'product_name' => $productName,
- 'quantity' => $item['quantity']
+ 'id_product' => $product->id,
+ 'id_product_attribute' => $product_attribute_id,
+ 'price' => $product->price,
+ 'price_wt' => $productPrice,
+ 'name' => $productName,
+ 'cart_quantity' => $item['quantity'],
+ 'weight' => 0,
+ 'weight_attribute' => 0,
+ 'stock_quantity' => $item['quantity'],
+ 'ecotax' => 0,
+ 'id_shop' => Context::getContext()->shop->id,
+ 'additional_shipping_cost' => 0,
+ 'total_wt' => $productPrice * $item['quantity'],
+ 'total' => $productPrice * $item['quantity'],
+ 'wholesale_price' => $product->wholesale_price,
+ 'id_supplier' => $product->id_supplier
);
if (isset($item['discountTotal']) && self::$apiVersion == 5) {
@@ -407,8 +419,11 @@ class RetailcrmHistory
$newOrder->add(false, false);
if (isset($order['payments']) && !empty($order['payments'])) {
- foreach ($order['payments'] as $pay) {
- if (!isset($pay['externalId']) && $pay['status'] == 'paid') {
+ foreach ($order['payments'] as $payment) {
+ if (!isset($payment['externalId'])
+ && isset($payment['status'])
+ && $payment['status'] == 'paid'
+ ) {
$ptype = $payment['type'];
$ptypes = $references->getSystemPaymentModules();
if ($payments[$ptype] != null) {
@@ -417,14 +432,13 @@ class RetailcrmHistory
$payType = $pay['name'];
}
}
- $paymentType = Module::getModuleName($payments[$ptype]);
- Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'order_payment`
- (`payment_method`, `order_reference` , `amount`, `date_add`)
- VALUES
- (\'' . $payType . '\',
- \'' . $newOrder->reference . '\',
- \'' . $payment['amount'] . '\',
- \'' . $payment['paidAt'] . '\')');
+
+ $orderPayment = new OrderPayment();
+ $orderPayment->payment_method = $payType;
+ $orderPayment->order_reference = $newOrder->reference;
+ $orderPayment->amount = $payment['amount'];
+ $orderPayment->date_add = $payment['paidAt'];
+ $orderPayment->save();
}
}
}
@@ -446,38 +460,9 @@ class RetailcrmHistory
/*
* Create order details
*/
- $query = 'INSERT `'._DB_PREFIX_.'order_detail`
- (
- `id_order`, `id_order_invoice`, `id_shop`, `product_id`, `product_attribute_id`,
- `product_name`, `product_quantity`, `product_quantity_in_stock`, `product_price`,
- `product_reference`, `total_price_tax_excl`, `total_price_tax_incl`,
- `unit_price_tax_excl`, `unit_price_tax_incl`, `original_product_price`
- )
-
- VALUES';
-
- $context = new Context();
- foreach ($product_list as $product) {
- $query .= '('
- .(int) $newOrder->id.',
- 0,
- '. Context::getContext()->shop->id.',
- '.(int) $product['product']->id.',
- '.$product['product_attribute_id'].',
- '.implode('', array('\'', $product['product_name'], '\'')).',
- '.(int) $product['quantity'].',
- '.(int) $product['quantity'].',
- '.$product['product_price'].',
- '.implode('', array('\'', $product['product']->reference, '\'')).',
- '.$product['product_price'].',
- '.$product['product_price_inc_tax'].',
- '.$product['product_price'].',
- '.$product['product_price_inc_tax'].',
- '.$product['product_price'].'
- ),';
- }
-
- Db::getInstance()->execute(rtrim($query, ','));
+ $orderDetail = new OrderDetail();
+ $orderDetail->createList($newOrder, $cart, $newOrder->current_state, $product_list);
+ $orderDetail->save();
if (!empty($customerFix)) {
self::$api->customersFixExternalIds($customerFix);
@@ -496,55 +481,39 @@ class RetailcrmHistory
$dtype = $order['delivery']['code'];
$dcost = !empty($order['delivery']['cost']) ? $order['delivery']['cost'] : null;
- if ($deliveries[$dtype] != null) {
+ if (isset($deliveries[$dtype]) && $deliveries[$dtype] != null) {
if ($deliveries[$dtype] != $orderToUpdate->id_carrier or $dcost != null) {
if ($dtype != null) {
- Db::getInstance()->execute('UPDATE `' . _DB_PREFIX_ . 'orders`
- SET
- `id_carrier` = \'' . $deliveries[$dtype] . '\'
- WHERE
- `id_order` = ' . (int)$order['externalId']);
+ $orderCarrier = new OrderCarrier($orderToUpdate->id_order_carrier);
+ $orderCarrier->id_carrier = $deliveries[$dtype];
}
- $updateCarrierFields = array();
if ($dtype != null) {
- $updateCarrierFields[] = '`id_carrier` = \'' . $deliveries[$dtype] . '\' ';
+ $orderCarrier->id_carrier = $deliveries[$dtype];
}
if ($dcost != null) {
- $updateCarrierFields[] = '`shipping_cost_tax_incl` = \'' . $dcost . '\' ';
- $updateCarrierFields[] = '`shipping_cost_tax_excl` = \'' . $dcost . '\' ';
+ $orderCarrier->shipping_cost_tax_incl = $dcost;
+ $orderCarrier->shipping_cost_tax_excl = $dcost;
}
- $updateCarrierFields = implode(', ', $updateCarrierFields);
- Db::getInstance()->execute('UPDATE `' . _DB_PREFIX_ . 'order_carrier`
- SET
- '.$updateCarrierFields.'
- WHERE
- `id_order` = \'' . $orderToUpdate->id . '\'');
+ $orderCarrier->update();
}
}
}
- /*
+ /**
* check payment type
*/
-
if (!empty($order['paymentType']) && self::$apiVersion != 5) {
$ptype = $order['paymentType'];
if ($payments[$ptype] != null) {
$paymentType = Module::getModuleName($payments[$ptype]);
if ($payments[$ptype] != $orderToUpdate->payment) {
- Db::getInstance()->execute('UPDATE `' . _DB_PREFIX_ . 'orders`
- SET
- `payment` = \'' . ($paymentType != null ? $paymentType : $payments[$ptype]). '\'
- WHERE
- `id_order` = ' . (int)$order['externalId']);
- Db::getInstance()->execute('UPDATE `' . _DB_PREFIX_ . 'order_payment`
- SET
- `payment_method` = \'' . $payments[$ptype] . '\'
- WHERE
- `order_reference` = \'' . $orderToUpdate->reference . '\'');
+ $orderToUpdate->payment = $paymentType != null ? $paymentType : $payments[$ptype];
+ $orderPayment = OrderPayment::getByOrderId($orderToUpdate->id);
+ $orderPayment->payment_method = $payments[$ptype];
+ $orderPayment->update();
}
}
} elseif (!empty($order['payments']) && self::$apiVersion == 5) {
@@ -562,19 +531,13 @@ class RetailcrmHistory
}
}
$paymentType = Module::getModuleName($payments[$ptype]);
- Db::getInstance()->execute('UPDATE `' . _DB_PREFIX_ . 'orders`
- SET
- `payment` = \'' . ($paymentType != null ? $paymentType : $payments[$ptype]). '\'
- WHERE
- `id_order` = ' . (int)$order['externalId']);
-
- Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'order_payment`
- (`payment_method`, `order_reference` , `amount`, `date_add`)
- VALUES
- (\'' . $payType . '\',
- \'' . $orderToUpdate->reference . '\',
- \'' . $payment['amount'] . '\',
- \'' . $payment['paidAt'] . '\')');
+ $orderToUpdate->payment = $paymentType != null ? $paymentType : $payments[$ptype];
+ $orderPayment = new OrderPayment();
+ $orderPayment->payment_method = $payType;
+ $orderPayment->order_reference = $orderToUpdate->reference;
+ $orderPayment->amount = $payment['amount'];
+ $orderPayment->date_add = $payment['paidAt'];
+ $orderPayment->save();
}
}
}
@@ -594,11 +557,7 @@ class RetailcrmHistory
$product_attribute_id = 0;
}
- Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'order_detail`
- WHERE
- `id_order` = '. $orderToUpdate->id .'
- AND
- `product_id` = '.$product_id. ' AND `product_attribute_id` = '.$product_attribute_id);
+ self::deleteOrderDetailByProduct($orderToUpdate->id, $product_id, $product_attribute_id);
unset($order['items'][$key]);
$ItemDiscount = true;
@@ -647,22 +606,16 @@ class RetailcrmHistory
$productPrice = round($productPrice, 2);
- Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'order_detail`
- SET
- `unit_price_tax_incl` = '.$productPrice.'
- WHERE
- `id_order_detail` = '.$orderItem['id_order_detail']);
+ $orderDetail = new OrderDetail($orderItem['id_order_detail']);
+ $orderDetail->unit_price_tax_incl = $productPrice;
// quantity
if (isset($item['quantity']) && $item['quantity'] != $orderItem['product_quantity']) {
- Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'order_detail`
- SET
- `product_quantity` = '.$item['quantity'].',
- `product_quantity_in_stock` = '.$item['quantity'].'
- WHERE
- `id_order_detail` = '.$orderItem['id_order_detail']);
+ $orderDetail->product_quantity = $item['quantity'];
+ $orderDetail->product_quantity_in_stock = $item['quantity'];
}
+ $orderDetail->update();
$ItemDiscount = true;
unset($order['items'][$key]);
}
@@ -673,16 +626,6 @@ class RetailcrmHistory
* Check new items
*/
if (!empty($order['items'])) {
- $query = 'INSERT `'._DB_PREFIX_.'order_detail`
- (
- `id_order`, `id_order_invoice`, `id_shop`, `product_id`, `product_attribute_id`,
- `product_name`, `product_quantity`, `product_quantity_in_stock`, `product_price`,
- `product_reference`, `total_price_tax_excl`, `total_price_tax_incl`,
- `unit_price_tax_excl`, `unit_price_tax_incl`, `original_product_price`
- )
-
- VALUES';
-
foreach ($order['items'] as $key => $newItem) {
$product_id = $newItem['offer']['externalId'];
$product_attribute_id = 0;
@@ -708,46 +651,49 @@ class RetailcrmHistory
}
// discount
- if ($newItem['discount'] || $newItem['discountPercent']|| $newItem['discountTotal']) {
+ if ((isset($newItem['discount']) && $newItem['discount'])
+ || (isset($newItem['discountPercent']) && $newItem['discountPercent'])
+ || (isset($newItem['discountTotal']) && $newItem['discountTotal'])
+ ) {
$productPrice = $productPrice - $newItem['discount'];
$productPrice = $productPrice - $newItem['discountTotal'];
$productPrice = $productPrice - ($prodPrice / 100 * $newItem['discountPercent']);
$ItemDiscount = true;
}
- $query .= '('
- .(int) $orderToUpdate->id.',
- 0,
- '. Context::getContext()->shop->id.',
- '.(int) $product_id.',
- '.(int) $product_attribute_id.',
- '.implode('', array('\'', $productName, '\'')).',
- '.(int) $newItem['quantity'].',
- '.(int) $newItem['quantity'].',
- '.$productPrice.',
- '.implode('', array('\'', $product->reference, '\'')).',
- '.$productPrice * $newItem['quantity'].',
- '.($productPrice + $productPrice / 100 * $tax->rate) * $newItem['quantity'].',
- '.$productPrice.',
- '.($productPrice + $productPrice / 100 * $tax->rate).',
- '.$productPrice.'
- ),';
+ $orderDetail = new OrderDetail();
+ $orderDetail->id_order = $orderToUpdate->id;
+ $orderDetail->id_order_invoice = $orderToUpdate->invoice_number;
+ $orderDetail->id_shop = Context::getContext()->shop->id;
+ $orderDetail->product_id = (int) $product_id;
+ $orderDetail->product_attribute_id = (int) $product_attribute_id;
+ $orderDetail->product_name = implode('', array('\'', $productName, '\''));
+ $orderDetail->product_quantity = (int) $newItem['quantity'];
+ $orderDetail->product_quantity_in_stock = (int) $newItem['quantity'];
+ $orderDetail->product_price = $productPrice;
+ $orderDetail->product_reference = implode('', array('\'', $product->reference, '\''));
+ $orderDetail->total_price_tax_excl = $productPrice * $newItem['quantity'];
+ $orderDetail->total_price_tax_incl = ($productPrice + $productPrice / 100 * $tax->rate) * $newItem['quantity'];
+ $orderDetail->unit_price_tax_excl = $productPrice;
+ $orderDetail->unit_price_tax_incl = ($productPrice + $productPrice / 100 * $tax->rate);
+ $orderDetail->original_product_price = $productPrice;
+ $orderDetail->save();
+ unset($orderDetail);
unset($order['items'][$key]);
}
-
- Db::getInstance()->execute(rtrim($query, ','));
}
/*
* Fix prices & discounts
* Discounts only for whole order
*/
- if (isset($order['discount']) ||
- isset($order['discountPercent']) ||
- isset($order['delivery']['cost']) ||
- isset($order['discountTotal']) ||
- $ItemDiscount) {
+ if (isset($order['discount'])
+ || isset($order['discountPercent'])
+ || isset($order['delivery']['cost'])
+ || isset($order['discountTotal'])
+ || $ItemDiscount
+ ) {
$infoOrd = self::$api->ordersGet($order['externalId']);
$infoOrder = $infoOrd->order;
$orderTotalProducts = $infoOrder['summ'];
@@ -760,21 +706,18 @@ class RetailcrmHistory
$order_cart_rule = new OrderCartRule($valCartRules['id_order_cart_rule']);
$order_cart_rule->delete();
}
- $orderToUpdate->update();
- Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'orders`
- SET
- `total_discounts` = '.$totalDiscount.',
- `total_discounts_tax_incl` = '.$totalDiscount.',
- `total_discounts_tax_excl` = '.$totalDiscount.',
- `total_shipping` = '.$deliveryCost.',
- `total_shipping_tax_incl` = '.$deliveryCost.',
- `total_shipping_tax_excl` = '.$deliveryCost.',
- `total_paid` = '.$totalPaid.',
- `total_paid_tax_incl` = '.$totalPaid.',
- `total_paid_tax_excl` = '.$totalPaid.',
- `total_products_wt` = '.$orderTotalProducts.'
- WHERE `id_order` = '.(int) $order['externalId']);
+ $orderToUpdate->total_discounts = $totalDiscount;
+ $orderToUpdate->total_discounts_tax_incl = $totalDiscount;
+ $orderToUpdate->total_discounts_tax_excl = $totalDiscount;
+ $orderToUpdate->total_shipping = $deliveryCost;
+ $orderToUpdate->total_shipping_tax_incl = $deliveryCost;
+ $orderToUpdate->total_shipping_tax_excl = $deliveryCost;
+ $orderToUpdate->total_paid = $totalPaid;
+ $orderToUpdate->total_paid_tax_incl = $totalPaid;
+ $orderToUpdate->total_paid_tax_excl = $totalPaid;
+ $orderToUpdate->total_products_wt = $orderTotalProducts;
+ $orderToUpdate->update();
unset($ItemDiscount);
}
@@ -787,29 +730,48 @@ class RetailcrmHistory
if ($statuses[$stype] != null) {
if ($statuses[$stype] != $orderToUpdate->current_state) {
- Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'order_history`
- (`id_employee`, `id_order`, `id_order_state`, `date_add`)
- VALUES
- (0, ' . $orderToUpdate->id . ',
- ' . $statuses[$stype] . ',
- "' . date('Y-m-d H:i:s') . '")');
+ $orderHistory = new OrderHistory();
+ $orderHistory->id_employee = 0;
+ $orderHistory->id_order = $orderToUpdate->id;
+ $orderHistory->id_order_state = $statuses[$stype];
+ $orderHistory->date_add = date('Y-m-d H:i:s');
+ $orderHistory->save();
- Db::getInstance()->execute('UPDATE `' . _DB_PREFIX_ . 'orders`
- SET
- `current_state` = \'' . $statuses[$stype] . '\'
- WHERE
- `id_order` = ' . (int)$order['externalId']);
+ $orderToUpdate->current_state = $statuses[$stype];
+ $orderToUpdate->update();
}
}
}
}
}
+
/*
* Update last sync timestamp
*/
Configuration::updateValue('RETAILCRM_LAST_ORDERS_SYNC', $sinceId);
+
+ return true;
} else {
return 'Nothing to sync';
}
}
-}
\ No newline at end of file
+
+ /**
+ * Delete order product from order by product
+ *
+ * @param $order_id
+ * @param $product_id
+ * @param $product_attribute_id
+ *
+ * @return void
+ */
+ private static function deleteOrderDetailByProduct($order_id, $product_id, $product_attribute_id)
+ {
+ Db::getInstance()->execute('
+ DELETE FROM ' . _DB_PREFIX_ . 'order_detail
+ WHERE id_order = ' . $order_id . '
+ AND product_id = ' . $product_id . '
+ AND product_attribute_id = ' . $product_attribute_id
+ );
+ }
+}
diff --git a/retailcrm/lib/RetailcrmHistoryHelper.php b/retailcrm/lib/RetailcrmHistoryHelper.php
index b31a958..c0dd89e 100644
--- a/retailcrm/lib/RetailcrmHistoryHelper.php
+++ b/retailcrm/lib/RetailcrmHistoryHelper.php
@@ -33,10 +33,10 @@ class RetailcrmHistoryHelper {
} else {
$orders[$change['order']['id']] = $change['order'];
}
-
+
if (isset($change['payment'])) {
if (isset($orders[$change['order']['id']]['payments'][$change['payment']['id']])) {
- $orders[$change['order']['id']]['payments'][$change['payment']['id']] = array_merge($orders[$change['order']['id']]['payments'][$change['payment']['id']], $change['payment']);
+ $orders[$change['order']['id']]['payments'][$change['payment']['id']] = array_merge($orders[$change['order']['id']]['payments'][$change['payment']['id']], $change['payment']);
} else {
$orders[$change['order']['id']]['payments'][$change['payment']['id']] = $change['payment'];
}
@@ -50,7 +50,7 @@ class RetailcrmHistoryHelper {
$orders[$change['order']['id']]['payments'][$change['payment']['id']][$fields['payment'][$change['field']]] = $change['newValue'];
}
}
-
+
if (isset($change['item'])) {
if (isset($orders[$change['order']['id']]['items'][$change['item']['id']])) {
$orders[$change['order']['id']]['items'][$change['item']['id']] = array_merge($orders[$change['order']['id']]['items'][$change['item']['id']], $change['item']);
@@ -64,7 +64,9 @@ class RetailcrmHistoryHelper {
if (empty($change['newValue']) && $change['field'] == 'order_product') {
$orders[$change['order']['id']]['items'][$change['item']['id']]['delete'] = true;
}
- if (!$orders[$change['order']['id']]['items'][$change['item']['id']]['create'] && $fields['item'][$change['field']]) {
+ if (!isset($orders[$change['order']['id']]['items'][$change['item']['id']]['create'])
+ && isset($fields['item'][$change['field']]) && $fields['item'][$change['field']]
+ ) {
$orders[$change['order']['id']]['items'][$change['item']['id']][$fields['item'][$change['field']]] = $change['newValue'];
}
} else {
diff --git a/retailcrm/retailcrm.php b/retailcrm/retailcrm.php
index 3e2ec69..71b6255 100644
--- a/retailcrm/retailcrm.php
+++ b/retailcrm/retailcrm.php
@@ -3,7 +3,7 @@
* @author Retail Driver LCC
* @copyright RetailCRM
* @license GPL
- * @version 2.2.0
+ * @version 2.2.2
* @link https://retailcrm.ru
*
*/
@@ -38,7 +38,7 @@ class RetailCRM extends Module
{
$this->name = 'retailcrm';
$this->tab = 'export';
- $this->version = '2.2.1';
+ $this->version = '2.2.2';
$this->author = 'Retail Driver LCC';
$this->displayName = $this->l('RetailCRM');
$this->description = $this->l('Integration module for RetailCRM');
@@ -117,7 +117,7 @@ class RetailCRM extends Module
);
$output .= $this->validateForm($settings, $output);
-
+
if ($output === '') {
Configuration::updateValue('RETAILCRM_ADDRESS', $address);
Configuration::updateValue('RETAILCRM_API_TOKEN', $token);
@@ -147,7 +147,7 @@ class RetailCRM extends Module
$output .= $this->displayConfirmation(
$this->l('Timezone settings must be identical to both of your crm and shop') .
- " $address/admin/settings#t-main"
+ "$address/admin/settings#t-main"
);
$this->display(__FILE__, 'retailcrm.tpl');
@@ -416,6 +416,7 @@ class RetailCRM extends Module
public function hookActionOrderEdited($params)
{
+
$order = array(
'externalId' => $params['order']->id,
'firstName' => $params['customer']->firstname,
@@ -437,7 +438,7 @@ class RetailCRM extends Module
if ($comment !== false) {
$order['customerComment'] = $comment;
}
-
+
unset($comment);
foreach ($orderdb->getProducts() as $item) {
@@ -496,10 +497,8 @@ class RetailCRM extends Module
$address = array_shift($addressCollection);
if ($address instanceof Address) {
- $phone = empty($address->phone)
- ? empty($address->phone_mobile) ? '' : $address->phone_mobile
- : $address->phone;
-
+ $additionalPhone = !empty($address->phone) ? $address->phone : '';
+ $phone = !empty($address->phone_mobile) ? $address->phone_mobile : '';
$postcode = $address->postcode;
$city = $address->city;
$addres_line = sprintf("%s %s", $address->address1, $address->address2);
@@ -520,9 +519,27 @@ class RetailCRM extends Module
$order['delivery']['address']['text'] = $addres_line;
}
- if (!empty($phone)) {
- $customer['phones'][] = array('number' => $phone);
+ if (!empty($phone) && !empty($additionalPhone)) {
+ $customer['phones'] = array(
+ array(
+ 'number' => $phone
+ ),
+ array(
+ 'number' => $additionalPhone
+ )
+ );
+
$order['phone'] = $phone;
+ $order['additionalPhone'] = $additionalPhone;
+ } else {
+ $order['phone'] = !empty($phone) ? $phone : $additionalPhone;
+ $customer['phones'][] = array('number' => $order['phone']);
+ }
+
+ $comment = $params['order']->getFirstMessage();
+
+ if ($comment !== false) {
+ $order['customerComment'] = $comment;
}
foreach ($cart->getProducts() as $item) {
@@ -612,7 +629,7 @@ class RetailCRM extends Module
}
$order['customer']['externalId'] = $customer['externalId'];
-
+
$this->api->ordersCreate($order);
return $order;
diff --git a/retailcrm/translations/es.php b/retailcrm/translations/es.php
new file mode 100644
index 0000000..d5a5466
--- /dev/null
+++ b/retailcrm/translations/es.php
@@ -0,0 +1,55 @@
+retailcrm_7d1d9327371097419bdf83ffa671d2f2'] = 'Versión de la API';
+$_MODULE['<{retailcrm}prestashop>retailcrm_463dc31aa1a0b6e871b1a9fed8e9860a'] = 'retailCRM';
+$_MODULE['<{retailcrm}prestashop>retailcrm_30de6237576b9a24f6fc599c22a35a4b'] = 'El módulo de integración con retailCRM';
+$_MODULE['<{retailcrm}prestashop>retailcrm_876f23178c29dc2552c0b48bf23cd9bd'] = '¿Está seguro de que desea eliminar el módulo?';
+$_MODULE['<{retailcrm}prestashop>retailcrm_b9b2d9f66d0112f3aae7dbdbd4e22a43'] = 'La dirección del CRM es incorrecta o está vacía';
+$_MODULE['<{retailcrm}prestashop>retailcrm_942010ef43f3fec28741f62a0d9ff29c'] = 'La clave CRM es incorrecta o está vacía';
+$_MODULE['<{retailcrm}prestashop>retailcrm_fba05687b61bc936d1a9a92371ba8bcf'] = '¡Atención! La zona horaria de CRM debe coincidir con la zona horaria de la tienda, la configuración de la zona horaria de CRM se puede establecer en:';
+$_MODULE['<{retailcrm}prestashop>retailcrm_5effd5157947e8ba4a08883f198b2e31'] = 'La dirección del CRM no es válida o está vacía';
+$_MODULE['<{retailcrm}prestashop>retailcrm_576300f5b6faeb746bb6d034d98e7afd'] = 'La clave de API no es válida o está vacía';
+$_MODULE['<{retailcrm}prestashop>retailcrm_c888438d14855d7d96a2724ee9c306bd'] = 'Los ajustes están actualizados';
+$_MODULE['<{retailcrm}prestashop>retailcrm_51af428aa0dcceb5230acb267ecb91c5'] = 'La configuración de la conexión';
+$_MODULE['<{retailcrm}prestashop>retailcrm_4cbd5dbeeef7392e50358b1bc00dd592'] = 'URL CRM';
+$_MODULE['<{retailcrm}prestashop>retailcrm_7f775042e08eddee6bbfd8fbe0add4a3'] = 'La clave API';
+$_MODULE['<{retailcrm}prestashop>retailcrm_c9cc8cce247e49bae79f15173ce97354'] = 'Guardar';
+$_MODULE['<{retailcrm}prestashop>retailcrm_065ab3a28ca4f16f55f103adc7d0226f'] = 'Los métodos del envío';
+$_MODULE['<{retailcrm}prestashop>retailcrm_33af8066d3c83110d4bd897f687cedd2'] = 'Los estados de pedidos';
+$_MODULE['<{retailcrm}prestashop>retailcrm_bab959acc06bb03897b294fbb892be6b'] = 'Los métodos de pago';
+$_MODULE['<{retailcrm}prestashop>retailcrm_6310f29293c902c64db619c29179d99a'] = 'Los método de envío';
+$_MODULE['<{retailcrm}prestashop>retailcrm_4dbcb38bbbff5d4a402f2575c57a35e6'] = 'El tipo de pago';
+$_MODULE['<{retailcrm}prestashop>retailcrm_dd7bf230fde8d4836917806aff6a6b27'] = 'Dirección';
+$_MODULE['<{retailcrm}prestashop>retailcrm_630f6dc397fe74e52d5189e2c80f282b'] = 'Volver a la lista';
+$_MODULE['<{retailcrm}prestashop>retailcrm_5c1cf6cfec2dad86c8ca5286a0294516'] = 'Nombre';
+$_MODULE['<{retailcrm}prestashop>retailcrm_c695cfe527a6fcd680114851b86b7555'] = 'Apellido';
+$_MODULE['<{retailcrm}prestashop>retailcrm_f9dd946cc89c1f3b41a0edbe0f36931d'] = 'Teléfono';
+$_MODULE['<{retailcrm}prestashop>retailcrm_61a649a33f2869e5e35fbb7aff3a80d9'] = 'Email';
+$_MODULE['<{retailcrm}prestashop>retailcrm_2664f03ac6b8bb9eee4287720e407db3'] = 'Dirección';
+$_MODULE['<{retailcrm}prestashop>retailcrm_6ddc09dc456001d9854e9fe670374eb2'] = 'País';
+$_MODULE['<{retailcrm}prestashop>retailcrm_69aede266809f89b89fe70681f6a129f'] = 'Provincia/Región/República';
+$_MODULE['<{retailcrm}prestashop>retailcrm_859214628431995197c0558f7b5f8ffc'] = 'Ciudad';
+$_MODULE['<{retailcrm}prestashop>retailcrm_4348f938bbddd8475e967ccb47ecb234'] = 'Código Postal';
+$_MODULE['<{retailcrm}prestashop>retailcrm_78fce82336bbbdca7f6da7564b8f9325'] = 'Calle';
+$_MODULE['<{retailcrm}prestashop>retailcrm_71a6834884666147c0334f0c40bc7295'] = 'Casa/Edificio';
+$_MODULE['<{retailcrm}prestashop>retailcrm_f88a77e3d68d251c3dc4008c327b5a0c'] = 'Piso';
+$_MODULE['<{retailcrm}prestashop>retailcrm_d977f846d110fcb7f71c6f97330c9d10'] = 'Número del piso y la letra';
+$_MODULE['<{retailcrm}prestashop>retailcrm_56c1e354d36beb85b0d881c5b2e24cbe'] = 'Planta';
+$_MODULE['<{retailcrm}prestashop>retailcrm_4d34f53389ed7f28ca91fc31ea360a66'] = 'Bloque';
+$_MODULE['<{retailcrm}prestashop>retailcrm_49354b452ec305136a56fe7731834156'] = 'Casa/Edificio';
+$_MODULE['<{retailcrm}prestashop>retailcrm_04176f095283bc729f1e3926967e7034'] = 'Nombre';
+$_MODULE['<{retailcrm}prestashop>retailcrm_dff4bf10409100d989495c6d5486035e'] = 'Apellido';
+$_MODULE['<{retailcrm}prestashop>retailcrm_1c76cbfe21c6f44c1d1e59d54f3e4420'] = 'Empresa';
+$_MODULE['<{retailcrm}prestashop>retailcrm_1aadcc03a9dbba84a3c5a5cbfde8a162'] = 'NIF';
+$_MODULE['<{retailcrm}prestashop>retailcrm_93d03fe37ab3c6abc2a19dd8e41543bd'] = 'Línea de dirección 1';
+$_MODULE['<{retailcrm}prestashop>retailcrm_22fcffe02ab9eda5b769387122f2ddce'] = 'Línea de dirección 2';
+$_MODULE['<{retailcrm}prestashop>retailcrm_8bcdc441379cbf584638b0589a3f9adb'] = 'Código Postal';
+$_MODULE['<{retailcrm}prestashop>retailcrm_57d056ed0984166336b7879c2af3657f'] = 'Ciudad';
+$_MODULE['<{retailcrm}prestashop>retailcrm_bcc254b55c4a1babdf1dcb82c207506b'] = 'Teléfono';
+$_MODULE['<{retailcrm}prestashop>retailcrm_f0e1fc6f97d36cb80f29196e2662ffde'] = 'Teléfono móvil';
+$_MODULE['<{retailcrm}prestashop>retailcrm_7a1920d61156abc05a60135aefe8bc67'] = 'Por defecto';
+$_MODULE['<{retailcrm}prestashop>retailcrm_cc18dd262eff97c4dd4b56f750896adb'] = 'Estado predeterminado';
+$_MODULE['<{retailcrm}prestashop>retailcrm_a33b96f0ce0f1227132f1cb3cf1c9e88'] = 'Estado del pedido al exportar por lotes';
+$_MODULE['<{retailcrm}prestashop>retailcrm_1bd340aeb42a5ee0318784c2cffed8a9'] = 'La versión seleccionada de la API no está disponible';
\ No newline at end of file