No announcement yet.

Conditional CSS

  • Filter
  • Time
  • Show
Clear All
new posts

  • Conditional CSS

    I am listing a price under a product along with a sale price next to it (span). The sale price is setup as a conditional where it is not displayed if nothing is entered in the field on the backend.

    What I'm attempting to accomplish is... For example, the product price will be displayed as a black color when the "sale" price is NOT listed, but displayed as a grey color with strike through decoration when the "sale" price IS listed.

    I'm guessing there will be some sort of conditional CSS, but how can this be accomplished with what code?

    Thanks for your help!!!
    Last edited by osalcedo; 09-24-2015, 06:04 PM.

  • #2
    Sorry to say but I don´t really see how this is related to Dynamik? I guess you´re using a plugin to do this (custom fields / Woo)? Might not be the right forum for this question maybe....
    Hard to answer anyway as we don´t see it - can´t test it - don´t have enough info - don´t know your PHP - don´t know your setup.

    Unfortunately there is no such thing as conditional CSS.
    But there is some conditional PHP. I would guess if/else. Thought: Maybe it´s possible to add a custom class/HTML to the price element WHEN it is displayed. That way you could use CSS with/without custom class to achieve a difference.


    • #3
      As SiGa said we can only guess without URL.

      If you are using WooCommerce, likely a class is added to the body or product when the item is on sale. Using that element you can style other elements within that class anyway CSS will allow.


      • #4
        You can put css in a hook box.


        • #5
          Hey guys, thanks for your input. I decided to go a different route after all.


          • Sogwap
            Sogwap commented
            Editing a comment
            May I ask what route you chose?

            As for your original request another route could have been to add a Dynamik Label (with a conditional) to the product. Then use Dynamik Hookbox/CSS to style any number of elements.

          • osalcedo
            osalcedo commented
            Editing a comment
            I decided to just label the two prices rather than playing with the CSS.
            This will be something I intend to tackle another day... Not a high priority at the moment.

            Sale Price