Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Product] Add a crossed price #3373

Closed
wants to merge 5 commits into from

Conversation

TristanPerchec
Copy link

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass?
Fixed tickets
License MIT
Doc PR

Added a crossed price attribute on every variant.

It works as amazon system price :

  • the crossed one is overpriced
  • the real one is normal
  • Add Field in DB
  • Add Backend display and fonctions
  • Add Frontend display and fonctions
  • Add Behat test
  • Add Phpspec test

This development was sponsorised by Store Factory

@peteward
Copy link

peteward commented Oct 1, 2015

Does 'crossed price' mean 'original price'? The naming feels a bit confusing

@TristanPerchec
Copy link
Author

It means "overpriced" as amazon, banggood and others brands do. It's commonly used to convince customers it's a good deal. Sorry for the confusion I edited the description.

@jimbocoder
Copy link
Contributor

I think the most common term, at least in my experience, is MSRP.

@pjedrzejewski
Copy link
Member

Nice work Tristan! I'd like to hear more opinions about the naming. :)

@@ -2,6 +2,9 @@
<a href="{{ path(product) }}"><h4>{{ product.name|truncate(18) }}</h4></a>
<a href="{{ path(product) }}">
<img class="img-rounded img-responsive" src="{{ product.image ? product.image.path|imagine_filter('sylius_medium') : 'http://placehold.it/262x255' }}" alt="{{ product.name }}" />
{% if (product.masterVariant.crossedprice != 0) %}
Copy link

Choose a reason for hiding this comment

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

I think the check here should be if crossedPrice > price, also I think this could be done in a macro as it's like you would want to display the price in this way in lots of places

Copy link

Choose a reason for hiding this comment

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

I would put it inside the main span so that it could be used as a macro something like:

<span class="label label-primary">
    {{ sylius_customer_product_price(variant) }}
</span>

Again not sure about naming, could be formatted_product_price()?
Then your markup might look something like:

<span class="label label-primary">
    <span class="product-price"><span class="crossed">€40<span>€25</span>
</span>

Then you have something reusable and don't have to repeat the formatting that you've got below - do it once in the macro.

@peteward
Copy link

peteward commented Oct 3, 2015

We have done something similar very similar in our project. We take this further with multiple PriceLists per product per channel. In this structure we have originalPrice and retailPrice. We have a very long discussion about names and we felt this was the best description.

From a native English-speakers perspective, 'crossed price' isn't a known term. I actually like it because it's not committing to anything specific, it's just describing that it's the crossed-out price on the page, but still not really known and obvious.

msrp isn't clear enough to read and manufacturers_suggested_retail_price is too long and too specific. Also rrp (recommended retal price) is another more common term that I'm aware of as well as list price. But what if you are the manufacturer in your application? It doesn't really make sense in every application.

So my vote would go for originalPrice over anything else.

@aramalipoor
Copy link
Contributor

+1 for originalPrice

@peteward
Copy link

peteward commented Oct 3, 2015

I would also look at logic on the ProductVariant such as isReduced() isDiscounted() or isMarkedDown() to handle the logic. This could also go into an Interface, although I'm not sure it necessarily belongs in the PriceableInterface...

@TristanPerchec
Copy link
Author

Tank you all for your feedbacks. I updated my work and now crossed_price has been replaced by original_price as suggested.

@@ -88,6 +88,7 @@ sylius:
images: Images
on_hand: Stock actuel
price: Prix
original_price: Prix original
Copy link
Contributor

Choose a reason for hiding this comment

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

We should modify only en translations and then the translation process is handled on Crowdin (http://translate.sylius.org)

@TristanPerchec TristanPerchec force-pushed the feature/SF-186 branch 4 times, most recently from b3e2ed4 to 98340e2 Compare October 7, 2015 13:32
@TristanPerchec
Copy link
Author

@peteward @jimbocoder @pjedrzejewski @aramalipoor @michalmarcinkowski Do you see anything to edit or improve ?

@TristanPerchec TristanPerchec changed the title [WIP] [Product] Add a crossed price [Product] Add a crossed price Oct 7, 2015
@@ -41,6 +41,7 @@ public function getFilters()
return array(
new \Twig_SimpleFilter('sylius_currency', array($this, 'convertAmount')),
new \Twig_SimpleFilter('sylius_price', array($this, 'convertAndFormatAmount')),
new \Twig_SimpleFilter('sylius_original_price', array($this, 'convertAndFormatAmount')),
Copy link

Choose a reason for hiding this comment

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

I would remove this and just use 'sylius_price' where you need to. I'm not sure that there's any point having 2 filters doing the same thing and it might even be misleading. I'm trying to think of a use-case for performing a different calculation on originalPrice compared to price and I can't think of one...

@pjedrzejewski
Copy link
Member

Looks good to me, ready for merge when rebase and we get a green light from Travis! 👍 Nice work @TristanPerchec!

@TristanPerchec
Copy link
Author

I saw there's just one test that is not passing in travis. I'm pretty new to behat and i don't know if this error is linked to my PR. Can someone help me with this ?

@pjedrzejewski
Copy link
Member

@TristanPerchec I quickly looked and not sure what's the problem, but our Travis scripts output failed scenarios to Termbin. You can have a look here - http://termbin.com/9158. Maybe it will give you some clue.

}

/**
* {@inheritdoc}
Copy link
Contributor

Choose a reason for hiding this comment

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

There's no inherited doc for recently added method, these methods should be added to ProductVariantInterface.

Copy link
Member

Choose a reason for hiding this comment

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

👍

@pamil
Copy link
Contributor

pamil commented Oct 20, 2015

@TristanPerchec it has something in common with channel-based pricing. If you take a look at

| Super T-Shirt | 19.99 | T-Shirts | channel_based | WEB-EU:15.99 |
, you will see that it returns "Super T-Shirt"'s regular price (€19.99) instead of that one returned by price calculator for WEB-EU channel which is €15.99.

Anyway, @Zales0123 it would be nicer and cleaner, if that assumption checked that "Super T-Shirt" has price "€15.99" instead of searching for "Super T-Shirt" and "€15.99" independently.

<div class="product-box">
<a href="{{ path(product) }}"><h4>{{ product.name|truncate(18) }}</h4></a>
<a href="{{ path(product) }}">
<img class="img-rounded img-responsive" src="{{ product.image ? product.image.path|imagine_filter('sylius_medium') : 'http://placehold.it/262x255' }}" alt="{{ product.name }}" />
<span class="label label-primary">{{ sylius_calculate_price(product.masterVariant)|sylius_price }}</span>
Copy link
Contributor

Choose a reason for hiding this comment

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

According to your error, you do not call sylius_calculate_price() in your macro. Moreover, current isReduced method in ProductVariant isn't aware of price calculator, so those channel differences are not processed (and it may introduce some errors if for some channel price is higher than regular price).

@pjedrzejewski pjedrzejewski added this to the v0.16.0 milestone Oct 20, 2015
@Zales0123
Copy link
Member

@pamil Sure, you're right! 👍 I will fix in the nearest future (at least I hope so ;)).

@nakashu
Copy link
Contributor

nakashu commented Nov 25, 2015

@TristanPerchec any update on this ?

@TristanPerchec
Copy link
Author

@nakashu Sorry got a lot of work lately. Maybe I will be able to work on it in the future but I can't right now.

@pjedrzejewski
Copy link
Member

@TristanPerchec No worries, thanks for letting us know. Anyone willing to pick up this PR? :)

@michalmarcinkowski
Copy link
Contributor

Related issue #1812

@pjedrzejewski pjedrzejewski removed this from the v0.16.0 milestone Dec 14, 2015
@kwedrowicz
Copy link

@pjedrzejewski I can pick up this PR if you want. I need this feature in a project at work so I have to write it anyways. Just tell me if I should work on core or extending model only for my own usages.

@pjedrzejewski
Copy link
Member

@starspire Sounds great, please open a new PR on top of this branch. 👍 Thanks!

@peteward
Copy link

This one can be closed, well done @TristanPerchec on your foundation work here.

@TristanPerchec
Copy link
Author

Well thanks to all of you for helping me on the work I did.

@pjedrzejewski
Copy link
Member

Yes, thank you Tristan a lot! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants