2

I have Drupal 7, without Drupal Commerce modules installed, because we are nor e-commerce place. For some items, we need to show up two prices (old_price and new_price). Only for items for new_price filled I need to show up old_price line-trough or with an X on top. I suppose that I need to put some code in someplace, but where?

I have been looking for a module, but all modules are for commerce. I do not want to install commerce and all the pile of commerce modules just to add this feature.

2 Answers 2

1

First, create two fields-"Old price" and "new price". Second, use css text-decoration:line-through; on the old price field.

Edit:

Based on your comment and clarification, I would suggest using rules and rules bonus pack to look for the "new price field", then have it add a body class to the node.

Your rule will look something like

  • Event #1: "when content is created"
  • Event #2: "when content is updated"
  • Condition #1: "entity has field", then select your "new price" field
  • Condition #2: "Data value is empty" and enable "negate"
  • Action: "Add body class"

Then in your css add the strikethough based on the extra body class.

This is essentially how the Commerce price savings formatter module works, but without the overhead of using commerce.

23
  • yes I know ...I did it, But I need old-price line-through only if we have new price. Aug 14, 2013 at 21:46
  • It works, except the line-through, the color works but not the line, .field-name-field-price{ text-decoration: line-through; color: red; } weird... any ideas? Aug 15, 2013 at 22:01
  • I would have a link to see the site to determine it. Aug 15, 2013 at 22:46
  • well is modernism.com, but I am working on a test site.. not real site.. but if you go to modernism.com we would like this action at item price... just click on an item with price.. Aug 15, 2013 at 23:04
  • this is a good example... but the rule is not in production.. modernism.com/items/39/chandeliers/… Aug 15, 2013 at 23:07
0

Or you could use the module that does this formatting for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.