Announcement

Collapse
No announcement yet.

Recently Viewed Products - Part Deux

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

    Recently Viewed Products - Part Deux

    I've been working with implementing SteveoSoule Recently Viewed Products https://gist.github.com/steveosoule/...f614b9b2927741

    I would like to add the Product Flags custom field to the layout and an Add to Cart button. LOL, there are other things that would be great but how do I at least get the Product Flags Custom Field?

    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: Twitter | Facebook | FourSquare | Pinterest | Flickr

    #2
    You can read the custom field in the template loop (within <mvt:foreach iterator="recent_product" array="recently_viewed:products">).
    <mvt:item name="customfields" param="Read_Product_Code( l.settings:recent_product:code, 'yourcustomfieldcode', g.yourcustomfieldcode)" />
    &mvt:global:yourcustomfieldcode;

    <mvt:item name="customfields" param="Read_Product_Code( l.settings:recent_product:code, 'product-flag', g.productflag)" />
    &mvt:global:productflag;

    Hope this helps!
    -Ryan

    Comment


      #3
      Originally posted by RTHOMASDESIGN View Post
      You can read the custom field in the template loop (within <mvt:foreach iterator="recent_product" array="recently_viewed:products">).
      <mvt:item name="customfields" param="Read_Product_Code( l.settings:recent_product:code, 'yourcustomfieldcode', g.yourcustomfieldcode)" />
      &mvt:global:yourcustomfieldcode;

      <mvt:item name="customfields" param="Read_Product_Code( l.settings:recent_product:code, 'product-flag', g.productflag)" />
      &mvt:global:productflag;

      Hope this helps!
      -Ryan
      Thanks. I understand what you are showing me but now I am baffled as to why what I had tried works "halfway". The out_of_stock flag displays as needed


      Code:
      <mvt:if expr="l.settings:recent_product:customfield_values :customfields:product_flag NE 'none' AND l.settings:recent_product:inv_level NE 'out'">
      <mvt:assign name="l.settings:recent_product:flag" value="'flag-s--' $ tolower(l.settings:recent_product:customfield_values:customfields:product_flag)" />
      <mvt:else>
      <mvt:assign name="l.settings:recent_product:flag" value="'flag-s--out_of_stock'" />
      </mvt:if>
      
      <span class="flag-s &mvt:recent_product:flag;">
      <img class="x-product-list__image" src="&mvt:recent_product:src;" alt="&mvt:recent_product:name;">
      </span>
      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: Twitter | Facebook | FourSquare | Pinterest | Flickr

      Comment


        #4
        You've got a space after customfield_values. That said, if you check the token list in PROD, I doubt you'd find the custom field available (unless you read it). Something like this should work:

        <mvt:item name="customfields" param="Read_Product_Code( l.settings:recent_product:code, 'product_flag', g.productflag )" />
        <mvt:if expr="g.productflag NE 'none' AND l.settings:recent_product:inv_level NE 'out'">
        <mvt:assign name="l.settings:recent_product:flag" value="'flag-s--' $ tolower(g.productflag)" />
        <mvt:else>
        <mvt:assign name="l.settings:recent_product:flag" value="'flag-s--out_of_stock'" />
        </mvt:if>
        &mvt:recent_product:flag;
        <span class="flag-s &mvt:recent_product:flag;">
        <img class="x-product-list__image" src="&mvt:recent_product:src;" alt="&mvt:recent_product:name;">
        </span>

        This "<mvt:assign name="l.settings:recent_product:flag" value="'flag-s--out_of_stock'" />" would always work as the condition wasn't met.

        Comment


          #5
          Originally posted by RTHOMASDESIGN View Post
          You've got a space after customfield_values. That said, if you check the token list in PROD, I doubt you'd find the custom field available (unless you read it). Something like this should work:
          &lt;mvt:item name="customfields" param="Read_Product_Code( l.settings:recent_product:code, 'product_flag', g.productflag )" /&gt;
          &lt;mvt:if expr="g.productflag NE 'none' AND l.settings:recent_product:inv_level NE 'out'"&gt;
          &lt;mvt:assign name="l.settings:recent_product:flag" value="'flag-s--' $ tolower(g.productflag)" /&gt;
          &lt;mvt:else&gt;
          &lt;mvt:assign name="l.settings:recent_product:flag" value="'flag-s--out_of_stock'" /&gt;
          &lt;/mvt:if&gt;
          &amp;mvt:recent_product:flag;
          &lt;span class="flag-s &amp;mvt:recent_product:flag;"&gt;
          &lt;img class="x-product-list__image" src="&amp;mvt:recent_product:src;" alt="&amp;mvt:recent_product:name;"&gt;
          &lt;/span&gt;
          This "&lt;mvt:assign name="l.settings:recent_product:flag" value="'flag-s--out_of_stock'" /&gt;" would always work as the condition wasn't met.

          That space happened when I pasted it here. Thanks, once I removed the extra &mvt:recent_product:flag; it's what I was trying to achieve.
          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: Twitter | Facebook | FourSquare | Pinterest | Flickr

          Comment


            #6
            Glad you got it working! Should be pretty easy to add an "add to cart" button. :)

            Comment

            Working...
            X