Announcement

Collapse
No announcement yet.

Tokens, foreach loop for products ordered on INVC

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

    Tokens, foreach loop for products ordered on INVC

    I've got a script to track conversions from my Pinterest ads. I don't know how to make is show each item that was ordered. Here's the code:
    Code:
       <mvt:foreach iterator="products" array="order:items">
         {
           product_name: '&mvt:item:name;',
           product_id: '&mvt:item:code;',
           product_price: &mvt:item:price;,
           product_quantity: &mvt:item:quantity;
         },
        </mvt:foreach>
    I added three different items to my cart for a test order, but when I reached INVC and inspected the code, it shows the same item listed three times. What do I need to change?

    Thanks for any help with this.
    Doug
    Using Miva Merchant since 2004
    StoreSMART.com

    #2
    Probably because this is located in the wrong place. There is already a foreach loop of products. So, within that loop, do something like:

    Code:
    <mvt:assign name="g.pintProducts" value="g.pintProducts $ 
    '{ product_name: \'' $l.settings:item:name$ '\',  
    'product_id: \'' $l.settings:item:code$ '\', 
    'product_price: \'' $l.settings:item:price$ '\', 
    'product_quantity: \'' $l.settings:item:quantity$ '\},'" />
    You need to get the total item count, set an independant count for your loop to control when you need to NOT add the }, at the end of the loop.

    Also, in your example, you labelled the iterator as "products" but are evauling another array's interator ("item") which is why you get the results you see.




    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


      #3
      Thank you for your reply. Everything works properly after I changed to iterator="item". Is there a way to call the product category?
      Doug
      Using Miva Merchant since 2004
      StoreSMART.com

      Comment


        #4
        Code:
        <mvt:do name="l.result" file="g.Module_Library_DB" value="CategoryList_Load_Offset_Product_Assigned(l.settings:product:id,0,'','',0,l.null, g.assigned_categories )" />
        
        <mvt:foreach iterator="category" array="global:assigned_categories">
        
        
                        &mvt:category:active;<br>
                       &mvt:category:code;<br>
                        &mvt:category:id;<br>
                        &mvt:category:name;<br>
        
        </mvt:foreach>
        Note. products can be assigned to multiple categories.
        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

        Working...
        X