ref #89649 изменена логика обработки купонов
Добавлен текст и переводы при настройке модуля
This commit is contained in:
parent
68f9ac0369
commit
d23b123151
7 changed files with 35 additions and 13 deletions
|
@ -125,7 +125,13 @@ msgid "Statuses"
|
|||
msgstr "Los estados"
|
||||
|
||||
msgid "Coupon"
|
||||
msgstr 'Cupón'
|
||||
msgstr "Cupón"
|
||||
|
||||
msgid "When working with coupons through CRM, it is impossible to transfer manual discounts"
|
||||
msgstr "Al trabajar con cupones a través de CRM, es imposible transferir descuentos manuales"
|
||||
|
||||
msgid "The custom field must be in the form of a string or text. An example of filling in a field in CRM: `code_coupon` or `code_coupon1; code_coupon2`"
|
||||
msgstr "El campo personalizado debe tener el formato de una cadena o texto. Un ejemplo de cómo completar un campo en CRM: `code_coupon` o `code_coupon1; código_cupón2`"
|
||||
|
||||
msgid "Payment types"
|
||||
msgstr "Métodos de pago"
|
||||
|
|
|
@ -136,6 +136,12 @@ msgstr "Статусы"
|
|||
msgid "Coupon"
|
||||
msgstr "Купон"
|
||||
|
||||
msgid "When working with coupons through CRM, it is impossible to transfer manual discounts"
|
||||
msgstr "При работе с купонами через CRM, невозможно передавать ручные скидки."
|
||||
|
||||
msgid "The custom field must be in the form of a string or text. An example of filling in a field in CRM: `code_coupon` or `code_coupon1; code_coupon2`"
|
||||
msgstr "Пользовательское поле должно быть формата string или text. Пример заполнения поля в CRM при использовании нескольких купонов: code_coupon_1; code_coupon_2"
|
||||
|
||||
msgid "Payment types"
|
||||
msgstr "Способы оплаты"
|
||||
|
||||
|
|
|
@ -361,6 +361,18 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
|
|||
'id' => 'coupon_options'
|
||||
];
|
||||
|
||||
$this->form_fields['coupon_notification'] = [
|
||||
'id' => 'coupon_options',
|
||||
'css' => 'max-width:400px;resize: none;height:150px;',
|
||||
'type' => 'textarea',
|
||||
'title' => __('Attention!', 'retailcrm'),
|
||||
'value' => '',
|
||||
'placeholder' => __('When working with coupons through CRM, it is impossible to transfer manual discounts', 'retailcrm') .
|
||||
PHP_EOL . PHP_EOL .
|
||||
__('The custom field must be in the form of a string or text. An example of filling in a field in CRM: `code_coupon` or `code_coupon1; code_coupon2`', 'retailcrm'),
|
||||
'custom_attributes' => ['readonly' => 'readonly'],
|
||||
];
|
||||
|
||||
$this->form_fields['woo_coupon_apply_field'] = [
|
||||
'title' => __('Coupon', 'retailcrm'),
|
||||
'css' => 'min-width:350px;',
|
||||
|
@ -368,6 +380,7 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
|
|||
'type' => 'select',
|
||||
'options' => $coupon_option_list,
|
||||
'desc_tip' => true,
|
||||
'description' => __('The custom field must be in the form of a string or text. An example of filling in a field in CRM: `code_coupon` or `code_coupon1; code_coupon2`', 'retailcrm')
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -300,7 +300,6 @@ if (!class_exists('WC_Retailcrm_History')) :
|
|||
);
|
||||
}
|
||||
}
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Exception $exception) {
|
||||
WC_Retailcrm_Logger::add(
|
||||
sprintf(
|
||||
|
@ -312,7 +311,6 @@ if (!class_exists('WC_Retailcrm_History')) :
|
|||
|
||||
continue;
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
|
@ -509,8 +507,8 @@ if (!class_exists('WC_Retailcrm_History')) :
|
|||
}
|
||||
}
|
||||
|
||||
$this->addProductInWcOrder($wcOrder, $wcProduct, $crmProduct);//TODO изменить логику, передавая просто данные, уже после в зависимости от наличия купонов выполнять определенные действия
|
||||
// вообще без разницы как из создавать, скидки все равно сбрасываются
|
||||
$this->addProductInWcOrder($wcOrder, $wcProduct, $crmProduct);
|
||||
|
||||
foreach ($wcOrder->get_items() as $orderItemId => $orderItem) {
|
||||
$arItemsNew[$orderItemId] = $orderItemId;
|
||||
}
|
||||
|
@ -550,7 +548,7 @@ if (!class_exists('WC_Retailcrm_History')) :
|
|||
wc_delete_order_item($itemExternalId[1]);
|
||||
}
|
||||
|
||||
$this->updateProductInWcOrder($wcOrderItem, $crmProduct);//TODO изменить логику, передавая просто данные, уже после в зависимости от наличия купонов выполнять определенные действия
|
||||
$this->updateProductInWcOrder($wcOrderItem, $crmProduct);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -842,7 +840,7 @@ if (!class_exists('WC_Retailcrm_History')) :
|
|||
$arItemsOld[$orderItemId] = $orderItemId;
|
||||
}
|
||||
|
||||
$this->addProductInWcOrder($wcOrder, $wcProduct, $crmProduct); //TODO изменить логику, передавая просто данные, уже после в зависимости от наличия купонов выполнять определенные действия
|
||||
$this->addProductInWcOrder($wcOrder, $wcProduct, $crmProduct);
|
||||
|
||||
foreach ($wcOrder->get_items() as $orderItemId => $orderItem) {
|
||||
$arItemsNew[$orderItemId] = $orderItemId;
|
||||
|
@ -1043,10 +1041,10 @@ if (!class_exists('WC_Retailcrm_History')) :
|
|||
$rewriteItems = false;
|
||||
$wcOrderCoupons = $wcOrder->get_coupon_codes();
|
||||
|
||||
if (!empty($orderHistory['customFields'])
|
||||
if (isset($orderHistory['customFields'])
|
||||
&& array_key_exists($couponField, $orderHistory['customFields'])
|
||||
&& empty($orderHistory['customFields'][$couponField])
|
||||
&& !empty($wcOrderCoupons)
|
||||
&& $wcOrderCoupons
|
||||
) {
|
||||
foreach ($wcOrderCoupons as $code) {
|
||||
$wcOrder->remove_coupon($code);
|
||||
|
@ -1071,11 +1069,10 @@ if (!class_exists('WC_Retailcrm_History')) :
|
|||
}
|
||||
}
|
||||
|
||||
if (!$rewriteItems && $this->recalculateCoupons) {
|
||||
if (($rewriteItems || $this->recalculateCoupons)
|
||||
&& ($wcOrderCoupons || !empty($orderHistory['customFields'][$couponField]))) {
|
||||
$wcOrder->recalculate_coupons();
|
||||
}
|
||||
|
||||
if ($rewriteItems || $this->recalculateCoupons) {
|
||||
$orderItem = new WC_Retailcrm_Order_Item($this->retailcrmSettings);
|
||||
$orderItems = [];
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -120,7 +120,7 @@ class WC_Retailcrm_Orders_Test extends WC_Retailcrm_Test_Case_Helper
|
|||
$this->assertEquals($orderData['customFields']['crm_order'], 'test_custom_fields');
|
||||
$this->assertEquals($orderData['customerComment'], 'crm_customer_comment_test');
|
||||
$this->assertEquals($orderData['delivery']['address']['text'], 'crm_address_text_test');
|
||||
$this->assertEquals($orderData['customFields']['testField'], 'test1;test2;');
|
||||
$this->assertEquals($orderData['customFields']['testField'], 'test1; test2;');
|
||||
} else {
|
||||
$this->assertEquals(null, $order);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue