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

CC-29675 Shipment Type support on Checkout & OMS #2058

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@



This document describes how to ingrate the [Order Management](/docs/scos/user/features/{{page.version}}/order-management-feature-overview/order-management-feature-overview.html) + [Inventory Management](/docs/pbc/all/warehouse-management-system/{{page.version}}/base-shop/inventory-management-feature-overview.html) feature into a Spryker project.
This document describes how to integrate the [Order Management](/docs/scos/user/features/{{page.version}}/order-management-feature-overview/order-management-feature-overview.html) + [Inventory Management](/docs/pbc/all/warehouse-management-system/{{page.version}}/base-shop/inventory-management-feature-overview.html) features into a Spryker project.

{% info_block errorBox %}

Expand All @@ -22,9 +22,9 @@ Follow the steps below to install the Order Management + Inventory Management fe

Install the required features:

| NAME | VERSION | INTEGRATION GUIDE |
|--------------|------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
| Order Management | {{page.version}} | [Order Management feature integration](/docs/scos/dev/feature-integration-guides/{{page.version}}/order-management-feature-integration.html)
| NAME | VERSION | INTEGRATION GUIDE |
|----------------------|------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| Order Management | {{page.version}} | [Order Management feature integration](/docs/scos/dev/feature-integration-guides/{{page.version}}/order-management-feature-integration.html) |
| Inventory Management | {{page.version}} | [Inventory Management feature integration](docs/scos/dev/feature-integration-guides/{{page.version}}/install-the-inventory-management-feature.md) |


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@


## Install feature core

### Prerequisites

To start feature integration, overview, and install the necessary features:

| NAME | VERSION |
|--------------|------------------|
| Shipment | {{page.version}} |
| Cart | {{page.version}} |
| Prices | {{page.version}} |

### Install the required modules using Composer

Run the following commands to install the required modules:

```bash
composer require spryker/shipment-cart-connector: "^2.1.0" spryker/shipment-type-cart: "^0.1.0" --update-with-dependencies
```
{% info_block warningBox "Verification" %}

Make sure that the following modules have been installed:

| MODULE | EXPECTED DIRECTORY |
|-----------------------|----------------------------------------|
| ShipmentCartConnector | vendor/spryker/shipment-cart-connector |
| ShipmentTypeCart | vendor/spryker/shipment-type-cart |

{% endinfo_block %}

### Set up transfer objects

Run the following command(s) to apply transfer changes:

```bash
console transfer:generate
```
{% info_block warningBox "Verification" %}

Make sure that the following changes have been applied in transfer objects:

| TRANSFER | TYPE | EVENT | PATH |
|---------------------------|-------|---------|-----------------------------------------------------------------|
| ShipmentMethods | class | Created | src/Generated/Shared/Transfer/ShipmentMethodsTransfer |
| ShipmentMethod | class | Created | src/Generated/Shared/Transfer/ShipmentMethodTransfer |
| Order | class | Created | src/Generated/Shared/Transfer/OrderTransfer |
| Quote | class | Created | src/Generated/Shared/Transfer/QuoteTransfer |
| Item | class | Created | src/Generated/Shared/Transfer/ItemTransfer |
| Expense | class | Created | src/Generated/Shared/Transfer/ExpenseTransfer |
| MoneyValue | class | Created | src/Generated/Shared/Transfer/MoneyValueTransfer |
| Money | class | Created | src/Generated/Shared/Transfer/MoneyTransfer |
| CartPreCheckResponse | class | Created | src/Generated/Shared/Transfer/CartPreCheckResponseTransfer |
| Message | class | Created | src/Generated/Shared/Transfer/MessageTransfer |
| CartChange | class | Created | src/Generated/Shared/Transfer/CartChangeTransfer |
| Currency | class | Created | src/Generated/Shared/Transfer/CurrencyTransfer |
| ShipmentGroup | class | Created | src/Generated/Shared/Transfer/ShipmentGroupTransfer |
| Shipment | class | Created | src/Generated/Shared/Transfer/ShipmentTransfer` |
| ShipmentMethodsCollection | class | Created | src/Generated/Shared/Transfer/ShipmentMethodsCollectionTransfer |
| ShipmentType | class | Created | src/Generated/Shared/Transfer/ShipmentTypeTransfer |
| ShipmentTypeCollection | class | Created | src/Generated/Shared/Transfer/ShipmentTypeCollectionTransfer |
| ShipmentTypeConditions | class | Created | src/Generated/Shared/Transfer/ShipmentTypeConditionsTransfer |
| ShipmentTypeCriteria | class | Created | src/Generated/Shared/Transfer/ShipmentTypeCriteriaTransfer |
| CheckoutResponse | class | Created | src/Generated/Shared/Transfer/CheckoutResponseTransfer |
| CheckoutError | class | Created | src/Generated/Shared/Transfer/CheckoutErrorTransfer |
| Store | class | Created | src/Generated/Shared/Transfer/StoreTransfer |

{% endinfo_block %}

### Set up behavior

Register the following plugins:

| PLUGIN | SPECIFICATION | PREREQUISITES | NAMESPACE |
|-----------------------------------------|-------------------------------------------------------------------------------------------------------------|----------------------------------------------|---------------------------------------------------------------------------------------------------|
| CartShipmentCartOperationPostSavePlugin | Recalculates the shipment expenses. | Replacement for `CartShipmentExpanderPlugin` | Spryker\Zed\ShipmentCartConnector\Communication\Plugin\Cart |
| CartShipmentPreCheckPlugin | Validates if current shipment method is still valid in cart shipments. | | Spryker\Zed\ShipmentCartConnector\Communication\Plugin\Cart |
| SanitizeCartShipmentItemExpanderPlugin | Clears quote shipping data if a user modified quote items. | | Spryker\Zed\ShipmentCartConnector\Communication\Plugin\Cart |
| ShipmentTypeCheckoutPreConditionPlugin | Validates if selected shipment type have relation to selected shipment method, current store and is active. | | Spryker\Zed\ShipmentTypeCart\Communication\Plugin\Checkout\ShipmentTypeCheckoutPreConditionPlugin |

**Pyz\Zed\Cart\CartDependencyProvider**

```php
<?php

