Need To Shorten Conditional

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • greggc
    Mivite


    • Mar 2006
    • 296

    #1

    Need To Shorten Conditional

    I have the following conditional to hide loyalty points from displaying on the product page. I need to add additional products to this. Can someone advise as how to possibly shorten this? Appreciate the help.

    <mvt:if expr="(l.settings:product:code NE 'e-gift-cert' AND l.settings:product:code NE 'gift-cert' AND l.settings:product:code NE 'HKW-1' AND l.settings:product:code NE '662434-83' AND l.settings:product:code NE 'O17-1')"></mvt>
  • Kent Multer
    Mega Mivite









    • Mar 2006
    • 3251

    #2
    This is a bit convoluted, but it's what I do in that situation:
    Code:
    <mvt:if expr="NOT ( (',' $ l.settings:product:code $ ',') CIN (',e-gift-cert,gift-cert,HKW-1,662434-83,O17-1,AnotherCode,OneMoreCode,YetAnotherCode,EtcEtc,') )">
    The extra commas are needed so that it won't accidentally detect a short code that happens to be a substring of a larger one in the list. Note that there are commas at the beginning and end of both strings.
    Kent Multer
    Magic Metal Productions
    http://TheMagicM.com
    * Web developer/designer
    * E-commerce and Miva
    * Author, The Official Miva Web Scripting Book -- available on-line:
    http://www.amazon.com/exec/obidos/IS...icmetalproducA

    Comment

    • greggc
      Mivite


      • Mar 2006
      • 296

      #3
      Thanks Kent.

      Comment

      • Bruce - PhosphorMedia
        Developer Partner











        • Mar 2006
        • 11256

        #4
        Yes, this is how it always should be done. If this is something an Admin may want to update, we'd typically write it like this:

        Code:
        <mvt:assign name="g.dont_show_points" value="'this_code, that_code, another_code'" />
        
        <mvt:if expr="NOT(', ' $ l.settings:product:code CIN g.dont_show_points)">
        points
        </mvt:if>
        this, in our experiance, makes Admin entry less prone to breaking things. At most, you get a false 'positive' in stead of breaking the conditional altogether.
        Bruce Golub
        Phosphor Media - "Your Success is our Business"

        Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
        phosphormedia.com

        Comment

        • lesliekirk
          Super Moderator











          • Aug 2008
          • 9290

          #5
          Originally posted by greggc View Post
          I have the following conditional to hide loyalty points from displaying on the product page.
          Question(s) - is this Miva's Points & Loyalty module? If so, would you mind sharing how you get the loyalty points to display on the product page? Thanks!
          Leslie Kirk
          Miva Certified Developer
          Miva Merchant Specialist since 1997
          Previously of Webs Your Way
          (aka Leslie Nord leslienord)

          Email me: [email protected]
          www.lesliekirk.com

          Follow me: X | Facebook | Pinterest

          Comment

          • lesliekirk
            Super Moderator











            • Aug 2008
            • 9290

            #6
            Originally posted by lesliekirk View Post

            Question(s) - is this Miva's Points & Loyalty module? If so, would you mind sharing how you get the loyalty points to display on the product page? Thanks!
            Follow-up - I used this:
            Code:
             <mvt:item name="points" param="Product_Points( l.settings:basket, l.settings:product, 0, 0, 1, l.settings:product:points_information )" />
            
            
            &mvt:product:points_information:base_points_total; <br>
            &mvt:product:points_information:base_points;
            What is the difference between base_points_total and base_points?
            Leslie Kirk
            Miva Certified Developer
            Miva Merchant Specialist since 1997
            Previously of Webs Your Way
            (aka Leslie Nord leslienord)

            Email me: [email protected]
            www.lesliekirk.com

            Follow me: X | Facebook | Pinterest

            Comment

            Working...
            X