Announcement

Collapse
No announcement yet.

Show content when Product Custom Field is checked

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Show content when Product Custom Field is checked

    I added a product custom field called ShowTermsOfUse and want to show a block of text for any products that have that checkbox enabled in the admin.

    I added this code and other variants to the PROD page but can't sort out the test condition. When I look at the Token List for the prod page for the test product http://www.allfrom1supply.com/chem-bake-step-2-xlt.html I don't see a variable for the value of the checkbox which I expected would be there as a '1' or 'yes'

    I'm sure it is a dumb mistake but I've been going in circles so appreciate your help.

    Code:
    <mvt:item name="customfields" param="Read_Product(l.settings:product:code,'ShowTermsOfUse') " />
    <mvt:if expr="l.settings:customfields:ShowTermsOfUse EQ 'yes'">
    <div class="terms-of-use-ec">
    <h2>Terms of Use</h2>
    <span class="terms-of-use-ec-body">This product is intended for use by knowledgeable and trained professionals. In order to purchase and/or use this product yourself, or purchase it on behalf of another entity, you must agree to read and educate yourself, and any intended users as to the technical specifications, material data safety, proper product and surface preparation, application requirements, suitability for intended usage and all other requirements that insure a successful result. Improper usage and failing to educate yourself in the aforementioned areas can result in product failure, damage to surfaces, personal injury and claims against you AND will void your warranty.</span>
    </div>    
    </mvt:if>

    #2
    Code:
    <mvt:item name="customfields" param="Read_Product_Code(l.settings:product:code,'ShowTermsOfUse', g.p_is_show_terms )" />
    <mvt:if expr="g.p_is_show_terms EQ 'yes'">
        <div class="terms-of-use-ec">
            <h2>Terms of Use</h2>
            <span class="terms-of-use-ec-body">This product is intended for use by knowledgeable and trained professionals. In order to purchase and/or use this product yourself, or purchase it on behalf of another entity, you must agree to read and educate yourself, and any intended users as to the technical specifications, material data safety, proper product and surface preparation, application requirements, suitability for intended usage and all other requirements that insure a successful result. Improper usage and failing to educate yourself in the aforementioned areas can result in product failure, damage to surfaces, personal injury and claims against you AND will void your warranty.
            </span>
        </div>
     </mvt:if>
    Make sure customfields item is assigned to the page and l.settings:product:code; has the actual product code in it.

    ...and ENJOY :-)

    Comment


      #3
      Thanks very much.

      Comment


        #4
        AHerb hmm... still having a confusing issue. If I use the Token List and view the test product after I set the custom field to show the text

        EC-CB2-1-XLT-AF1

        'g.p_is_show_terms' has no value so I can't get the conditional to work.

        Also 'l.settings:product_code' has a previous product I viewed stored in it

        EC-CB-8000-BC-1


        The only variables that show as having the product code of the product I'm look at are...

        l.settings:recently_viewed:product_codes[2] EC-CB2-1-XLT-AF1
        l.settings:recently_viewed:products[2]:code EC-CB2-1-XLT-AF1
        g.session:cache:customfld:basket:fields:recently_v iewed &mvt:global:session:cache:customfld:basket:fiel ds: recently_viewed;[1]=JAN-1000_DR-BRKT-CMRCL,[2]=EC-CB2-1-XLT-AF1,[3]=EC-CB-8000-BC-1


        I tried printing the Product code to the page by placing this in the PROD body

        &mvt:product_code;


        and get

        JAN-1000_DR-BRKT-CMRCL which is in the recently viewed list.

        I tried putting this in various places in the loop abnd out of it. Not sure what I'm doing wrong.

        Comment


          #5
          Hmm...okay the value in 'l.settings:attributemachine:product:code' does work - so using it unless there is some reason not to.

          Comment


            #6
            In the code example I gave you earlier try to change
            Code:
             
             <mvt:item name="customfields" param="Read_Product_Code(l.settings:product:code,'ShowTermsOfUse', g.p_is_show_terms )" />
            To actual code, that has a checkbox (for test purposes).

            Code:
            <mvt:item name="customfields" param="Read_Product_Code( 'EC-CB2-1-XLT-AF1' ,'ShowTermsOfUse', g.p_is_show_terms )" />
            if above works, that means that you just need to find variable that stores current product code.

            -------------


            in the TokenList try to look for "code"
            normally you may have ...product:code ...product_code or something similar

            Comment


              #7
              Oh, missed your last reply.
              If it works - all is ok :-)

              On your page you have the output: ITEM: EC-CB2-1-XLT-AF1
              You could just look for the token that is used to output it in the code

              Comment


                #8
                Thanks again. Works like a charm.

                Comment


                  #9
                  Originally posted by habreu View Post
                  Thanks again. Works like a charm.
                  If you're still following this topic, change
                  Code:
                   <mvt:if expr="g.p_is_show_terms EQ 'yes'">
                  to

                  Code:
                   <mvt:if expr="NOT ISNULL g.p_is_show_terms">
                  As of Miva 9.07 new and existing (but re-activated) checkboxes will return 1 instead of 'yes' when activated. Change above will match both.

                  Comment


                    #10
                    Thanks very much for the followup!

                    Comment

                    Working...
                    X