diff --git a/README.md b/README.md index 0a1419aba42d68cbb57884ba835a6319b1c16b84..7388a1ef5a1e9a10e3a3247e66216ef6dcfbfa16 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,8 @@ Developers - quiqqerOrderCustomerDataSave [QUI\ERP\Order\Controls\OrderProcess\CustomerData] - quiqqerOrderCustomerDataSaveEnd [QUI\ERP\Order\Controls\OrderProcess\CustomerData] +- quiqqerOrderBasketRemovePos [QUI\ERP\Order\Basket\Basket, pos] + ### Order Events - onOrderStart [\QUI\ERP\Order\OrderProcess] diff --git a/ajax/frontend/basket/removePos.php b/ajax/frontend/basket/removePos.php new file mode 100644 index 0000000000000000000000000000000000000000..eaad60d0874155c6b5b944f6f8d3fd0cb60e8d1b --- /dev/null +++ b/ajax/frontend/basket/removePos.php @@ -0,0 +1,25 @@ +<?php + +/** + * This file contains package_quiqqer_order_ajax_frontend_basket_removePos + */ + +/** + * + * @param integer $basketId + * @param integer $productId + * @return array + */ +QUI::$Ajax->registerFunction( + 'package_quiqqer_order_ajax_frontend_basket_removePos', + function ($basketId, $pos) { + $User = QUI::getUserBySession(); + $Basket = new QUI\ERP\Order\Basket\Basket($basketId, $User); + + QUI::getEvents()->fireEvent( + 'quiqqerOrderBasketRemovePos', + [$Basket, $pos] + ); + }, + ['basketId', 'pos'] +); diff --git a/ajax/frontend/basket/save.php b/ajax/frontend/basket/save.php index e079b6435c374fee16180b47a174c3fa65911cb2..4a66f3c4a4203b0a2e188625aa6fb792fac174f0 100644 --- a/ajax/frontend/basket/save.php +++ b/ajax/frontend/basket/save.php @@ -19,8 +19,7 @@ QUI::$Ajax->registerFunction( 'package_quiqqer_order_ajax_frontend_basket_save', function ($basketId, $products) { - $User = QUI::getUserBySession(); - + $User = QUI::getUserBySession(); $Basket = new QUI\ERP\Order\Basket\Basket($basketId, $User); if (!QUI::getUsers()->isNobodyUser($User)) { diff --git a/bin/frontend/classes/Basket.js b/bin/frontend/classes/Basket.js index d05658576c26293e3d2f4a91a0b794d634b6e528..b272c3305d544bb92a6323119024bbf7038f129a 100644 --- a/bin/frontend/classes/Basket.js +++ b/bin/frontend/classes/Basket.js @@ -13,7 +13,7 @@ * @event onClear [self] * * @event onRefreshBegin [self] - * @event onRefresh [self] + * @event onRefresh [self]f */ define('package/quiqqer/order/bin/frontend/classes/Basket', [ @@ -426,16 +426,23 @@ define('package/quiqqer/order/bin/frontend/classes/Basket', [ var self = this, index = pos - 1; - if (typeof this.$products[index] === 'undefined') { - return Promise.resolve(); - } - - this.fireEvent('refreshBegin', [this]); - this.fireEvent('removeBegin', [this]); + return new Promise(function (resolve) { + QUIAjax.post('package_quiqqer_order_ajax_frontend_basket_removePos', function () { + if (typeof self.$products[index] === 'undefined') { + return resolve(); + } - this.$products.splice(index, 1); + self.fireEvent('refreshBegin', [self]); + self.fireEvent('removeBegin', [self]); - return self.save().then(function () { + self.$products.splice(index, 1); + self.save().then(resolve); + }, { + 'package': 'quiqqer/order', + basketId : self.$basketId, + pos : index + }); + }).then(function () { self.fireEvent('remove', [self]); self.fireEvent('refresh', [self]); }); diff --git a/bin/frontend/controls/OrderProcess.js b/bin/frontend/controls/OrderProcess.js index 987cd98ba9f9562eb48872673d9762c948c22b0a..a63c6f3870efbfecf8263c4ca423e2ca7f67c6e7 100644 --- a/bin/frontend/controls/OrderProcess.js +++ b/bin/frontend/controls/OrderProcess.js @@ -334,7 +334,7 @@ define('package/quiqqer/order/bin/frontend/controls/OrderProcess', [ if (this.getElm().getElement('[data-qui="package/quiqqer/frontend-users/bin/frontend/controls/login/Login"]')) { return; } - +return; QUIAjax.get('package_quiqqer_order_ajax_frontend_order_isLoggedIn', function (isLoggedIn) { if (!isLoggedIn) { // show login diff --git a/src/QUI/ERP/Order/Basket/Basket.php b/src/QUI/ERP/Order/Basket/Basket.php index 703a76755d99dfab81dc0d9371cc86017700d344..608b9b4839c4e4146d4b633c988f89d7181f410b 100644 --- a/src/QUI/ERP/Order/Basket/Basket.php +++ b/src/QUI/ERP/Order/Basket/Basket.php @@ -369,7 +369,7 @@ public function hasOrder() */ public function getOrder() { - if ($this->hash === null) { + if ($this->hash === null || empty($this->hash)) { throw new Exception( QUI::getLocale()->get('quiqqer/order', 'exception.order.not.found'), QUI\ERP\Order\Handler::ERROR_ORDER_NOT_FOUND