Skip to content

Commit

Permalink
Merge pull request #58 from BitBagCommerce/hotfix/buying-out-of-stock
Browse files Browse the repository at this point in the history
Fix issues with buying out-of-stock products
  • Loading branch information
senghe authored Jan 5, 2023
2 parents 02edcf8 + 3a4517b commit d720fe5
Showing 4 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/CommandHandler/Cart/AddItemToCartHandler.php
Original file line number Diff line number Diff line change
@@ -74,7 +74,7 @@ public function __invoke(AddItemToCart $addItemToCart): OrderInterface

$isStockSufficient = $this->availabilityChecker->isStockSufficient(
$productVariant,
$cartItem->getQuantity() + $this->getExistingCartItemQuantityFromCart($cart, $cartItem),
$addItemToCart->quantity + $this->getExistingCartItemQuantityFromCart($cart, $cartItem),
);

Assert::true($isStockSufficient, 'There are no that many items on stock.');
2 changes: 1 addition & 1 deletion src/Controller/ThankYouPageController.php
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ public function redirectAction(Request $request): Response
);
}

return new RedirectResponse(sprintf('%s/checkout/thank-you?order=%s', $this->vsf2Host, (string)$orderNumber));
return new RedirectResponse(sprintf('%s/checkout/thank-you?order=%s', $this->vsf2Host, (string) $orderNumber));
}

return new RedirectResponse(
4 changes: 1 addition & 3 deletions src/Fixture/ChannelLocalesFixture.php
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@
namespace BitBag\SyliusVueStorefront2Plugin\Fixture;

use Doctrine\ORM\EntityManagerInterface;
use Sylius\Bundle\CoreBundle\Fixture\Factory\ExampleFactoryInterface;
use Sylius\Bundle\FixturesBundle\Fixture\AbstractFixture;
use Sylius\Component\Channel\Repository\ChannelRepositoryInterface;
use Sylius\Component\Core\Model\ChannelInterface;
@@ -33,7 +32,7 @@ final class ChannelLocalesFixture extends AbstractFixture
public function __construct(
ChannelRepositoryInterface $channelRepository,
RepositoryInterface $localeRepository,
EntityManagerInterface $entityManager
EntityManagerInterface $entityManager,
) {
$this->channelRepository = $channelRepository;
$this->localeRepository = $localeRepository;
@@ -68,6 +67,5 @@ public function load(array $options): void

protected function configureOptionsNode(ArrayNodeDefinition $optionsNode): void
{

}
}
6 changes: 3 additions & 3 deletions src/Resources/api_resources/Order.xml
Original file line number Diff line number Diff line change
@@ -36,12 +36,12 @@ We are hiring developers from all over the world. Join us and start your new, ex
<attribute name="orderTokenValue">
<attribute name="type">String</attribute>
</attribute>
<attribute name="quantity">
<attribute name="type">Int</attribute>
</attribute>
<attribute name="productVariant">
<attribute name="type">String</attribute>
</attribute>
<attribute name="quantity">
<attribute name="type">Int</attribute>
</attribute>
</attribute>
</operation>

0 comments on commit d720fe5

Please sign in to comment.