namespace Pyz\Zed\Cart;

use Spryker\Zed\Cart\CartDependencyProvider as SprykerCartDependencyProvider;
use Spryker\Zed\Kernel\Container;
use Spryker\Zed\ShipmentCartConnector\Communication\Plugin\Cart\CartShipmentCartOperationPostSavePlugin;
use Spryker\Zed\ShipmentCartConnector\Communication\Plugin\Cart\SanitizeCartShipmentItemExpanderPlugin;

class CartDependencyProvider extends SprykerCartDependencyProvider
{
/**
* @param \Spryker\Zed\Kernel\Container $container
*
* @return \Spryker\Zed\CartExtension\Dependency\Plugin\ItemExpanderPluginInterface[]
*/
protected function getExpanderPlugins(Container $container)
{
return [
new SanitizeCartShipmentItemExpanderPlugin(),
];
}

/**
* @param \Spryker\Zed\Kernel\Container $container
*
* @return \Spryker\Zed\CartExtension\Dependency\Plugin\CartOperationPostSavePluginInterface[]
*/
protected function getPostSavePlugins(Container $container)
{
return [
new CartShipmentCartOperationPostSavePlugin(),
];
}
}
```

**src/Pyz/Zed/Checkout/CheckoutDependencyProvider.php**

```php
<?php

namespace Pyz\Zed\Checkout;

use Spryker\Zed\Checkout\CheckoutDependencyProvider as SprykerCheckoutDependencyProvider;
use Spryker\Zed\Kernel\Container;
use Spryker\Zed\ShipmentTypeCart\Communication\Plugin\Checkout\ShipmentTypeCheckoutPreConditionPlugin;

