Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Greetings,
Both commerce_price and commerce_saleprice are displaying the same amount which is the data in the commerce_saleprice field. Can somebody help me troubleshoot this? Thanks!
Comments
Comment #1
AndyF CreditAttribution: AndyF commentedSorry it's tough to answer/understand the question as it stands. What have you done, what happened, what were you expecting to happen?
Comment #2
pyxio CreditAttribution: pyxio commentedHi
The commerce module by default has the commerce_price field. This module adds a new field commerce_saleprice. So for example, If I have a price $100 as the official retail price in the commerce_price field and I add a sale price of $50 into the commerce_saleprice field and then look at the node display, I see original price $50 and sale price $50. I was hoping to see price $100 with sale price $50 on the node display. I hope this makes more sense now. Cheers, Kevin
Comment #3
AndyF CreditAttribution: AndyF commentedYou'd like to see both prices on the product display (like with the full price crossed out and sale price after)?
Commerce doesn't use the value in the commerce_price field directly - it first uses the Rules system to trigger an event to determine the effective price, which is useful for things like discounts, taxes, etc. See this link for more details.
What my module does is integrate with that system, so that if the On sale field is set to true, then the base price is changed from what's in commerce_price to what's in commerce_sale_price. Note this has nothing to do with display. The commerce_sale_price field will normally be hidden, and you use an appropriately configured price formatter to display the price. If you Google drupal commerce price formatter you get some hits - this module should play nicely with any price formatter.
HTH
Comment #4
pyxio CreditAttribution: pyxio commentedThank you for the explanation. It is very clear to me now. So, in order to get both prices displayed would I need to use a preprocess function? Cheers, Kevin
Comment #5
AndyF CreditAttribution: AndyF commentedNo, nothing that complex, you just need a price formatter. Something like Commerce Price Savings Formatter.
Comment #6
pyxio CreditAttribution: pyxio commentedAbsolutely perfect. Thanks so much AndyF!!