This commit is contained in:
parent
7b7371e37f
commit
a0005e1ff8
@ -1,3 +1,6 @@
|
|||||||
|
## 2023-10-17 v.6.4.8
|
||||||
|
- Добавлена передача адреса пункта самовывоза в заказе из Bitrix в CRM
|
||||||
|
|
||||||
## 2023-10-10 v.6.4.7
|
## 2023-10-10 v.6.4.7
|
||||||
- Изменена логика передачи адреса доставки в заказе из Bitrix в CRM
|
- Изменена логика передачи адреса доставки в заказе из Bitrix в CRM
|
||||||
|
|
||||||
|
@ -120,8 +120,7 @@ class RetailCrmOrder
|
|||||||
|
|
||||||
$order['contragent']['contragentType'] = $arParams['optionsContragentType'][$arOrder['PERSON_TYPE_ID']];
|
$order['contragent']['contragentType'] = $arParams['optionsContragentType'][$arOrder['PERSON_TYPE_ID']];
|
||||||
|
|
||||||
|
$countryList = BitrixOrderService::getCountryList();
|
||||||
$countryList = RetailCrmService::getCountryList();
|
|
||||||
$deliveryAddress = ['city' => '', 'text' => '', 'index' => '', 'region' => '', 'countryIso' => ''];
|
$deliveryAddress = ['city' => '', 'text' => '', 'index' => '', 'region' => '', 'countryIso' => ''];
|
||||||
|
|
||||||
//Order fields
|
//Order fields
|
||||||
@ -175,10 +174,19 @@ class RetailCrmOrder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear empty fields
|
// Удаляем пустые значения
|
||||||
$deliveryAddress = array_filter($deliveryAddress);
|
$deliveryAddress = array_filter($deliveryAddress);
|
||||||
|
|
||||||
if (!empty($deliveryAddress)) {
|
// Пункт самовывоза
|
||||||
|
$pickupPointAddress = '';
|
||||||
|
|
||||||
|
if (RetailcrmConfigProvider::needSendPickupPointAddress() === 'Y') {
|
||||||
|
$pickupPointAddress = BitrixOrderService::getPickupPointAddress($arOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($pickupPointAddress !== '') {
|
||||||
|
$order['delivery']['address']['text'] = $pickupPointAddress;
|
||||||
|
} elseif(!empty($deliveryAddress)) {
|
||||||
$order['delivery']['address'] = $deliveryAddress;
|
$order['delivery']['address'] = $deliveryAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Bitrix\Sale\Order;
|
||||||
|
use Bitrix\Main\Context;
|
||||||
|
use Bitrix\Catalog\StoreTable;
|
||||||
|
|
||||||
|
class BitrixOrderService
|
||||||
|
{
|
||||||
|
public static function getCountryList()
|
||||||
|
{
|
||||||
|
$server = Context::getCurrent()->getServer()->getDocumentRoot();
|
||||||
|
$countryList = [];
|
||||||
|
|
||||||
|
if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml')) {
|
||||||
|
$countryFile = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml');
|
||||||
|
|
||||||
|
foreach ($countryFile->country as $country) {
|
||||||
|
$countryList[RCrmActions::fromJSON((string) $country->name)] = (string) $country->alpha;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $countryList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPickupPointAddress($arOrder)
|
||||||
|
{
|
||||||
|
$address = '';
|
||||||
|
$orderInfo = Order::load($arOrder['ID']);
|
||||||
|
|
||||||
|
foreach ($orderInfo->getShipmentCollection() as $store) {
|
||||||
|
$storeId = $store->getStoreId();
|
||||||
|
|
||||||
|
if ($storeId) {
|
||||||
|
$arStore = StoreTable::getRow([
|
||||||
|
'filter' => [
|
||||||
|
'ID' => $storeId,
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (!empty($arStore['ADDRESS'])) {
|
||||||
|
$address = GetMessage('PICKUP_POINT') . $arStore['ADDRESS'];
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $address;
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Bitrix\Main\Context;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class RetailCrmService
|
* Class RetailCrmService
|
||||||
*/
|
*/
|
||||||
@ -180,20 +178,4 @@ class RetailCrmService
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getCountryList()
|
|
||||||
{
|
|
||||||
$server = Context::getCurrent()->getServer()->getDocumentRoot();
|
|
||||||
$countryList = [];
|
|
||||||
|
|
||||||
if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml')) {
|
|
||||||
$countryFile = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml');
|
|
||||||
|
|
||||||
foreach ($countryFile->country as $country) {
|
|
||||||
$countryList[RCrmActions::fromJSON((string) $country->name)] = (string) $country->alpha;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $countryList;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
- Изменена логика передачи адреса доставки в заказе из Bitrix в CRM
|
- Добавлена передача адреса пункта самовывоза в заказе из Bitrix в CRM
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$arModuleVersion = [
|
$arModuleVersion = [
|
||||||
'VERSION' => '6.4.7',
|
'VERSION' => '6.4.8',
|
||||||
'VERSION_DATE' => '2023-10-10 18:00:00'
|
'VERSION_DATE' => '2023-10-17 18:00:00'
|
||||||
];
|
];
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
$MESS["NO_DELIVERY"] = "No delivery";
|
|
||||||
$MESS["PRICE_TYPE"] = "RetailCRM price";
|
|
@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$MESS["PICKUP_POINT"] = "Pick-up point: ";
|
@ -68,6 +68,8 @@ $MESS ['ORDER_NUMBERS'] = 'Transferring order numbers to the store for orders cr
|
|||||||
$MESS ['ORDER_VAT'] = 'Transfer VAT of goods';
|
$MESS ['ORDER_VAT'] = 'Transfer VAT of goods';
|
||||||
$MESS ['CRM_API_VERSION'] = 'API version';
|
$MESS ['CRM_API_VERSION'] = 'API version';
|
||||||
$MESS ['CURRENCY'] = 'Currency set in the order when uploading from CRM';
|
$MESS ['CURRENCY'] = 'Currency set in the order when uploading from CRM';
|
||||||
|
$MESS ['SEND_PICKUP_POINT_ADDRESS'] = 'Transfer the pick-up point';
|
||||||
|
$MESS ['SEND_PICKUP_POINT_ADDRESS_WARNING'] = 'Important! The address of the pick-up point is correctly transmitted with one shipment added in the 1C-Bitrix order. If you have more than one shipment added, only the first one will be transmitted.';
|
||||||
$MESS ['ORDER_DIMENSIONS'] = 'Send dimensions and weight of the products in the order';
|
$MESS ['ORDER_DIMENSIONS'] = 'Send dimensions and weight of the products in the order';
|
||||||
$MESS ['SEND_PAYMENT_AMOUNT'] = 'Send payment amount in the order';
|
$MESS ['SEND_PAYMENT_AMOUNT'] = 'Send payment amount in the order';
|
||||||
$MESS ['INVENTORIES_UPLOAD'] = 'Enable leftovers uploading by warehouse';
|
$MESS ['INVENTORIES_UPLOAD'] = 'Enable leftovers uploading by warehouse';
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
$MESS["NO_DELIVERY"] = "Без доставки";
|
|
||||||
$MESS["PRICE_TYPE"] = "Цена RetailCRM";
|
|
@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$MESS["PICKUP_POINT"] = "Пункт самовывоза: ";
|
@ -89,6 +89,8 @@ $MESS ['ORDER_VAT'] = 'Передавать НДС товаров';
|
|||||||
$MESS ['CRM_API_VERSION'] = 'Версия API клиента';
|
$MESS ['CRM_API_VERSION'] = 'Версия API клиента';
|
||||||
$MESS ['CURRENCY'] = 'Валюта, устанавливаемая в заказе при выгрузке из CRM';
|
$MESS ['CURRENCY'] = 'Валюта, устанавливаемая в заказе при выгрузке из CRM';
|
||||||
$MESS ['ORDER_DIMENSIONS'] = 'Передавать габариты и вес товаров в заказе';
|
$MESS ['ORDER_DIMENSIONS'] = 'Передавать габариты и вес товаров в заказе';
|
||||||
|
$MESS ['SEND_PICKUP_POINT_ADDRESS'] = 'Передавать пункт самовывоза';
|
||||||
|
$MESS ['SEND_PICKUP_POINT_ADDRESS_WARNING'] = 'Важно! Адрес пункта самовывоза корректно передается при одной добавленной отгрузке в заказе 1C-Bitrix. Если у вас добавлено более одной отгрузки, будет передана только первая.';
|
||||||
$MESS ['SEND_PAYMENT_AMOUNT'] = 'Передавать сумму оплаты в заказе';
|
$MESS ['SEND_PAYMENT_AMOUNT'] = 'Передавать сумму оплаты в заказе';
|
||||||
|
|
||||||
$MESS ['INVENTORIES_UPLOAD'] = 'Включить выгрузку остатков в разрезе складов';
|
$MESS ['INVENTORIES_UPLOAD'] = 'Включить выгрузку остатков в разрезе складов';
|
||||||
|
@ -648,6 +648,11 @@ class ConfigProvider
|
|||||||
return self::$orderVat;
|
return self::$orderVat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function needSendPickupPointAddress()
|
||||||
|
{
|
||||||
|
return static::getOption(Constants::CRM_SEND_PICKUP_POINT_ADDRESS);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getOrderHistoryDate
|
* getOrderHistoryDate
|
||||||
*
|
*
|
||||||
|
@ -98,6 +98,7 @@ class Constants
|
|||||||
public const AGREEMENT_PERSONAL_DATA_CODE = 'AGREEMENT_PERSONAL_DATA_CODE';
|
public const AGREEMENT_PERSONAL_DATA_CODE = 'AGREEMENT_PERSONAL_DATA_CODE';
|
||||||
public const AGREEMENT_LOYALTY_PROGRAM_CODE = 'AGREEMENT_LOYALTY_PROGRAM_CODE';
|
public const AGREEMENT_LOYALTY_PROGRAM_CODE = 'AGREEMENT_LOYALTY_PROGRAM_CODE';
|
||||||
public const CART = 'cart';
|
public const CART = 'cart';
|
||||||
|
public const CRM_SEND_PICKUP_POINT_ADDRESS = 'send_pickup_point_address';
|
||||||
public const LP_EVENTS = [
|
public const LP_EVENTS = [
|
||||||
['EVENT_NAME' => 'OnSaleOrderSaved', 'FROM_MODULE' => 'sale'],
|
['EVENT_NAME' => 'OnSaleOrderSaved', 'FROM_MODULE' => 'sale'],
|
||||||
['EVENT_NAME' => 'OnSaleComponentOrderResultPrepared', 'FROM_MODULE' => 'sale'],
|
['EVENT_NAME' => 'OnSaleComponentOrderResultPrepared', 'FROM_MODULE' => 'sale'],
|
||||||
|
@ -406,13 +406,6 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||||||
$contragentTypeArr[$orderType['ID']] = htmlspecialchars(trim($_POST['contragent-type-' . $orderType['ID']]));
|
$contragentTypeArr[$orderType['ID']] = htmlspecialchars(trim($_POST['contragent-type-' . $orderType['ID']]));
|
||||||
}
|
}
|
||||||
|
|
||||||
//order numbers
|
|
||||||
$orderVat = htmlspecialchars(trim($_POST['order-vat'])) ?: 'N';
|
|
||||||
$orderNumbers = htmlspecialchars(trim($_POST['order-numbers'])) ?: 'N';
|
|
||||||
$orderDimensions = htmlspecialchars(trim($_POST[$CRM_DIMENSIONS])) ?: 'N';
|
|
||||||
$sendPaymentAmount = htmlspecialchars(trim($_POST[RetailcrmConstants::SEND_PAYMENT_AMOUNT])) ?: 'N';
|
|
||||||
$crmCouponFiled = htmlspecialchars(trim($_POST['crm-coupon-field'])) ?: 'N';
|
|
||||||
|
|
||||||
//stores
|
//stores
|
||||||
$bitrixStoresArr = [];
|
$bitrixStoresArr = [];
|
||||||
$bitrixShopsArr = [];
|
$bitrixShopsArr = [];
|
||||||
@ -810,17 +803,22 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||||||
COption::SetOptionString(
|
COption::SetOptionString(
|
||||||
$mid,
|
$mid,
|
||||||
$CRM_ORDER_NUMBERS,
|
$CRM_ORDER_NUMBERS,
|
||||||
$orderNumbers
|
htmlspecialchars(trim($_POST['order-numbers'])) ?: 'N'
|
||||||
);
|
);
|
||||||
COption::SetOptionString(
|
COption::SetOptionString(
|
||||||
$mid,
|
$mid,
|
||||||
$CRM_ORDER_VAT,
|
$CRM_ORDER_VAT,
|
||||||
$orderVat
|
htmlspecialchars(trim($_POST['order-vat'])) ?: 'N'
|
||||||
);
|
);
|
||||||
COption::SetOptionString(
|
COption::SetOptionString(
|
||||||
$mid,
|
$mid,
|
||||||
$CRM_COUPON_FIELD,
|
$CRM_COUPON_FIELD,
|
||||||
$crmCouponFiled
|
htmlspecialchars(trim($_POST['crm-coupon-field'])) ?: 'N'
|
||||||
|
);
|
||||||
|
COption::SetOptionString(
|
||||||
|
$mid,
|
||||||
|
Constants::CRM_SEND_PICKUP_POINT_ADDRESS,
|
||||||
|
htmlspecialchars(trim($_POST['send-pickup-point-address'])) ?: 'N'
|
||||||
);
|
);
|
||||||
COption::SetOptionString(
|
COption::SetOptionString(
|
||||||
$mid,
|
$mid,
|
||||||
@ -894,9 +892,9 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||||||
COption::SetOptionString(
|
COption::SetOptionString(
|
||||||
$mid,
|
$mid,
|
||||||
$CRM_DIMENSIONS,
|
$CRM_DIMENSIONS,
|
||||||
$orderDimensions
|
htmlspecialchars(trim($_POST[$CRM_DIMENSIONS])) ?: 'N'
|
||||||
);
|
);
|
||||||
RetailcrmConfigProvider::setSendPaymentAmount($sendPaymentAmount);
|
RetailcrmConfigProvider::setSendPaymentAmount(htmlspecialchars(trim($_POST[Constants::SEND_PAYMENT_AMOUNT])) ?: 'N');
|
||||||
RetailCrmConfigProvider::setDiscountRound($discount_round);
|
RetailCrmConfigProvider::setDiscountRound($discount_round);
|
||||||
RetailcrmConfigProvider::setCart($optionCart);
|
RetailcrmConfigProvider::setCart($optionCart);
|
||||||
COption::SetOptionString(
|
COption::SetOptionString(
|
||||||
@ -1024,8 +1022,9 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||||||
$optionsLegalDetails = unserialize(COption::GetOptionString($mid, $CRM_LEGAL_DETAILS, 0));
|
$optionsLegalDetails = unserialize(COption::GetOptionString($mid, $CRM_LEGAL_DETAILS, 0));
|
||||||
$optionsCustomFields = unserialize(COption::GetOptionString($mid, $CRM_CUSTOM_FIELDS, 0));
|
$optionsCustomFields = unserialize(COption::GetOptionString($mid, $CRM_CUSTOM_FIELDS, 0));
|
||||||
$optionsOrderNumbers = COption::GetOptionString($mid, $CRM_ORDER_NUMBERS, 0);
|
$optionsOrderNumbers = COption::GetOptionString($mid, $CRM_ORDER_NUMBERS, 0);
|
||||||
$optionsOrderVat= COption::GetOptionString($mid, $CRM_ORDER_VAT, 0);
|
$optionsOrderVat = COption::GetOptionString($mid, $CRM_ORDER_VAT, 0);
|
||||||
$canselOrderArr = unserialize(COption::GetOptionString($mid, $CRM_CANSEL_ORDER, 0));
|
$canselOrderArr = unserialize(COption::GetOptionString($mid, $CRM_CANSEL_ORDER, 0));
|
||||||
|
$sendPickupPointAddress = COption::GetOptionString($mid, Constants::CRM_SEND_PICKUP_POINT_ADDRESS, 'N');
|
||||||
|
|
||||||
$optionInventotiesUpload = COption::GetOptionString($mid, $CRM_INVENTORIES_UPLOAD, 0);
|
$optionInventotiesUpload = COption::GetOptionString($mid, $CRM_INVENTORIES_UPLOAD, 0);
|
||||||
$optionStores = unserialize(COption::GetOptionString($mid, $CRM_STORES, 0));
|
$optionStores = unserialize(COption::GetOptionString($mid, $CRM_STORES, 0));
|
||||||
@ -2194,6 +2193,13 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('input[name="send-pickup-point-address"]').change(
|
||||||
|
function(){
|
||||||
|
if ($(this).is(':checked')) {
|
||||||
|
alert('<?php echo GetMessage('SEND_PICKUP_POINT_ADDRESS_WARNING'); ?>');
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -2237,6 +2243,32 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||||||
</b>
|
</b>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="option-head option-other-top option-other-bottom">
|
||||||
|
<b>
|
||||||
|
<label>
|
||||||
|
<input class="addr" type="checkbox" name="send-pickup-point-address" value="Y" <?php if($sendPickupPointAddress === 'Y') {echo "checked";} ?>> <?php echo GetMessage('SEND_PICKUP_POINT_ADDRESS'); ?>
|
||||||
|
</label>
|
||||||
|
</b>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<?php if($sendPickupPointAddress === 'Y') {
|
||||||
|
$warningMessage = GetMessage('SEND_PICKUP_POINT_ADDRESS_WARNING');
|
||||||
|
|
||||||
|
echo sprintf('<tr>
|
||||||
|
<td colspan="2" class="option-head option-other-top option-other-bottom">
|
||||||
|
<b>
|
||||||
|
<label style="color: darkorange">
|
||||||
|
%s
|
||||||
|
</label>
|
||||||
|
</b>
|
||||||
|
</td>
|
||||||
|
</tr>', $warningMessage);
|
||||||
|
} ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" class="option-head option-other-top option-other-bottom">
|
<td colspan="2" class="option-head option-other-top option-other-bottom">
|
||||||
<b>
|
<b>
|
||||||
|
Loading…
Reference in New Issue
Block a user