Install the Cart + Shipment feature

Edit on GitHub

Install feature core

Prerequisites

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

NAME VERSION
Shipment 202307.0
Cart 202307.0
Spryker Core 202307.0
Prices 202307.0

1) Install the required modules

Install the required modules using Composer:

composer require spryker/shipment-cart-connector: "^2.1.0" --update-with-dependencies
Verification

Make sure that the following modules have been installed:

MODULE EXPECTED DIRECTORY
ShipmentCartConnector vendor/spryker/shipment-cart-connector

2) Set up transfer objects

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

console transfer:generate
Verification

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

TRANSFER TYPE EVENT PATH
ShipmentMethodsTransfer class Created src/Generated/Shared/Transfer/ShipmentMethodsTransfer
ShipmentMethodTransfer class Created src/Generated/Shared/Transfer/ShipmentMethodTransfer
OrderTransfer class Created src/Generated/Shared/Transfer/OrderTransfer
QuoteTransfer class Created src/Generated/Shared/Transfer/QuoteTransfer
ItemTransfer class Created src/Generated/Shared/Transfer/ItemTransfer
ExpenseTransfer class Created src/Generated/Shared/Transfer/ExpenseTransfer
MoneyValueTransfer class Created src/Generated/Shared/Transfer/MoneyValueTransfer
MoneyTransfer class Created src/Generated/Shared/Transfer/MoneyTransfer
CartPreCheckResponseTransfer class Created src/Generated/Shared/Transfer/CartPreCheckResponseTransfer
MessageTransfer class Created src/Generated/Shared/Transfer/MessageTransfer
CartChangeTransfer class Created src/Generated/Shared/Transfer/CartChangeTransfer
CurrencyTransfer class Created src/Generated/Shared/Transfer/CurrencyTransfer
ShipmentGroupTransfer class Created src/Generated/Shared/Transfer/ShipmentGroupTransfer
ShipmentTransfer class Created src/Generated/Shared/Transfer/ShipmentTransfer`
ShipmentMethodsCollectionTransfer class Created src/Generated/Shared/Transfer/ShipmentMethodsCollectionTransfer

3) Set up behavior

Register the following plugins:

PLUGIN SPECIFICATION PREREQUISITES
CartShipmentCartOperationPostSavePlugin Recalculates the shipment expenses. Replacement for CartShipmentExpanderPlugin
SanitizeCartShipmentItemExpanderPlugin Clears quote shipping data if a user modified quote items. None

Pyz\Zed\Cart\CartDependencyProvider

<?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(),
        ];
    }
}
Verification

Make sure that if you change items in the cart (add, remove or change quantity) then all the shipping methods are sanitized.