Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions Classes/Controller/Cart/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,12 @@ protected function dispatchOrderCreateEvents(Item $orderItem): bool
return true;
}

$stockEvent = new StockEvent($this->cart, $orderItem, $this->configurations);
$this->eventDispatcher->dispatch($stockEvent);
if ($stockEvent instanceof StoppableEventInterface && $stockEvent->isPropagationStopped()) {
return true;
if ($this->configurations['settings']['stockEventAfterPaymentEvent'] !== '1') {
$stockEvent = new StockEvent($this->cart, $orderItem, $this->configurations);
$this->eventDispatcher->dispatch($stockEvent);
if ($stockEvent instanceof StoppableEventInterface && $stockEvent->isPropagationStopped()) {
return true;
}
}

$paymentEvent = new PaymentEvent($this->cart, $orderItem, $this->configurations);
Expand All @@ -236,6 +238,14 @@ protected function dispatchOrderCreateEvents(Item $orderItem): bool
return true;
}

if(!isset($stockEvent)) {
$stockEvent = new StockEvent($this->cart, $orderItem, $this->configurations);
$this->eventDispatcher->dispatch($stockEvent);
if ($stockEvent instanceof StoppableEventInterface && $stockEvent->isPropagationStopped()) {
return true;
}
}

$finishEvent = new FinishEvent($this->cart, $orderItem, $this->configurations);
$this->eventDispatcher->dispatch($finishEvent);
if ($finishEvent instanceof StoppableEventInterface && $finishEvent->isPropagationStopped()) {
Expand Down
1 change: 1 addition & 0 deletions Configuration/TypoScript/constants.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ plugin.tx_cart {

settings {
addToCartByAjax = 2278001
stockEventAfterPaymentEvent =

format.currency {
currencySign = €
Expand Down
1 change: 1 addition & 0 deletions Configuration/TypoScript/setup.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ plugin.tx_cart {
autoGenerateNumbers = order

settings {
stockEventAfterPaymentEvent = {$plugin.tx_cart.settings.stockEventAfterPaymentEvent}
cart {
pid = {$plugin.tx_cart.settings.cart.pid}
isNetCart = {$plugin.tx_cart.settings.cart.isNetCart}
Expand Down
18 changes: 18 additions & 0 deletions Documentation/Administrator/Configuration/Base/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Base
}

itemsPerPage =
stockEventAfterPaymentEvent =
}
}

Expand Down Expand Up @@ -67,3 +68,20 @@ plugin.tx_cart.settings
Defines how many records should be displayed per page in the list action.

Also valid: `module.tx_cart.settings.itemsPerPage`.

.. confval:: stockEventAfterPaymentEvent

:Required: false
:Type: boolean
:Default: false

Switch order of PaymentEvent and StockEvent.

If set to `1`, stock handling is processed after payment. This is useful for
external provider (Paypal, Stripe). In this case, the payment provider extension
is responsable to handle StockEvent and FinishingEvent after successful payment.
This ensures that stock isn't changed on failed or aborted payment.

Note: Switching the events can lead to understocking if two customers order
the last product at the same time and the first customer is still in the
payment process..
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'title' => 'Cart',
'description' => 'Shopping Cart(s) for TYPO3',
'category' => 'plugin',
'version' => '10.0.0',
'version' => '10.1.0',
'state' => 'stable',
'author' => 'Daniel Gohlke',
'author_email' => 'ext@extco.de',
Expand Down