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

Skip to content

Commit bcd612c

Browse files
committed
[UI][Catalog Promotion] show original price on cart item
1 parent 0c96399 commit bcd612c

6 files changed

Lines changed: 43 additions & 13 deletions

File tree

features/cart/shopping_cart/adding_product_with_discounted_catalog_price_to_cart.feature

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ Feature: Adding a simple product with discounted catalog price to the cart
1010
And the store has a product "T-Shirt" priced at "$20"
1111
And there is a catalog promotion "Winter sale" that reduces price by "25%" and applies on "T-Shirt" variant
1212

13-
@todo
13+
@ui
1414
Scenario: Adding a simple product with discounted catalog price to the cart
1515
When I add product "T-Shirt" to the cart
1616
And I add product "Mug" to the cart
1717
Then I should be on my cart summary page
1818
And I should be notified that the product has been successfully added
1919
And I should see "T-Shirt" with unit price "$15.00" in my cart
2020
And I should see "T-Shirt" with original price "$20.00" in my cart
21-
And I should see also "Mug" with unit price "$40.00" in my cart
22-
And I should see "Mug" with original price "$40.00" in my cart
21+
And I should see "Mug" only with unit price "$40.00" in my cart

features/cart/shopping_cart/adding_product_with_variants_with_discounted_catalog_price_to_cart.feature

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,18 @@ Feature: Adding a product with selected variant with discounted catalog price to
66

77
Background:
88
Given the store operates on a single channel in "United States"
9-
And the store has a product "T-Shirt"
9+
And the store has a "T-Shirt" configurable product
1010
And this product has "PHP T-Shirt" variant priced at "$20"
11-
And the store has a product "Keyboard"
11+
And this product has "Kotlin T-Shirt" variant priced at "$400"
12+
And the store has a "Keyboard" configurable product
1213
And this product has "RGB Keyboard" variant priced at "$40"
14+
And this product has "Pink Keyboard" variant priced at "$300"
1315
And there is a catalog promotion "Winter sale" that reduces price by "25%" and applies on "PHP T-Shirt" variant
1416

15-
@todo
17+
@ui
1618
Scenario: Adding multiple product variants with discounted price by catalog promotion catalog to the cart
17-
Given I add product "PHP T-Shirt" to the cart
18-
And I add product "RGB Keyboard" to the cart
19+
Given I add "PHP T-Shirt" variant of product "T-Shirt" to the cart
20+
And I add "RGB Keyboard" variant of product "Keyboard" to the cart
1921
When I check details of my cart
20-
Then I should see "PHP T-Shirt" with unit price "$15.00" in my cart
21-
And I should see "RGB Keyboard" with unit price "$40.00" in my cart
22+
Then I should see "T-Shirt" with unit price "$15.00" in my cart
23+
And I should see "Keyboard" with unit price "$40.00" in my cart

src/Sylius/Behat/Context/Ui/Shop/CartContext.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ public function __construct(
5252

5353
/**
5454
* @When /^I see the summary of my (?:|previous )cart$/
55+
* @When /^I check details of my cart$/
5556
*/
56-
public function iOpenCartSummaryPage()
57+
public function iOpenCartSummaryPage(): void
5758
{
5859
$this->summaryPage->open();
5960
}
@@ -408,13 +409,30 @@ public function iShouldSeeWithQuantityInMyCart($productName, $quantity)
408409
}
409410

410411
/**
411-
* @Then /^I should see "([^"]+)" with unit price ("[^"]+") in my cart$/
412+
* @Then /^I should see(?:| also) "([^"]+)" with unit price ("[^"]+") in my cart$/
412413
*/
413-
public function iShouldSeeProductWithUnitPriceInMyCart($productName, $unitPrice)
414+
public function iShouldSeeProductWithUnitPriceInMyCart($productName, $unitPrice): void
414415
{
415416
Assert::same($this->summaryPage->getItemUnitPrice($productName), $unitPrice);
416417
}
417418

419+
/**
420+
* @Then /^I should see "([^"]+)" with original price ("[^"]+") in my cart$/
421+
*/
422+
public function iShouldSeeWithOriginalPriceInMyCart(string $productName, int $originalPrice): void
423+
{
424+
Assert::same($this->summaryPage->getItemUnitRegularPrice($productName), $originalPrice);
425+
}
426+
427+
/**
428+
* @Then /^I should see "([^"]+)" only with unit price ("[^"]+") in my cart$/
429+
*/
430+
public function iShouldSeeOnlyWithUnitPriceInMyCart(string $productName, int $unitPrice): void
431+
{
432+
$this->iShouldSeeProductWithUnitPriceInMyCart($productName, $unitPrice);
433+
Assert::false($this->summaryPage->hasOriginalPrice($productName));
434+
}
435+
418436
/**
419437
* @Given I use coupon with code :couponCode
420438
*/

src/Sylius/Behat/Page/Shop/Cart/SummaryPage.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ public function getItemUnitPrice(string $productName): int
110110
return $this->getPriceFromString(trim($unitPrice->getText()));
111111
}
112112

113+
public function hasOriginalPrice(string $productName): bool
114+
{
115+
return $this->hasElement('product_unit_regular_price', ['%name%' => $productName]);
116+
}
117+
113118
public function getItemImage(int $itemNumber): string
114119
{
115120
$itemImage = $this->getElement('item_image', ['%number%' => $itemNumber]);

src/Sylius/Behat/Page/Shop/Cart/SummaryPageInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public function getItemUnitRegularPrice(string $productName): int;
4141

4242
public function getItemUnitPrice(string $productName): int;
4343

44+
public function hasOriginalPrice(string $productName): bool;
45+
4446
public function getItemImage(int $itemNumber): string;
4547

4648
public function isItemDiscounted(string $productName): bool;

src/Sylius/Bundle/ShopBundle/Resources/views/Cart/Summary/_item.html.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
{% import "@SyliusShop/Common/Macro/money.html.twig" as money %}
22

33
{% set product_variant = item.variant %}
4+
{% set pricing_for_active_channel = product_variant.getChannelPricingForChannel(cart.channel) %}
45

56
<tr {{ sylius_test_html_attribute('cart-product-row', item.productName) }}>
67
<td class="single line" {{ sylius_test_html_attribute('cart-item', loop_index|default(null) ) }}>
78
{% include '@SyliusShop/Product/_info.html.twig' with {'variant': product_variant} %}
89
</td>
910
<td class="right aligned">
11+
{% if pricing_for_active_channel.originalPrice is not null %}
12+
<span class="old-price">{{ money.convertAndFormat(pricing_for_active_channel.originalPrice) }}</span>
13+
{% endif %}
1014
{% if item.unitPrice != item.discountedUnitPrice %}
1115
<span class="sylius-regular-unit-price" {{ sylius_test_html_attribute('cart-product-regular-unit-price') }}>
1216
<span class="old-price">{{ money.convertAndFormat(item.unitPrice) }}</span>

0 commit comments

Comments
 (0)