mirror of
https://github.com/retailcrm/prestashop-module.git
synced 2025-03-02 19:33:14 +03:00
v2.2.7
This commit is contained in:
parent
8f2cb8c1b2
commit
3f0abdc409
@ -1,3 +1,7 @@
|
|||||||
|
## v.2.2.7
|
||||||
|
* Добавлена отправка адреса клиента при обновлении покупателя на стороне сайта
|
||||||
|
* Добавлены методы получения адреса и телефона
|
||||||
|
|
||||||
## v.2.2.6
|
## v.2.2.6
|
||||||
* Добавлена активация модуля в маркетплейсе retailCRM
|
* Добавлена активация модуля в маркетплейсе retailCRM
|
||||||
|
|
||||||
|
@ -394,6 +394,7 @@ class RetailCRM extends Module
|
|||||||
public function hookActionCustomerAccountUpdate($params)
|
public function hookActionCustomerAccountUpdate($params)
|
||||||
{
|
{
|
||||||
$customer = $params['customer'];
|
$customer = $params['customer'];
|
||||||
|
|
||||||
$customerSend = array(
|
$customerSend = array(
|
||||||
'externalId' => $customer->id,
|
'externalId' => $customer->id,
|
||||||
'firstName' => $customer->firstname,
|
'firstName' => $customer->firstname,
|
||||||
@ -402,6 +403,21 @@ class RetailCRM extends Module
|
|||||||
'birthday' => $customer->birthday
|
'birthday' => $customer->birthday
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$addreses = $customer->getAddresses($this->default_lang);
|
||||||
|
$address = array_shift($addreses);
|
||||||
|
|
||||||
|
if (!empty($address)){
|
||||||
|
|
||||||
|
if (is_object($address)) {
|
||||||
|
$address = $this->addressParse($address);
|
||||||
|
} else {
|
||||||
|
$address = new Address($address['id_address']);
|
||||||
|
$address = $this->addressParse($address);
|
||||||
|
}
|
||||||
|
|
||||||
|
$customerSend = array_merge($customerSend, $address['customer']);
|
||||||
|
}
|
||||||
|
|
||||||
$this->api->customersEdit($customerSend);
|
$this->api->customersEdit($customerSend);
|
||||||
|
|
||||||
return $customerSend;
|
return $customerSend;
|
||||||
@ -507,53 +523,9 @@ class RetailCRM extends Module
|
|||||||
$cart = $params['cart'];
|
$cart = $params['cart'];
|
||||||
$addressCollection = $cart->getAddressCollection();
|
$addressCollection = $cart->getAddressCollection();
|
||||||
$address = array_shift($addressCollection);
|
$address = array_shift($addressCollection);
|
||||||
|
$address = $this->addressParse($address);
|
||||||
if ($address instanceof Address) {
|
$customer = array_merge($customer, $address['customer']);
|
||||||
$additionalPhone = !empty($address->phone) ? $address->phone : '';
|
$order = array_merge($order, $address['order']);
|
||||||
$phone = !empty($address->phone_mobile) ? $address->phone_mobile : '';
|
|
||||||
$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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
$comment = $params['order']->getFirstMessage();
|
||||||
|
|
||||||
if ($comment !== false) {
|
if ($comment !== false) {
|
||||||
@ -782,6 +754,74 @@ class RetailCRM extends Module
|
|||||||
return $output;
|
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
|
* Activate/deactivate module in marketplace retailCRM
|
||||||
*
|
*
|
||||||
|
@ -57,6 +57,11 @@ class RetailCRMTest extends RetailcrmTestCase
|
|||||||
$this->assertArrayHasKey('lastName', $customer);
|
$this->assertArrayHasKey('lastName', $customer);
|
||||||
$this->assertArrayHasKey('email', $customer);
|
$this->assertArrayHasKey('email', $customer);
|
||||||
$this->assertArrayHasKey('birthday', $customer);
|
$this->assertArrayHasKey('birthday', $customer);
|
||||||
|
$this->assertArrayHasKey('address', $customer);
|
||||||
|
$this->assertArrayHasKey('index', $customer['address']);
|
||||||
|
$this->assertArrayHasKey('city', $customer['address']);
|
||||||
|
$this->assertArrayHasKey('text', $customer['address']);
|
||||||
|
$this->assertArrayHasKey('countryIso', $customer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHookActionOrderEdited()
|
public function testHookActionOrderEdited()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user