Skip to content

Commit

Permalink
Правильная установка paymentMethod
Browse files Browse the repository at this point in the history
  • Loading branch information
ivannin committed May 13, 2022
1 parent 506fe59 commit 4fc46ed
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 18 deletions.
Binary file modified CHANGELOG.md
Binary file not shown.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ Turboshop Orders
1. https://example.com/wp-json/turboshop_orders/v1/order/accept -- Принятие заказа
2. https://example.com/wp-json/turboshop_orders/v1/order/status -- Обновление заказа

Ввиду особенностей реализации API Яндекс.Турбо, обе конечные точки выполняют фактически одни и те же действия,
поэтому заказ может быть создан или обновлен обращением к любой конечной точке.


Установка и настройка плагина
-----------------------------
Expand Down
26 changes: 20 additions & 6 deletions classes/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,23 @@ private function update_order( $order, $json, $action, $update_products ) {
$order_comment = $action . ' # ' . $json[ 'id' ] . '<br>' . PHP_EOL;

// Устанавливаем статус заказа
if ( isset( $json[ 'status' ] ) ) {
$order->update_status( apply_filters( 'turboshop_orders_update_status', strtolower( $json[ 'status' ] ), $order, $json ) );
$order_comment .= __('Статус', TURBOSHOP_ORDERS ) . ': ' . $json[ 'status' ] . ' / ' . $json[ 'substatus' ] . '<br>' . PHP_EOL;
if ( isset( $json[ 'paymentType' ] ) ) {
switch ( $json[ 'paymentType' ] ) {
case 'PREPAID':
$order_status = 'wc-processing';
break;

case 'POSTPAID':
$order_status = 'wc-pending';
break;

default:
$order_status = 'wc-on-hold';
break;
}
$order->update_status( apply_filters( 'turboshop_orders_update_status', $order_status, $order, $json ) );
$order_comment .= __('Статус', TURBOSHOP_ORDERS ) . ': ' . $json[ 'status' ] . ' / ' . $json[ 'substatus' ] . '<br>' .
__('Тип оплаты', TURBOSHOP_ORDERS ) . ': ' . $json[ 'paymentType' ] . '<br>' .PHP_EOL;
}

// Устанавливаем способ доставки
Expand All @@ -232,9 +246,9 @@ private function update_order( $order, $json, $action, $update_products ) {
}

// Указываем оплату
if ( isset( $json[ 'paymentType' ] ) ) {
$order->set_payment_method( apply_filters( 'turboshop_orders_set_payment_method', $json[ 'paymentType' ], $order, $json ) );
$order_comment .= __('Оплата', TURBOSHOP_ORDERS ) . ': ' . $json[ 'paymentType' ] . '<br>' . PHP_EOL;
if ( isset( $json[ 'paymentMethod' ] ) ) {
$order->set_payment_method( apply_filters( 'turboshop_orders_set_payment_method', $json[ 'paymentMethod' ], $order, $json ) );
$order_comment .= __('Метод оплаты', TURBOSHOP_ORDERS ) . ': ' . $json[ 'paymentMethod' ] . '<br>' . PHP_EOL;
}

// Примечание к заказу
Expand Down
22 changes: 13 additions & 9 deletions lang/turboshop_orders.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
msgid ""
msgstr ""
"Project-Id-Version: TurboShop Orders\n"
"POT-Creation-Date: 2022-05-05 15:31+0300\n"
"PO-Revision-Date: 2022-05-05 15:30+0300\n"
"POT-Creation-Date: 2022-05-13 15:57+0300\n"
"PO-Revision-Date: 2022-05-13 15:56+0300\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -45,27 +45,31 @@ msgstr ""
msgid "Нет JSON данных для обновления"
msgstr ""

#: classes/plugin.php:208
#: classes/plugin.php:221
msgid "Статус"
msgstr ""

#: classes/plugin.php:219
#: classes/plugin.php:222
msgid "Тип оплаты"
msgstr ""

#: classes/plugin.php:233
msgid "Доставка Яндекс.Турбо"
msgstr ""

#: classes/plugin.php:230
#: classes/plugin.php:245
msgid "Доставка"
msgstr ""

#: classes/plugin.php:236
msgid "Оплата"
#: classes/plugin.php:251
msgid "Метод оплаты"
msgstr ""

#: classes/plugin.php:322
#: classes/plugin.php:343
msgid "Не передан ID заказа Яндекс.Турбо"
msgstr ""

#: classes/plugin.php:379
#: classes/plugin.php:400
msgid "Заказ в Яндекс.Турбо"
msgstr ""

Expand Down

0 comments on commit 4fc46ed

Please sign in to comment.