Install the Marketplace Product Offer + Cart feature
Edit on GitHubThis document describes how to install the Marketplace Product Offer + Car feature.
Install feature core
Follow the steps below to install the Marketplace Product Offer + Cart feature core.
Prerequisites
Install the required features:
NAME | VERSION | INSTALLATION GUIDE |
---|---|---|
Marketplace Product Offer | 202311.0 | Install the Marketplace Product Offer feature |
Cart | 202311.0 | Install the Cart feature |
Set up behavior
Enable the following behaviors by registering the plugins:
PLUGIN | SPECIFICATION | PREREQUISITES | NAMESPACE |
---|---|---|---|
ProductOfferGroupKeyItemExpanderPlugin | Adds a product offer reference to group key that separates items in the cart. | Spryker\Zed\ProductOffer\Communication\Plugin\Cart | |
ProductOfferCartPreCheckPlugin | Checks if the product offer belongs to the concrete product before adding an item to cart. | Spryker\Zed\ProductOffer\Communication\Plugin\Cart | |
FilterInactiveProductOfferPreReloadItemsPlugin | Removes an inactive product offer from cart when reloading it. | Spryker\Zed\ProductOffer\Communication\Plugin\Cart |
src/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\ProductOffer\Communication\Plugin\Cart\FilterInactiveProductOfferPreReloadItemsPlugin;
use Spryker\Zed\ProductOffer\Communication\Plugin\Cart\ProductOfferCartPreCheckPlugin;
use Spryker\Zed\ProductOffer\Communication\Plugin\Cart\ProductOfferGroupKeyItemExpanderPlugin;
class CartDependencyProvider extends SprykerCartDependencyProvider
{
/**
* @param \Spryker\Zed\Kernel\Container $container
*
* @return array<\Spryker\Zed\CartExtension\Dependency\Plugin\ItemExpanderPluginInterface>
*/
protected function getExpanderPlugins(Container $container): array
{
return [
new ProductOfferGroupKeyItemExpanderPlugin(),
];
}
/**
* @param \Spryker\Zed\Kernel\Container $container
*
* @return array<\Spryker\Zed\CartExtension\Dependency\Plugin\CartPreCheckPluginInterface>
*/
protected function getCartPreCheckPlugins(Container $container): array
{
return [
new ProductOfferCartPreCheckPlugin(),
];
}
/**
* @param \Spryker\Zed\Kernel\Container $container
*
* @return array<\Spryker\Zed\CartExtension\Dependency\Plugin\PreReloadItemsPluginInterface>
*/
protected function getPreReloadPlugins(Container $container): array
{
return [
new FilterInactiveProductOfferPreReloadItemsPlugin(),
];
}
}
Make sure that inactive product offers get removed from cart on reload.
Make sure that it is only possible to have items in cart where the product offer reference belongs to the correct concrete product.
Install feature frontend
Follow the steps below to install the Marketplace Product Offer + Cart feature frontend.
Prerequisites
To start feature integration, overview, and install the necessary features:
NAME | VERSION | INSTALLATION GUIDE |
---|---|---|
Marketplace Product Offer | 202311.0 | Install the Marketplace Product Offer feature |
Cart | 202311.0 | Install the Cart feature |
Set up behavior
Enable the following behaviors by registering the plugins:
PLUGIN | DESCRIPTION | PREREQUISITES | NAMESPACE |
---|---|---|---|
MerchantProductOfferPreAddToCartPlugin | Sets the product offer reference to the item transfer | SprykerShop\Yves\MerchantProductOfferWidget\Plugin\CartPage |
src/Pyz/Yves/CartPage/CartPageDependencyProvider.php
<?php
namespace Pyz\Yves\CartPage;
use SprykerShop\Yves\CartPage\CartPageDependencyProvider as SprykerCartPageDependencyProvider;
use SprykerShop\Yves\MerchantProductOfferWidget\Plugin\CartPage\MerchantProductOfferPreAddToCartPlugin;
class CartPageDependencyProvider extends SprykerCartPageDependencyProvider
{
/**
* @return array<\SprykerShop\Yves\CartPageExtension\Dependency\Plugin\PreAddToCartPluginInterface>
*/
protected function getPreAddToCartPlugins(): array
{
return [
new MerchantProductOfferPreAddToCartPlugin(),
];
}
}
Make sure that the product offer reference (and sold by merchant) is added to the Cart page when adding a product offer to cart.
Install related features
FEATURE | REQUIRED FOR THE CURRENT FEATURE | INSTALLATION GUIDE |
---|---|---|
Marketplace Product Offer + Cart API | Install the Marketplace Product Offer + Cart Glue API |
Thank you!
For submitting the form