Announcement

Collapse
No announcement yet.

Check if PriceGroup is Assigned to Product

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

    Check if PriceGroup is Assigned to Product

    I'm wanting to use the code snippet (a modified version of this) on the CTGY page

    Code:
    <mvt:do file="g.Module_Feature_PGR_DB" name="l.ok" value="PriceGroup_Load_Name( 'Volume Pricing', l.price_group )" />
    <mvt:if expr="l.price_group:id GT 0">
    <mvt:do file="g.Module_Feature_PGR_DB" name="l.b" value="PriceGroupXProduct_Load( l.price_group:id , l.settings:product:id, l.settings:pricegroupvar )" />
    <mvt:if expr="NOT ISNULL l.settings:pricegroupvar">
    Assigned to this product<br />
    </mvt:if>
    </mvt:if>
    </mvt:if>
    The snippet works as expected on the PROD page, but on the CTGY it's displaying for every product. What have I goofed up this time?
    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
    It's possible that the pricegroupsvar array is already populated. When you add to an array it doesn't get rid of previous values, so you could put this right above the PriceGroupXProduct_Load line to clear entries that are already in it.

    Code:
    <mvt:assign name="l.settings:pricegroupvar" value="''" />
    OR, do you have it loading while it's in the mvt:while or mvt:foreach loop? That could load more values into it as well.

    OR, it's in a loop and you still need to reset the variable with the code above so it doesn't keep loading.

    I'm not 100% sure what you're doing there so basically these are the things I'd personally first look at.
    M.A.D.* since 1997

    http://www.scotsscripts.com

    *miva application developers

    Comment


      #3
      My typical blurb, not sure what the goal is.

      If you need to identify if each product in that category is assigned a pgrp, you need a loop, like Foreach to grab the status of each product ID in the category product listing. I don't think speed will be an issue, but the loop already exists for rendering each product.

      Scott
      Need to offer Shipping Insurance?
      Interactive Design Solutions https://www.myids.net
      MivaMerchant Business Partner | Certified MivaMerchant Web Developer
      Competitive Rates, Custom Modules and Integrations, Store Integration
      AutoBaskets|Advanced Waitlist Integration|Ask about Shipping Insurance Integration
      My T-shirt Collection is mostly MivaCon T-shirts!!

      Comment


        #4
        Originally posted by ids View Post
        My typical blurb, not sure what the goal is.


        Scott
        The goal is to display an icon on the category page that indicates there is Volume Pricing for the product if the customer is assigned to that price group.



        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


          #5
          Try this:
          Code:
          <mvt:do file="g.Module_Feature_PGR_DB" name="l.ok" value="PriceGroup_Load_Name( 'Volume Pricing', l.price_group )" />
          <mvt:if expr="l.price_group:id GT 0">
               <mvt:do file="g.Module_Feature_PGR_DB" name="l.b" value="PriceGroupXProduct_Load( l.price_group:id , l.settings:product:id, l.settings:pricegroupvar )" />
               <mvt:if expr="NOT ISNULL l.settings:pricegroupvar">
                    Assigned to this product<br />
               </mvt:if>
          
          </mvt:if>
          <mvt:assign name="l.settings:pricegroupvar" value="''"/>
          Also, I'd consider putting the

          <mvt:do file="g.Module_Feature_PGR_DB" name="l.ok" value="PriceGroup_Load_Name( 'Volume Pricing', l.price_group )" />

          function globally and change l.price_group to a global (i.e., g.price_group_name) so you don't need to keep calling it inside loops. Probably not the end of the world, but certainly not good coding practice.

          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


            #6
            Thanks, Bruce - PhosphorMedia - that got me in the direction I needed to go!
            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

            Working...
            X