mirror of
https://github.com/retailcrm/prestashop-module.git
synced 2025-03-01 19:03:14 +03:00
v2.2.5
This commit is contained in:
parent
b92579e515
commit
54d4091f63
10
CHANGELOG.md
10
CHANGELOG.md
@ -13,11 +13,13 @@
|
||||
## v2.2.6
|
||||
* Добавлена активация модуля в маркетплейсе retailCRM
|
||||
|
||||
## v2.2.5
|
||||
* Добавлена передача страны при создании заказа для пользователя и заказа
|
||||
* Добавлен метод сохранения сущностей с обработкой исключений
|
||||
## v.2.2.5
|
||||
* Добавлена передача страны при создании заказа для заказа и покупателя
|
||||
* Добавлен метод для загрузки сущностей с перехватом исключений
|
||||
* Для версии 1.7 добавлена передача адреса при заполнении его на стороне сайта.
|
||||
* Получение адреса и телефона вынесено в отдельные методы.
|
||||
|
||||
## v2.2.4
|
||||
## v.2.2.4
|
||||
* Добавлена установка дефолтной валюты для оплаты при получении истории
|
||||
* Добавлено получение суммы оплаты из заказа в CMS, если она не передается по истории
|
||||
|
||||
|
@ -53,6 +53,7 @@ class RetailcrmHistory
|
||||
if (self::loadInCMS($customer, 'update') === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else {
|
||||
$customer = new Customer();
|
||||
|
||||
|
@ -3,7 +3,11 @@
|
||||
* @author Retail Driver LCC
|
||||
* @copyright RetailCRM
|
||||
* @license GPL
|
||||
<<<<<<< 4dfc7b8d1acbf9bdc33ac6484f0d7f4171e774d6
|
||||
* @version 2.2.9
|
||||
=======
|
||||
* @version 2.2.5
|
||||
>>>>>>> v2.2.5
|
||||
* @link https://retailcrm.ru
|
||||
*
|
||||
*/
|
||||
@ -76,7 +80,8 @@ class RetailCRM extends Module
|
||||
$this->registerHook('actionPaymentConfirmation') &&
|
||||
$this->registerHook('actionCustomerAccountAdd') &&
|
||||
$this->registerHook('actionOrderEdited') &&
|
||||
($this->use_new_hooks ? $this->registerHook('actionCustomerAccountUpdate') : true)
|
||||
($this->use_new_hooks ? $this->registerHook('actionCustomerAccountUpdate') : true) &&
|
||||
($this->use_new_hooks ? $this->registerHook('actionValidateCustomerAddressForm') : true)
|
||||
);
|
||||
}
|
||||
|
||||
@ -418,11 +423,26 @@ class RetailCRM extends Module
|
||||
$customerSend = array_merge($customerSend, $address['customer']);
|
||||
}
|
||||
|
||||
if (isset($params['cart'])){
|
||||
$address = $this->addressParse($params['cart']);
|
||||
}
|
||||
|
||||
$customerSend = array_merge($customerSend, $address['customer']);
|
||||
|
||||
$this->api->customersEdit($customerSend);
|
||||
|
||||
return $customerSend;
|
||||
}
|
||||
|
||||
// this hook added in 1.7
|
||||
public function hookActionValidateCustomerAddressForm($params)
|
||||
{
|
||||
$customer = new Customer($params['cart']->id_customer);
|
||||
$customerAddress = array('customer' => $customer, 'cart' => $params['cart']);
|
||||
|
||||
return $this->hookActionCustomerAccountUpdate($customerAddress);
|
||||
}
|
||||
|
||||
public function hookNewOrder($params)
|
||||
{
|
||||
return $this->hookActionOrderStatusPostUpdate($params);
|
||||
@ -490,6 +510,68 @@ class RetailCRM extends Module
|
||||
return $order;
|
||||
}
|
||||
|
||||
private function addressParse($address)
|
||||
{
|
||||
$addressCollection = $address->getAddressCollection();
|
||||
$address = array_shift($addressCollection);
|
||||
|
||||
if ($address instanceof Address) {
|
||||
$postcode = $address->postcode;
|
||||
$city = $address->city;
|
||||
$addres_line = sprintf("%s %s", $address->address1, $address->address2);
|
||||
$countryIso = CountryCore::getIsoById($address->id_country);
|
||||
}
|
||||
|
||||
if (!empty($postcode)) {
|
||||
$customer['address']['index'] = $postcode;
|
||||
$order['delivery']['address']['index'] = $postcode;
|
||||
}
|
||||
|
||||
if (!empty($city)) {
|
||||
$customer['address']['city'] = $city;
|
||||
$order['delivery']['address']['city'] = $city;
|
||||
}
|
||||
|
||||
if (!empty($addres_line)) {
|
||||
$customer['address']['text'] = $addres_line;
|
||||
$order['delivery']['address']['text'] = $addres_line;
|
||||
}
|
||||
|
||||
if (!empty($countryIso)) {
|
||||
$order['countryIso'] = $countryIso;
|
||||
$customer['address']['countryIso'] = $countryIso;
|
||||
}
|
||||
|
||||
$phones = $this->getPhone($address);
|
||||
$order = array_merge($order, $phones['order']);
|
||||
$customer = array_merge($customer, $phones['customer']);
|
||||
$addressArray = array('order' => $order, 'customer' => $customer);
|
||||
|
||||
return $addressArray;
|
||||
}
|
||||
|
||||
private function getPhone($address)
|
||||
{
|
||||
if (!empty($address->phone_mobile)){
|
||||
$order['phone'] = $address->phone_mobile;
|
||||
$customer['phones'][] = array('number'=> $address->phone_mobile);
|
||||
}
|
||||
|
||||
if (!empty($address->phone)){
|
||||
$order['additionalPhone'] = $address->phone;
|
||||
$customer['phones'][] = array('number'=> $address->phone);
|
||||
}
|
||||
|
||||
if (!isset($order['phone']) && !empty($order['additionalPhone'])){
|
||||
$order['phone'] = $order['additionalPhone'];
|
||||
unset($order['additionalPhone']);
|
||||
}
|
||||
|
||||
$phonesArray = array('customer' => $customer, 'order' => $order);
|
||||
|
||||
return $phonesArray;
|
||||
}
|
||||
|
||||
public function hookActionOrderStatusPostUpdate($params)
|
||||
{
|
||||
$delivery = json_decode(Configuration::get('RETAILCRM_API_DELIVERY'), true);
|
||||
@ -521,9 +603,11 @@ class RetailCRM extends Module
|
||||
}
|
||||
|
||||
$cart = $params['cart'];
|
||||
|
||||
$addressCollection = $cart->getAddressCollection();
|
||||
$address = array_shift($addressCollection);
|
||||
$address = $this->addressParse($address);
|
||||
|
||||
$customer = array_merge($customer, $address['customer']);
|
||||
$order = array_merge($order, $address['order']);
|
||||
$comment = $params['order']->getFirstMessage();
|
||||
@ -754,74 +838,6 @@ class RetailCRM extends Module
|
||||
return $output;
|
||||
}
|
||||
|
||||
private function addressParse($address)
|
||||
{
|
||||
|
||||
if ($address instanceof Address) {
|
||||
$postcode = $address->postcode;
|
||||
$city = $address->city;
|
||||
$addres_line = sprintf("%s %s", $address->address1, $address->address2);
|
||||
$countryIso = CountryCore::getIsoById($address->id_country);
|
||||
}
|
||||
|
||||
if (!empty($postcode)) {
|
||||
$customer['address']['index'] = $postcode;
|
||||
$order['delivery']['address']['index'] = $postcode;
|
||||
}
|
||||
|
||||
if (!empty($city)) {
|
||||
$customer['address']['city'] = $city;
|
||||
$order['delivery']['address']['city'] = $city;
|
||||
}
|
||||
|
||||
if (!empty($addres_line)) {
|
||||
$customer['address']['text'] = $addres_line;
|
||||
$order['delivery']['address']['text'] = $addres_line;
|
||||
}
|
||||
|
||||
if (!empty($countryIso)) {
|
||||
$order['countryIso'] = $countryIso;
|
||||
$customer['address']['countryIso'] = $countryIso;
|
||||
}
|
||||
|
||||
$phones = $this->getPhone($address);
|
||||
|
||||
if ($phones !== false) {
|
||||
$order = array_merge($order, $phones['order']);
|
||||
$customer = array_merge($customer, $phones['customer']);
|
||||
}
|
||||
|
||||
$addressArray = array('order' => $order, 'customer' => $customer);
|
||||
|
||||
return $addressArray;
|
||||
}
|
||||
|
||||
private function getPhone($address)
|
||||
{
|
||||
if (!empty($address->phone_mobile)){
|
||||
$order['phone'] = $address->phone_mobile;
|
||||
$customer['phones'][] = array('number'=> $address->phone_mobile);
|
||||
}
|
||||
|
||||
if (!empty($address->phone)){
|
||||
$order['additionalPhone'] = $address->phone;
|
||||
$customer['phones'][] = array('number'=> $address->phone);
|
||||
}
|
||||
|
||||
if (!isset($order['phone']) && !empty($order['additionalPhone'])){
|
||||
$order['phone'] = $order['additionalPhone'];
|
||||
unset($order['additionalPhone']);
|
||||
}
|
||||
if (!empty($customer) && !empty($order)) {
|
||||
$phonesArray = array('customer' => $customer, 'order' => $order);
|
||||
|
||||
return $phonesArray;
|
||||
} else {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate/deactivate module in marketplace retailCRM
|
||||
*
|
||||
|
@ -48,6 +48,7 @@ class RetailCRMTest extends RetailcrmTestCase
|
||||
public function testHookActionCustomerAccountUpdate()
|
||||
{
|
||||
$customer = new Customer(1);
|
||||
|
||||
$params = array('customer' => $customer);
|
||||
$customer = $this->retailcrmModule->hookActionCustomerAccountUpdate($params);
|
||||
|
||||
@ -125,6 +126,11 @@ class RetailCRMTest extends RetailcrmTestCase
|
||||
$this->assertArrayHasKey('lastName', $result);
|
||||
$this->assertArrayHasKey('email', $result);
|
||||
$this->assertArrayHasKey('delivery', $result);
|
||||
$this->assertArrayHasKey('address', $result['delivery']);
|
||||
$this->assertArrayHasKey('city', $result['delivery']['address']);
|
||||
$this->assertArrayHasKey('text', $result['delivery']['address']);
|
||||
$this->assertArrayHasKey('index', $result['delivery']['address']);
|
||||
$this->assertArrayHasKey('countryIso', $result);
|
||||
$this->assertArrayHasKey('items', $result);
|
||||
$this->assertArrayHasKey('customer', $result);
|
||||
$this->assertArrayHasKey('externalId', $result['customer']);
|
||||
|
Loading…
x
Reference in New Issue
Block a user