class CheckoutDependencyProvider extends SprykerCheckoutDependencyProvider
{
/**
* @param \Spryker\Zed\Kernel\Container $container
*
* @return list<\Spryker\Zed\CheckoutExtension\Dependency\Plugin\CheckoutPreConditionPluginInterface>
*/
protected function getCheckoutPreConditions(Container $container): array
{
return [
new ShipmentTypeCheckoutPreConditionPlugin(),
];
}
}
```

{% info_block warningBox "Verification" %}

* Make sure that if you change items in the cart (add, remove or change quantity) then all the shipping methods are sanitized.
* Make sure that if you deactivate shipment type selected during the checkout, you will receive a validation error on checkout summary page.

{% endinfo_block %}


## Install feature frontend

Follow the steps below to install the feature frontend.

### Prerequisites

To start feature integration, integrate the required features:

| NAME | VERSION |
|----------|------------------|
| Shipment | {{page.version}} |
| Cart | {{page.version}} |

### Add translations

Add translations as follows:

1. Append glossary according to your configuration:

**src/data/import/glossary.csv**

```csv
shipment_type_cart.checkout.validation.error,Selected delivery type "%name%" is not available,en_US
shipment_type_cart.checkout.validation.error,Die ausgewählte Lieferart "%name%" ist nicht verfügbar,de_DE
```

2. Import data:

```bash
console data:import glossary
```

{% info_block warningBox "Verification" %}

Make sure that the configured data has been added to the `spy_glossary` table in the database.

{% endinfo_block %}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ Follow the steps below to install the Shipment feature core.
To start the feature integration, integrate the required features:


| NAME | VERSION | INTEGRATION GUIDE |
|--------------|------------------|--------------------------------------------------------------------------------------------------------------------------------------|
| Spryker Core | {{page.version}} | [Spryker Core feature integration](/docs/pbc/all/miscellaneous/{{page.version}}/install-and-upgrade/install-features/install-the-spryker-core-feature.html) | |
| NAME | VERSION | INTEGRATION GUIDE |
|------------------|------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Spryker Core | {{page.version}} | [Spryker Core feature integration](/docs/pbc/all/miscellaneous/{{page.version}}/install-and-upgrade/install-features/install-the-spryker-core-feature.html) |
| Order Management | {{page.version}} | [Order Management feature integration](/docs/scos/dev/feature-integration-guides/{{page.version}}/order-management-feature-integration.html) |

### 1) Install the required modules using Composer

Expand All @@ -38,11 +39,11 @@ Make sure that the following modules have been installed:

| MODULE | EXPECTED DIRECTORY |
|-------------------------|-------------------------------------------|
| SalesShipmentType | vendor/spryker/sales-shipment-type |
| ShipmentDataImport | vendor/spryker/shipment-data-import |
| ShipmentGui | vendor/spryker/shipment-gui |
| Shipment | vendor/spryker/shipment |
| ShipmentType | vendor/spryker/shipment-type |
| ShipmentTypeCart | vendor/spryker/shipment-type-cart |
| ShipmentTypeDataImport | vendor/spryker/shipment-type-data-import |
| ShipmentTypeStorage | vendor/spryker/shipment-type-storage |
| ShipmentTypesBackendApi | vendor/spryker/shipment-types-backend-api |
Expand Down Expand Up @@ -147,13 +148,15 @@ console transfer:generate

Make sure that the following changes have been applied by checking your database:

| DATABASE ENTITY | TYPE | EVENT |
|--------------------------------------|--------|---------|
| spy_shipment_method_store | table | created |
| spy_shipment_type | table | created |
| spy_shipment_type_storage | table | created |
| spy_shipment_type_store | table | created |
| spy_shipment_method.fk_shipment_type | column | created |
| DATABASE ENTITY | TYPE | EVENT |
|---------------------------------------|--------|---------|
| spy_sales_shipment_type | table | created |
| spy_shipment_method_store | table | created |
| spy_shipment_type | table | created |
| spy_shipment_type_storage | table | created |
| spy_shipment_type_store | table | created |
| spy_sales_shipment.fk_shipment_type | column | created |
| spy_shipment_method.fk_shipment_type | column | created |

Make sure that the following changes have been applied in transfer objects:

Expand All @@ -175,6 +178,7 @@ Make sure that the following changes have been applied in transfer objects:
| ShipmentTypeStorageCriteriaTransfer | class | created | src/Generated/Shared/Transfer/ShipmentTypeStorageCriteriaTransfer |
| ShipmentTypeStorageConditionsTransfer | class | created | src/Generated/Shared/Transfer/ShipmentTypeStorageConditionsTransfer |
| ShipmentMethodCollectionTransfer | class | created | src/Generated/Shared/Transfer/ShipmentMethodCollectionTransfer |
| SalesShipmentType | class | created | src/Generated/Shared/Transfer/SalesShipmentTypeTransfer |
| ShipmentMethodTransfer.shipmentType | property | created | src/Generated/Shared/Transfer/ShipmentMethodTransfer |
| ShipmentTransfer.shipmentTypeUuid | property | created | src/Generated/Shared/Transfer/ShipmentTransfer |
| ItemTransfer.shipmentType | property | created | src/Generated/Shared/Transfer/ItemTransfer |
Expand Down Expand Up @@ -979,7 +983,47 @@ Make sure that during checkout on the Shipment step, you can only see shipment m

{% endinfo_block %}

6. To enable the Backend API, register these plugins:
6. Configure shipment type order saver plugins:

| PLUGIN | SPECIFICATION | PREREQUISITES | NAMESPACE |
|---------------------------------------|--------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------|-------------------------------------------------------------|
| ShipmentTypeCheckoutDoSaveOrderPlugin | Persists shipment type data to `spy_sales_shipment_type` table and updates `spy_sales_shipment` with `fk_shipment_type`. | Should be executed after the `SalesOrderShipmentSavePlugin` plugin. | Spryker\Zed\SalesShipmentType\Communication\Plugin\Checkout |


**src/Pyz/Zed/Checkout/CheckoutDependencyProvider.php**

```php
<?php

namespace Pyz\Zed\Checkout;

use Spryker\Zed\Checkout\CheckoutDependencyProvider as SprykerCheckoutDependencyProvider;
use Spryker\Zed\Kernel\Container;
use Spryker\Zed\SalesShipmentType\Communication\Plugin\Checkout\ShipmentTypeCheckoutDoSaveOrderPlugin;

class CheckoutDependencyProvider extends SprykerCheckoutDependencyProvider
{
/**
* @param \Spryker\Zed\Kernel\Container $container
*
* @return list<\Spryker\Zed\Checkout\Dependency\Plugin\CheckoutSaveOrderInterface>|list<\Spryker\Zed\CheckoutExtension\Dependency\Plugin\CheckoutDoSaveOrderInterface>
*/
protected function getCheckoutOrderSavers(Container $container): array
{
return [
new ShipmentTypeCheckoutDoSaveOrderPlugin(),
];
}
}
```

{% info_block warningBox "Verification" %}

Make sure that when you place an order, the selected shipment type is persisted to `spy_sales_shipment_type` and `spy_sales_shipment.fk_sales_shipment_type` is updated.

{% endinfo_block %}

7. To enable the Backend API, register these plugins:

| PLUGIN | SPECIFICATION | PREREQUISITES | NAMESPACE |
|------------------------------------|------------------------------------------|---------------|-----------------------------------------------------------------------|
Expand Down