Skip to content

Commit a63960d

Browse files
committed
Fixed Discounts example
1 parent 22955b1 commit a63960d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

code_samples/discounts/src/Command/ManageDiscountsCommand.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5959

6060
$discountCodeCreateStruct = new DiscountCodeCreateStruct(
6161
'summer10',
62+
10, // Global usage limit
6263
null, // Unlimited usage
6364
$this->permissionResolver->getCurrentUserReference()->getUserId(),
6465
$now
@@ -78,8 +79,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7879
new IsInRegions(['germany', 'france']),
7980
new IsProductInArray(['product-1', 'product-2']),
8081
new IsInCurrency('EUR'),
81-
new IsValidDiscountCode($discountCode->getCode(), $discountCode->getUsedLimit()),
82-
])
82+
new IsValidDiscountCode(
83+
$discountCode->getCode(),
84+
$discountCode->getGlobalLimit(),
85+
$discountCode->getUsedLimit()
86+
), ])
8387
->setTranslations([
8488
new DiscountTranslationStruct('eng-GB', 'Discount name', 'This is a discount description', 'Promotion Label', 'Promotion Description'),
8589
new DiscountTranslationStruct('ger-DE', 'Discount name (German)', 'Description (German)', 'Promotion Label (German)', 'Promotion Description (German)'),

0 commit comments

Comments
 (0)