Install the Promotions & Discounts + Product labels feature
Edit on GitHubThis document describes how to install the Product Labels + Promotions & Discounts feature.
Install feature core
Follow the steps below to install the feature core.
Prerequisites
Install the required features:
NAME | VERSION | INSTALLATION GUIDE |
---|---|---|
Promotions & Discounts | 202404.0 | Install the Promotions & Discounts feature |
Product Labels | 202404.0 | Install the Discontinued Products feature |
Spryker Core | 202404.0 | Install the Spryker Core feature |
1) Set up behavior
Set up the following behaviors:
PLUGIN | SPECIFICATION | PREREQUISITES | NAMESPACE |
---|---|---|---|
ProductLabelDiscountableItemCollectorPlugin | Collects the cart items with product labels to which a discount should be applied. | None | Spryker\Zed\ProductLabelDiscountConnector\Communication\Plugin\Collector |
ProductLabelListDecisionRulePlugin | Defines if a discount can be applied to a cart item with a product label. | None | Spryker\Zed\ProductLabelDiscountConnector\Communication\Plugin\DecisionRule |
src/Pyz/Zed/Discount/DiscountDependencyProvider.php
<?php
namespace Pyz\Zed\Discount;
use Spryker\Zed\Discount\DiscountDependencyProvider as SprykerDiscountDependencyProvider;
use Spryker\Zed\ProductLabelDiscountConnector\Communication\Plugin\DecisionRule\ProductLabelListDecisionRulePlugin;
use Spryker\Zed\ProductLabelDiscountConnector\Communication\Plugin\Collector\ProductLabelDiscountableItemCollectorPlugin;
class DiscountDependencyProvider extends SprykerDiscountDependencyProvider
{
/**
* @return \Spryker\Zed\Discount\Dependency\Plugin\DecisionRulePluginInterface[]
*/
protected function getDecisionRulePlugins()
{
return array_merge(parent::getDecisionRulePlugins(), [
new ProductLabelListDecisionRulePlugin(),
]);
}
/**
* @return \Spryker\Zed\Discount\Dependency\Plugin\CollectorPluginInterface[]
*/
protected function getCollectorPlugins()
{
return array_merge(parent::getCollectorPlugins(), [
new ProductLabelDiscountableItemCollectorPlugin(),
]);
}
}
Verification
Ensure that the plugins work correctly:
- Create a discount and define its condition as a query string with a product-label field.
- Add a product with the defined product label to the cart.
- Verify that the discount is applied to the cart.
Thank you!
For submitting the form