Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Нумерация заказа MS2 #393

Merged
merged 11 commits into from
Jun 30, 2020
12 changes: 11 additions & 1 deletion _build/data/transport.settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,16 @@
'area' => 'ms2_cart',
),

'ms2_order_format_num' => array(
'value' => '%y%m',
'xtype' => 'textfield',
'area' => 'ms2_order_format_num',
),
'ms2_order_format_num_separator' => array(
'value' => '/',
'xtype' => 'textfield',
'area' => 'ms2_order_format_num_separator',
),
'ms2_order_grid_fields' => array(
'value' => 'id,num,customer,status,cost,weight,delivery,payment,createdon,updatedon,comment',
'xtype' => 'textarea',
Expand Down Expand Up @@ -314,4 +324,4 @@
$settings[] = $setting;
}

return $settings;
return $settings;
4 changes: 4 additions & 0 deletions core/components/minishop2/lexicon/ru/setting.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@
$_lang['setting_ms2_payment_paypal_cancel_order'] = 'Отмена заказа PayPal';
$_lang['setting_ms2_payment_paypal_cancel_order_desc'] = 'Если включено, заказ будет отменён при отказе от оплаты';

$_lang['setting_ms2_order_format_num'] = 'Формат нумерации заказа';
$_lang['setting_ms2_order_format_num_desc'] = 'Формат нумерации заказа. Доступные значения в формате PHP strftime()';
$_lang['setting_ms2_order_format_num_separator'] = 'Разделитель для нумерации заказа';
$_lang['setting_ms2_order_format_num_separator_desc'] = 'Разделитель для нумерации заказа. Доступние значения "/" и ","';
$_lang['setting_ms2_order_grid_fields'] = 'Поля таблицы заказов';
$_lang['setting_ms2_order_grid_fields_desc'] = 'Список полей, которые будут показаны в таблице заказов. Доступны: "createdon,updatedon,num,cost,cart_cost,delivery_cost,weight,status,delivery,payment,customer,receiver".';
$_lang['setting_ms2_order_address_fields'] = 'Поля адреса доставки';
Expand Down
16 changes: 12 additions & 4 deletions core/components/minishop2/model/minishop2/msorderhandler.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,15 @@ public function getCost($with_cart = true, $only_cost = false)
*/
public function getNum()
{
$cur = date('ym');
$formatNum = htmlspecialchars($this->modx->getOption('ms2_order_format_num', null, '%y%m'));
$formatNumSeparator = trim(preg_replace("/[^,\/\-]/", '', "\/"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно из опции тоже вытаскивать, а то опция как бы есть, но бесполезна.


if ($formatNum){
$cur = strftime($formatNum);
}else{
$cur = date('ym');
}
CrazyBoy49z marked this conversation as resolved.
Show resolved Hide resolved

$num = 0;

$c = $this->modx->newQuery('msOrder');
Expand All @@ -608,10 +616,10 @@ public function getNum()
$num = $c->stmt->fetchColumn();
}
if (empty($num)) {
$num = date('ym') . '/0';
$num = "{$cur}{$formatNumSeparator}0";
Ibochkarev marked this conversation as resolved.
Show resolved Hide resolved
}
$num = explode('/', $num);
$num = $cur . '/' . ($num[1] + 1);
$num = explode($formatNumSeparator, $num);
$num = "{$cur}{$formatNumSeparator}" . ($num[1] + 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Дикое переопределение переменных. Можно переписать чуть более наглядно.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Поправлю только, доберусь, ошибки есть так набросал в браузере, я б совсем завел новое поле в таблице на количество, но думаю это уже нужно будет добавить в minishop3


return $num;
}
Expand Down