feat(order): wire EmptyOrder/GetOrderCost events and set errors#393
Open
Ibochkarev wants to merge 1 commit into
Open
feat(order): wire EmptyOrder/GetOrderCost events and set errors#393Ibochkarev wants to merge 1 commit into
Ibochkarev wants to merge 1 commit into
Conversation
Fire registered msOnBeforeEmptyOrder/msOnEmptyOrder on draft clean and msOnBeforeGetOrderCost/msOnGetOrderCost on getTotalCost. Order::set aggregates per-field add() failures. Draft create stays on SaveOrder; recalculate stays an internal write without inventing new event names.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Описание
Закрывает TODO по событиям черновика/заказа без нового event bus.
OrderDraftManager::clean—msOnBeforeEmptyOrder/msOnEmptyOrder(draft), отказ плагина уходит в API.OrderCostCalculator::getTotalCost—msOnBeforeGetOrderCost/msOnGetOrderCostсreturnedValuesдляcost,delivery_cost,cart_cost,payment_cost(паритет MS2getCost).Order::set— без batch-событий (их нет в реестре MS2/MS3); поля идут черезadd()и уже существующиеmsOnBeforeAddToOrder/msOnAddToOrder; ошибки валидации собираются вdata.errors.msOrder::save()уже шлётmsOnBeforeSaveOrder/msOnSaveOrderсMODE_NEW.recalculate— только запись агрегатов корзины; хуки стоимости наgetTotalCost.Пример плагина
Тип изменений
Order::setпри ошибке поля теперь может вернутьsuccess: falseиdata.errorsвместо безусловного success (раньше ошибкиadd()глотались).Связанные Issues
Closes #343
Как это было протестировано?
php -lна трёх изменённых файлах. Плагин на живом MODX не гонял.Конфигурация тестирования:
feat/343-order-draft-eventsphp -lСкриншоты (если применимо)
Чеклист
Новых ключей лексикона нет:
ms3_order_err_validationуже есть вorder.inc.php.Дополнительные заметки
Связано с контрактом
returnedValues(#219). Не трогает mgr OrdersController API. После неуспешногоmsOnEmptyOrderполя уже очищены — как в MS2.