Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 77a8e84

Browse files
committed
[Behat] Not applying catalog promotion on products after its taxon change if criteria does not met
append to taxon
1 parent 7c365c5 commit 77a8e84

2 files changed

Lines changed: 91 additions & 1 deletion

File tree

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
@applying_catalog_promotions
2+
Feature: Not reapplying catalog promotions on variants once the product’s taxon changes
3+
In order to have proper discounts in product catalog
4+
As a Store Owner
5+
I do not want to have discounts reapplied on variants once the product’s taxon changes if the catalog promotion criteria are not met
6+
7+
Background:
8+
Given the store operates on a channel named "Web-US" with hostname "web-us"
9+
And the store classifies its products as "Clothes", "Shirts" and "Dishes"
10+
And the store has a "T-Shirt" configurable product
11+
And this product belongs to "Clothes"
12+
And this product has "PHP T-Shirt" variant priced at "$100.00"
13+
And it is "2022-01-01" now
14+
And there is a catalog promotion "Winter sale" between "2021-12-20" and "2021-12-30" available in "Web-US" channel that reduces price by "30%" and applies on "Clothes" taxon
15+
And there is another catalog promotion "Spring sale" between "2022-04-01" and "2022-05-01" available in "Web-US" channel that reduces price by "25%" and applies on "Shirts" taxon
16+
And there is disabled catalog promotion "Surprise sale" between "2021-07-01" and "2022-05-04" available in "Web-US" channel that reduces price by "90%" and applies on "Dishes" taxon
17+
And I am logged in as an administrator
18+
19+
@ui
20+
Scenario: Changing products taxon to taxon with scheduled catalog promotion
21+
When I change that the "T-Shirt" product does not belong to the "Clothes" taxon
22+
And I change that the "T-Shirt" product belongs to the "Shirts" taxon
23+
Then the visitor should see that the "PHP T-Shirt" variant is not discounted
24+
And the visitor should still see "$100.00" as the price of the "T-Shirt" product in the "Web-US" channel
25+
26+
@ui
27+
Scenario: Changing products taxon to taxon with disabled catalog promotion
28+
When I change that the "T-Shirt" product does not belong to the "Clothes" taxon
29+
And I change that the "T-Shirt" product belongs to the "Dishes" taxon
30+
Then the visitor should see that the "PHP T-Shirt" variant is not discounted
31+
And the visitor should still see "$100.00" as the price of the "T-Shirt" product in the "Web-US" channel

src/Sylius/Behat/Context/Setup/CatalogPromotionContext.php

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,65 @@ public function thereIsAnotherCatalogPromotionAvailableInChannelsThatReducesPric
461461
$this->entityManager->flush();
462462
}
463463

464+
/**
465+
* @Given /^there is (?:a|another) catalog promotion "([^"]*)" between "([^"]+)" and "([^"]+)" available in ("[^"]+" channel) that reduces price by ("[^"]+") and applies on ("[^"]+" taxon)$/
466+
*/
467+
public function thereIsACatalogPromotionBetweenAvailableInChannelThatReducesPriceByAndAppliesOnTaxon(
468+
string $name,
469+
string $startDate,
470+
string $endDate,
471+
ChannelInterface $channel,
472+
float $discount,
473+
TaxonInterface $taxon
474+
): void {
475+
$this->createCatalogPromotion(
476+
name: $name,
477+
channels: [$channel->getCode()],
478+
scopes: [[
479+
'type' => ForTaxonsScopeVariantsProvider::TYPE,
480+
'configuration' => ['taxons' => [$taxon->getCode()]],
481+
]],
482+
actions: [[
483+
'type' => PercentageDiscountPriceCalculator::TYPE,
484+
'configuration' => ['amount' => $discount],
485+
]],
486+
startDate: new \DateTimeImmutable($startDate),
487+
endDate: new \DateTimeImmutable($endDate)
488+
);
489+
490+
$this->entityManager->flush();
491+
}
492+
493+
/**
494+
* @Given /^there is disabled catalog promotion "([^"]*)" between "([^"]+)" and "([^"]+)" available in ("[^"]+" channel) that reduces price by ("[^"]+") and applies on ("[^"]+" taxon)$/
495+
*/
496+
public function thereIsDisabledCatalogPromotionBetweenAvailableInChannelThatReducesPriceByAndAppliesOnTaxon(
497+
string $name,
498+
string $startDate,
499+
string $endDate,
500+
ChannelInterface $channel,
501+
float $discount,
502+
TaxonInterface $taxon
503+
): void {
504+
$this->createCatalogPromotion(
505+
name: $name,
506+
channels: [$channel->getCode()],
507+
scopes: [[
508+
'type' => ForTaxonsScopeVariantsProvider::TYPE,
509+
'configuration' => ['taxons' => [$taxon->getCode()]],
510+
]],
511+
actions: [[
512+
'type' => PercentageDiscountPriceCalculator::TYPE,
513+
'configuration' => ['amount' => $discount],
514+
]],
515+
startDate: new \DateTimeImmutable($startDate),
516+
endDate: new \DateTimeImmutable($endDate),
517+
enabled: false
518+
);
519+
520+
$this->entityManager->flush();
521+
}
522+
464523
/**
465524
* @Given /^there is(?: a| another) catalog promotion "([^"]*)" that reduces price by ("[^"]+") and applies on ("[^"]+" product)$/
466525
*/
@@ -636,7 +695,7 @@ public function theAdministratorMakesThisCatalogPromotionUnavailableInTheChannel
636695

637696
/**
638697
* @Given the catalog promotion :catalogPromotion operates between :startDate and :endDate
639-
* @Given /^(this catalog promotion) operates between ("[^"]+") and ("[^"]+")$/
698+
* @Given /^(this catalog promotion) operates between "([^"]+)" and "([^"]+)"$/
640699
*/
641700
public function theCatalogPromotionOperatesBetweenDates(
642701
CatalogPromotionInterface $catalogPromotion,

0 commit comments

Comments
 (0)