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

Skip to content

[Shop][Product] Display product original price on product page (no bc break)#11423

Merged
lchrusciel merged 9 commits into
Sylius:masterfrom
FlashPanther:feat/product-original-price
May 14, 2020
Merged

[Shop][Product] Display product original price on product page (no bc break)#11423
lchrusciel merged 9 commits into
Sylius:masterfrom
FlashPanther:feat/product-original-price

Conversation

@FlashPanther
Copy link
Copy Markdown

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? yes
Related tickets fixes #8258
License MIT

Follows up pull request #11200 by @JulienLoison , fixing backward compatibility break

@FlashPanther FlashPanther requested a review from a team as a code owner May 5, 2020 13:43
@probot-autolabeler probot-autolabeler Bot added the Shop ShopBundle related issues and PRs. label May 5, 2020
@vvasiloi
Copy link
Copy Markdown
Contributor

vvasiloi commented May 5, 2020

I think there are ways of adding this feature without deprecating anything or adding any BC breaks.

  1. Use the current ProductVariantPriceCalculatorInterface for a new implementation which will return the original price.
  2. Introduce a new interface ProductVariantOriginalPriceCalculatorInterface and it's implementation.
  3. Introduce a new interface ProductVariantChannelPricingResolver which will return an instance of ChannelPricingInterface for a given product variant and channel.
    This can be used to complement 1st and/or 2nd option(s). It can be used directly in the view layer (through Twig extension), similar to sylius_resolve_variant.

I find the 3rd option more practical and flexible. An instance of ChannelPricingInterface can be easily used in the view layer for all kinds of calculations.

Also, there's ChannelPricingInterface::isPriceReduced which can be used for/instead of sylius_has_discount

P.S. I can help with the implementation this presents interest.

Comment thread src/Sylius/Component/Core/Provider/ProductVariantsPricesProvider.php Outdated
Comment thread src/Sylius/Component/Core/Promotion/Filter/PriceRangeFilter.php Outdated
Comment thread src/Sylius/Component/Core/OrderProcessing/OrderPricesRecalculator.php Outdated
@pamil
Copy link
Copy Markdown
Contributor

pamil commented May 6, 2020

@vvasiloi 2nd idea looks like a good solution! It'd not introduce any more new abstractions, so the complexity would stay almost the same.

@FlashPanther
Copy link
Copy Markdown
Author

Thanks for your feedback @vvasiloi , @pamil .

I followed @lchrusciel comment : here

Idea 1 : @JulienLoison proposed this in pull request #11200 , right ?
Idea 2 : Yes, but some code will be duplicated ...
Idea 3 : Maybe more complicated ... @vvasiloi "P.S. I can help with the implementation this presents interest." ( I appreciate !)

Which solution do I have to choose ?

(Sorry, first pull request in this project). 😄

@vvasiloi
Copy link
Copy Markdown
Contributor

vvasiloi commented May 6, 2020

Idea 1 : @JulienLoison proposed this in pull request #11200 , right ?

@FlashPanther No, there's a new method in the current interface, instead of a new interface.

@vvasiloi 2nd idea looks like a good solution! It'd not introduce any more new abstractions, so the complexity would stay almost the same.

@pamil It is actually a new abstraction, since it adds a new interface. Perhaps you were referring to the 1st, which reuses the current interface.

@patrickallaert
Copy link
Copy Markdown

Idea 1 : @JulienLoison proposed this in pull request #11200 , right ?

@FlashPanther No, there's a new method in the current interface, instead of a new interface.

Correct, but that was flagged as a BC Break, hence the new proposal of @FlashPanther which was based on the commit of @JulienLoison introduced in #11200.

@FlashPanther FlashPanther force-pushed the feat/product-original-price branch from 5498f7d to 44c3f6d Compare May 7, 2020 18:01
@FlashPanther FlashPanther requested a review from pamil May 7, 2020 20:18
Comment thread src/Sylius/Bundle/CoreBundle/Templating/Helper/PriceHelper.php Outdated
Comment thread src/Sylius/Bundle/CoreBundle/Templating/Helper/PriceHelper.php Outdated
Comment thread src/Sylius/Bundle/CoreBundle/Templating/Helper/PriceHelper.php
Comment thread src/Sylius/Component/Core/Calculator/ProductVariantPricesCalculatorInterface.php Outdated
@FlashPanther
Copy link
Copy Markdown
Author

Of course ... Psalm analysis triggers errors because of deprecated class ...
Am I wrong ? Do I have to change something ?

@FlashPanther FlashPanther requested a review from lchrusciel May 11, 2020 16:39
Copy link
Copy Markdown
Contributor

@lchrusciel lchrusciel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add an exception to psalm ruleset (see DeprecatedClass tag in psalm.xml

Comment thread src/Sylius/Component/Core/Calculator/ProductVariantPriceCalculatorInterface.php Outdated
@FlashPanther FlashPanther force-pushed the feat/product-original-price branch from 4866b5f to fd0ffb2 Compare May 12, 2020 20:26
@FlashPanther
Copy link
Copy Markdown
Author

@pamil : ok for you ? (requested for review)

@lchrusciel lchrusciel merged commit a06189f into Sylius:master May 14, 2020
@lchrusciel
Copy link
Copy Markdown
Contributor

lchrusciel commented May 14, 2020

Thanks, tdevos and Julien! 🎉

@lchrusciel
Copy link
Copy Markdown
Contributor

If anyone would like to improve this feature, even more, we could add original prices to our fixtures, so they will be visible on demo/testing installation just after fixtures reload ;)

@lchrusciel
Copy link
Copy Markdown
Contributor

There is an additional case, that I didn't spot during code review - the price is not updated when the variant is changed. It means also, that it will not work if the first variant doesn't have an original price (even if the previous problem was fixed). @FlashPanther would you like to give it a try to fix these cases?

lchrusciel added a commit that referenced this pull request May 26, 2020
…oduct page (JulienLoison)

This PR was merged into the 1.8-dev branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | master
| Bug fix?        | yes
| New feature?    | yes
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | -
| License         | MIT

Follows up @lchrusciel's comment on #11423 about variant prices not updating on the product page or variant not displaying discount if the first variant of the product has no discount. 

Commits
-------

8bddc52 [UI] added display of product variant original price on product page
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Shop ShopBundle related issues and PRs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Original price not displayed in product listing

6 participants