Install the Promotions & Discounts feature
Edit on GitHubThe following feature integration guide expects the basic feature to be in place. This document describes how to add the discount prioritization, HH:MM time definition in discount validity period, and voucher codes removal after the discount type switching functionality.
Install feature core
Follow the steps below to install the Promotions & Discounts feature core.
Prerequisites
Install the required features:
NAME | VERSION | INSTALLATION GUIDE |
---|---|---|
Spryker Core | 202507.0 | Install the Spryker Core feature |
1) Install the required modules
Install the required modules using Composer:
composer require spryker-feature/promotions-discounts 202507.0 --update-with-dependencies
Make sure that the following modules have been installed:
MODULE | EXPECTED DIRECTORY |
---|---|
Discount | vendor/spryker/discount |
2) Set up database schema and transfer objects
Apply database changes and generate entity and transfer changes:
console transfer:generate
console propel:install
Make sure that the following changes have been applied by checking your database:
DATABASE ENTITY | TYPE | EVENT |
---|---|---|
spy_discount.priority | column | added |
Make sure that the following changes have been triggered in transfer objects:
TRANSFER | TYPE | EVENT | PATH |
---|---|---|---|
DiscountConfiguratorResponse | class | created | src/Generated/Shared/Transfer/DiscountConfiguratorResponseTransfer |
DiscountAmountCriteria | class | created | src/Generated/Shared/Transfer/DiscountAmountCriteriaTransfer |
Discount.priority | property | created | src/Generated/Shared/Transfer/DiscountTransfer |
Discount.minimumItemAmount | property | created | src/Generated/Shared/Transfer/DiscountTransfer |
Discount.storeRelation | property | created | src/Generated/Shared/Transfer/DiscountTransfer |
CalculatedDiscount.priority | property | created | src/Generated/Shared/Transfer/CalculatedDiscountTransfer |
DiscountGeneral.priority | property | created | src/Generated/Shared/Transfer/DiscountGeneral |
Make sure that the discount form has the PRIORITY field, and the discounts table has the PRIORITY column.
Make sure, that the existing discounts in the spy_discount
DB table have priority set to 9999
.
3) Add translations
Generate a new translation cache for Zed:
console translator:generate-cache
Make sure that all labels and help tooltips in the discount form has English and German translation.
4) Set up behavior
Enable the following behaviors by registering the plugins:
PLUGIN | SPECIFICATION | PREREQUISITES | NAMESPACE |
---|---|---|---|
DeleteDiscountVoucherPoolDiscountPostUpdatePlugin | Deletes all vouchers from the voucher pool and the voucher pool itself after switching the discount type from voucher to another one. |
Spryker\Zed\Discount\Communication\Plugin\Discount |
src/Pyz/Zed/Discount/DiscountDependencyProvider.php
<?php
namespace Pyz\Zed\Discount;
use Spryker\Zed\Discount\Communication\Plugin\Discount\DeleteDiscountVoucherPoolDiscountPostUpdatePlugin;
use Spryker\Zed\Discount\DiscountDependencyProvider as SprykerDiscountDependencyProvider;
class DiscountDependencyProvider extends SprykerDiscountDependencyProvider
{
/**
* @return array<\Spryker\Zed\Discount\Dependency\Plugin\DiscountPostUpdatePluginInterface>
*/
protected function getDiscountPostUpdatePlugins(): array
{
return [
new DeleteDiscountVoucherPoolDiscountPostUpdatePlugin(),
];
}
}
- In the Back Office, go to Merchandising > Discount.
- Create a discount with the Voucher type.
- Generate several voucher codes for the created discount.
- Switch the discount type from Voucher to another type–for example, Cart rule. Make sure the voucher pool and voucher codes related to discount are deleted from
spy_discount_voucher_pool
and fromspy_discount_voucher
DB tables.
5) Build Zed UI frontend
Enable Javascript and CSS changes:
console frontend:project:install-dependencies
console frontend:zed:build
Make sure that discounts are calculated according to their priorities:
- Create a couple of percentage discounts with different priorities.
- To fulfill the discounts’ requirements, add items to the cart.
- Check that discounts are applied in the correct order and that the calculated discount total is correct.
Make sure that you can submit the Discount Create and Discount Update forms with specified date and time for Valid From and Valid To discount form fields:
- In the Back Office, go to Merchandising > Discount.
- Create a new discount or update an existing one and check that you can see the Discount form.
- To ensure you can see the calendar, click on Valid From and Valid To fields, where you can select a specific date and time.
- Make sure Valid From and Valid To fields can accept the selected date and time (for times not falling on the hour, use keystroke entry—for example, 13:45).
- In the
spy_discount
DB table, make sure Valid From and Valid To date and time are saved correctly.
Thank you!
For submitting the form