Skip to content

Commit

Permalink
Workaround if product position in basket was changed by plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
aimeos committed Oct 21, 2016
1 parent 109355a commit fd99224
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions controller/frontend/src/Controller/Frontend/Basket/Standard.php
Expand Up @@ -434,15 +434,20 @@ protected function addProductInStock( \Aimeos\MShop\Order\Item\Base\Product\Ifac
if( $stocklevel === null || $stocklevel > 0 )
{
$position = $this->get()->addProduct( $orderBaseProductItem );
$orderBaseProductItem = clone $this->get()->getProduct( $position );
$quantity = $orderBaseProductItem->getQuantity();

if( $stocklevel > 0 && $stocklevel < $quantity )
try
{
$this->get()->deleteProduct( $position );
$orderBaseProductItem->setQuantity( $stocklevel );
$this->get()->addProduct( $orderBaseProductItem, $position );
$orderBaseProductItem = clone $this->get()->getProduct( $position );
$quantity = $orderBaseProductItem->getQuantity();

if( $stocklevel > 0 && $stocklevel < $quantity )
{
$this->get()->deleteProduct( $position );
$orderBaseProductItem->setQuantity( $stocklevel );
$this->get()->addProduct( $orderBaseProductItem, $position );
}
}
catch( \Aimeos\MShop\Order\Exception $e ) {} // hide error if product position changed by plugin
}

if( $stocklevel !== null && $stocklevel < $quantity )
Expand Down

0 comments on commit fd99224

Please sign in to comment.