Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Msi 2825 hide store pickup on the checkout if one of the products in cart is not available for pickup #2867

Merged
18 changes: 18 additions & 0 deletions InventoryInStorePickupApi/Test/_files/source_items.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,30 @@
SourceItemInterface::QUANTITY => 5,
SourceItemInterface::STATUS => SourceItemInterface::STATUS_IN_STOCK,
],
[
SourceItemInterface::SOURCE_CODE => 'eu-1',
SourceItemInterface::SKU => 'SKU-2',
SourceItemInterface::QUANTITY => 0,
SourceItemInterface::STATUS => SourceItemInterface::STATUS_OUT_OF_STOCK,
],
[
SourceItemInterface::SOURCE_CODE => 'eu-2',
SourceItemInterface::SKU => 'SKU-2',
SourceItemInterface::QUANTITY => 3,
SourceItemInterface::STATUS => SourceItemInterface::STATUS_IN_STOCK,
],
[
SourceItemInterface::SOURCE_CODE => 'eu-3',
SourceItemInterface::SKU => 'SKU-2',
SourceItemInterface::QUANTITY => 0,
SourceItemInterface::STATUS => SourceItemInterface::STATUS_OUT_OF_STOCK,
],
[
SourceItemInterface::SOURCE_CODE => 'eu-disabled',
SourceItemInterface::SKU => 'SKU-2',
SourceItemInterface::QUANTITY => 0,
SourceItemInterface::STATUS => SourceItemInterface::STATUS_OUT_OF_STOCK,
],
[
SourceItemInterface::SOURCE_CODE => 'eu-2',
SourceItemInterface::SKU => 'SKU-3',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

use Magento\Framework\Api\DataObjectHelper;
use Magento\InventoryApi\Api\Data\SourceItemInterface;
use Magento\InventoryApi\Api\Data\SourceItemInterfaceFactory;
use Magento\InventoryApi\Api\SourceItemsSaveInterface;
use Magento\TestFramework\Helper\Bootstrap;

/** @var DataObjectHelper $dataObjectHelper */
$dataObjectHelper = Bootstrap::getObjectManager()->get(DataObjectHelper::class);
/** @var SourceItemInterfaceFactory $sourceItemFactory */
$sourceItemFactory = Bootstrap::getObjectManager()->get(SourceItemInterfaceFactory::class);
/** @var SourceItemsSaveInterface $sourceItemsSave */
$sourceItemsSave = Bootstrap::getObjectManager()->get(SourceItemsSaveInterface::class);

$sourcesItemsData = [
[
SourceItemInterface::SOURCE_CODE => 'eu-1',
SourceItemInterface::SKU => 'SKU-1',
SourceItemInterface::QUANTITY => 5.5,
SourceItemInterface::STATUS => SourceItemInterface::STATUS_IN_STOCK,
],
[
SourceItemInterface::SOURCE_CODE => 'eu-2',
SourceItemInterface::SKU => 'SKU-1',
SourceItemInterface::QUANTITY => 0,
SourceItemInterface::STATUS => SourceItemInterface::STATUS_OUT_OF_STOCK,
],
[
SourceItemInterface::SOURCE_CODE => 'eu-3',
SourceItemInterface::SKU => 'SKU-1',
SourceItemInterface::QUANTITY => 0,
SourceItemInterface::STATUS => SourceItemInterface::STATUS_OUT_OF_STOCK,
],
[
SourceItemInterface::SOURCE_CODE => 'eu-1',
SourceItemInterface::SKU => 'SKU-2',
SourceItemInterface::QUANTITY => 0,
SourceItemInterface::STATUS => SourceItemInterface::STATUS_OUT_OF_STOCK,
],
[
SourceItemInterface::SOURCE_CODE => 'eu-2',
SourceItemInterface::SKU => 'SKU-2',
SourceItemInterface::QUANTITY => 3,
SourceItemInterface::STATUS => SourceItemInterface::STATUS_IN_STOCK,
],
[
SourceItemInterface::SOURCE_CODE => 'eu-3',
SourceItemInterface::SKU => 'SKU-2',
SourceItemInterface::QUANTITY => 0,
SourceItemInterface::STATUS => SourceItemInterface::STATUS_OUT_OF_STOCK,
],
[
SourceItemInterface::SOURCE_CODE => 'eu-1',
SourceItemInterface::SKU => 'SKU-3',
SourceItemInterface::QUANTITY => 0,
SourceItemInterface::STATUS => SourceItemInterface::STATUS_OUT_OF_STOCK,
],
[
SourceItemInterface::SOURCE_CODE => 'eu-3',
SourceItemInterface::SKU => 'SKU-3',
SourceItemInterface::QUANTITY => 10,
SourceItemInterface::STATUS => SourceItemInterface::STATUS_IN_STOCK,
],
[
SourceItemInterface::SOURCE_CODE => 'eu-2',
SourceItemInterface::SKU => 'SKU-3',
SourceItemInterface::QUANTITY => 0,
SourceItemInterface::STATUS => SourceItemInterface::STATUS_OUT_OF_STOCK,
],
];

$sourceItems = [];
foreach ($sourcesItemsData as $sourceItemData) {
/** @var SourceItemInterface $source */
$sourceItem = $sourceItemFactory->create();
$dataObjectHelper->populateWithArray($sourceItem, $sourceItemData, SourceItemInterface::class);
$sourceItems[] = $sourceItem;
}
$sourceItemsSave->execute($sourceItems);
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function setUp()
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items_eu_stock_only.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryInStorePickupApi/Test/_files/source_items_eu_stock_only.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryInStorePickupSalesApi/Test/_files/create_in_store_pickup_quote_on_eu_website_customer.php
*
Expand Down Expand Up @@ -174,7 +174,7 @@ private function assertShippingAddressFields(array $shippingAddressResponse, str
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items_eu_stock_only.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryInStorePickupApi/Test/_files/source_items_eu_stock_only.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryInStorePickupSalesApi/Test/_files/create_in_store_pickup_quote_on_eu_website_customer.php
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function setUp()
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items_eu_stock_only.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryInStorePickupApi/Test/_files/source_items_eu_stock_only.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryInStorePickupSalesApi/Test/_files/create_in_store_pickup_quote_on_eu_website_guest.php
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected function setUp()
* @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php
* @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php
* @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php
* @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items_eu_stock_only.php
* @magentoDataFixture ../../../../app/code/Magento/InventoryInStorePickupApi/Test/_files/source_items_eu_stock_only.php
* @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php
* @magentoDataFixture ../../../../app/code/Magento/InventoryInStorePickupSalesApi/Test/_files/create_in_store_pickup_quote_on_eu_website_guest.php
* @magentoDataFixture ../../../../app/code/Magento/InventoryInStorePickupSalesApi/Test/_files/place_order.php
Expand Down
12 changes: 6 additions & 6 deletions InventoryInStorePickupSalesApi/Test/Api/OrderCreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class OrderCreateTest extends OrderPlacementBase
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items_eu_stock_only.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryInStorePickupApi/Test/_files/source_items_eu_stock_only.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php
*
* @throws \Magento\Framework\Exception\LocalizedException
Expand Down Expand Up @@ -59,7 +59,7 @@ public function testPlaceOrderRegisteredCustomerExistedAddress(): void
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items_eu_stock_only.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryInStorePickupApi/Test/_files/source_items_eu_stock_only.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php
*
* @return void
Expand Down Expand Up @@ -94,7 +94,7 @@ public function testPlaceOrderGuest(): void
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items_eu_stock_only.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryInStorePickupApi/Test/_files/source_items_eu_stock_only.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php
*
* @return void
Expand Down Expand Up @@ -130,7 +130,7 @@ public function testPlaceOrderGuestBillingAddressSameAsShipping(): void
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items_eu_stock_only.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryInStorePickupApi/Test/_files/source_items_eu_stock_only.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php
*
* @return void
Expand Down Expand Up @@ -163,7 +163,7 @@ public function testPlaceOrderRegisteredCustomerNewAddress(): void
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items_eu_stock_only.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryInStorePickupApi/Test/_files/source_items_eu_stock_only.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php
*
* @throws \Magento\Framework\Exception\LocalizedException
Expand Down Expand Up @@ -213,7 +213,7 @@ public function testPlaceOrderRegisteredCustomerExistedAddressSaveNewAddressInAd
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items_eu_stock_only.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryInStorePickupApi/Test/_files/source_items_eu_stock_only.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php
*
* @return void
Expand Down
22 changes: 17 additions & 5 deletions InventoryInStorePickupSalesApi/Test/Api/PlaceOrderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,12 @@ protected function setUp()
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items_eu_stock_only.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryInStorePickupApi/Test/_files/source_items_eu_stock_only.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryInStorePickupSalesApi/Test/_files/create_in_store_pickup_quote_on_eu_website_guest.php
*
* @return void
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function testPlaceOrderWithStorePickupDeliveryMethodGuestCustomer(): void
{
Expand Down Expand Up @@ -120,12 +121,14 @@ public function testPlaceOrderWithStorePickupDeliveryMethodGuestCustomer(): void
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items_eu_stock_only.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryInStorePickupApi/Test/_files/source_items_eu_stock_only.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryInStorePickupSalesApi/Test/_files/create_in_store_pickup_quote_on_eu_website_customer.php
* @magentoConfigFixture store_for_eu_website_store customer/account_share/scope 0
*
* @return void
* @throws \Magento\Framework\Exception\AuthenticationException
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function testPlaceOrderWithStorePickupDeliveryMethodRegisteredCustomerExistedAddress(): void
{
Expand Down Expand Up @@ -163,12 +166,14 @@ public function testPlaceOrderWithStorePickupDeliveryMethodRegisteredCustomerExi
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items_eu_stock_only.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryInStorePickupApi/Test/_files/source_items_eu_stock_only.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryInStorePickupSalesApi/Test/_files/create_in_store_pickup_quote_on_eu_website_customer.php
* @magentoConfigFixture store_for_eu_website_store customer/account_share/scope 0
*
* @return void
* @throws \Magento\Framework\Exception\AuthenticationException
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function testPlaceOrderWithStorePickupDeliveryMethodRegisteredCustomerNewAddress(): void
{
Expand Down Expand Up @@ -208,12 +213,14 @@ public function testPlaceOrderWithStorePickupDeliveryMethodRegisteredCustomerNew
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items_eu_stock_only.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryInStorePickupApi/Test/_files/source_items_eu_stock_only.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryInStorePickupSalesApi/Test/_files/quote_with_save_shipping_address_to_address_book.php
* @magentoConfigFixture store_for_eu_website_store customer/account_share/scope 0
*
* @return void
* @throws \Magento\Framework\Exception\LocalizedException
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function testPlaceOrderWithStorePickupDeliveryMethodRegisteredCustomerAddressSaveInBook(): void
{
Expand Down Expand Up @@ -257,12 +264,14 @@ public function testPlaceOrderWithStorePickupDeliveryMethodRegisteredCustomerAdd
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items_eu_stock_only.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryInStorePickupApi/Test/_files/source_items_eu_stock_only.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryInStorePickupSalesApi/Test/_files/quote_with_shipping_address_same_as_billing.php
* @magentoConfigFixture store_for_eu_website_store customer/account_share/scope 0
*
* @return void
* @throws \Magento\Framework\Exception\AuthenticationException
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function testPlaceOrderWithStorePickupDeliveryMethodRegisteredCustomerSameAsBillingAddress(): void
{
Expand Down Expand Up @@ -304,6 +313,7 @@ private function getStoreHeader(): array
* @param string $password
*
* @return array
* @throws \Magento\Framework\Exception\AuthenticationException
*/
private function getAuthHeader(string $username = 'customer@example.com', string $password = 'password'): array
{
Expand All @@ -317,7 +327,9 @@ private function getAuthHeader(string $username = 'customer@example.com', string
* Verify created order.
*
* @param array $response
*
* @return void
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
private function verifyOrder(array $response): void
{
Expand Down
Loading