Announcement

Collapse
No announcement yet.

Price Group Message

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

  • lesliekirk
    replied
    Originally posted by Kent Multer View Post
    This snippet mostly uses l.pricegroup (without underscore), but you have l.price_group (with underscore) in the last mvt:do.

    Also, as someone mentioned, if you're doing this in a loop to cover a group of products, such as on a category page, once it gets a single positive result, it will show positive for all the rest of the products. You don't have code in place to reset it for each product.
    Okay, that is making sense. I'm going to use another example that only displays products that have Volume Pricing. It works great to display only the products that have Volume Pricing BUT it shows the Volume Pricing "label" to everyone that is logged

    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">
    <span class="category-product-flag volume">VOLUME PRICING</span>
    </mvt:if>
    
    </mvt:if>
    <mvt:assign name="l.settings:pricegroupvar" value="''"/>
    The question is how do I get the products assigned to the Price Group to only display to customers assigned to that Price Group?

    Leave a comment:


  • Kent Multer
    replied
    This snippet mostly uses l.pricegroup (without underscore), but you have l.price_group (with underscore) in the last mvt:do.

    Also, as someone mentioned, if you're doing this in a loop to cover a group of products, such as on a category page, once it gets a single positive result, it will show positive for all the rest of the products. You don't have code in place to reset it for each product.

    Leave a comment:


  • lesliekirk
    replied
    After finally getting a somewhat good night's sleep (it's been a really rough week). I started playing around with what I think I'm trying to do. Of course, the latest attempt failed. I think I'll reach out to developer support. Once I get a working solution, I will share it.

    Here's my latest attempt ( I was thinking I first needed to make sure the customer is in the price group, then check for the products in the price group to display the message next to only each product in the price group)

    Code:
    <mvt:if expr="g.Basket:cust_id">
    <mvt:do name="l.result" file="g.Module_Feature_PGR_DB" value="PriceGroup_Load_Name( 'Barrys_Tea_10_1', l.pricegroup )" />
    <mvt:if expr="l.result">
    <mvt:do name="l.exists" file="g.Module_Feature_PGR_DB" value="PriceGroupXCustomer_Load( l.pricegroup:id, g.Basket:cust_id, l.null )" />
    <mvt:if expr="l.exists">
    <mvt:assign name="g.basket:customer:Barrys_Tea_10_1" value="1" />
    </mvt:if>
    </mvt:if>
    
    <mvt:if expr="g.basket:customer:Barrys_Tea_10_1">
    <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">
    <span class="category-product-flag volume">Barry's Deal</span>
    </mvt:if>
    
    
    </mvt:if>
    </mvt:if>
    I would love to learn what I am doing wrong. Thanks, Leslie

    Leave a comment:


  • lesliekirk
    replied
    Originally posted by Bruce - PhosphorMedia View Post
    place this:

    <mvt:assign name="l.result" value="''" />
    <mvt:assign name="l.exists" value="''" />

    after:

    <mvt:if expr="g.basket:customer:Barrys_Tea_10_1">
    yada yada
    </mvt:if>
    <mvt:assign name="g.basket:customer:Barrys_Tea_10_1" value="''" />

    and see if that doesnt' fix it.
    Color me extremely confused. I was thinking first you check to see if the customer is logged in, then you check to see if the customer is logged in to the Price Group "Barrys_Tea_10_1", then if he is, you determine which products are in "Barrys_Tea_10_1" then you can display the message for that customer only next to those products.

    Leave a comment:


  • Bruce - PhosphorMedia
    replied
    place this:

    <mvt:assign name="l.result" value="''" />
    <mvt:assign name="l.exists" value="''" />

    after:

    <mvt:if expr="g.basket:customer:Barrys_Tea_10_1">
    yada yada
    </mvt:if>
    <mvt:assign name="g.basket:customer:Barrys_Tea_10_1" value="''" />

    and see if that doesnt' fix it.

    Leave a comment:


  • lesliekirk
    replied
    Originally posted by Bruce - PhosphorMedia View Post
    the thinking here is, once "g.basket:customer:Barrys_Tea_10_1", is set to true, then all other products will still see g.basket:customer:Barrys_Tea_10_1 = true (i.e., 1).

    anytime you set a variable in a loop, you need to either positively reset it (i.e., use IF then ELSE) or null it after its use.

    for the same reason, if you haven't already, add:
    <mvt:assign name="l.result" value="''" />
    and
    <mvt:assign name="l.exists" value="''" />
    along with
    <mvt:assign name="g.basket:customer:Barrys_Tea_10_1" value="''" />
    ...and if I knew what that meant, I would not be asking for help....

    Leave a comment:


  • Bruce - PhosphorMedia
    replied
    the thinking here is, once "g.basket:customer:Barrys_Tea_10_1", is set to true, then all other products will still see g.basket:customer:Barrys_Tea_10_1 = true (i.e., 1).

    anytime you set a variable in a loop, you need to either positively reset it (i.e., use IF then ELSE) or null it after its use.

    for the same reason, if you haven't already, add:
    <mvt:assign name="l.result" value="''" />
    and
    <mvt:assign name="l.exists" value="''" />
    along with
    <mvt:assign name="g.basket:customer:Barrys_Tea_10_1" value="''" />
    Last edited by Bruce - PhosphorMedia; 06-06-25, 11:52 AM.

    Leave a comment:


  • lesliekirk
    replied
    This displays the "yada yada" on every product in the store to customers assigned to the "Barry" Price Group

    Code:
     <mvt:if expr="g.Basket:cust_id">
    <mvt:do name="l.result" file="g.Module_Feature_PGR_DB" value="PriceGroup_Load_Name( 'Barrys_Tea_10_1', l.pricegroup )" />
    <mvt:if expr="l.result">
    <mvt:do name="l.exists" file="g.Module_Feature_PGR_DB" value="PriceGroupXCustomer_Load( l.pricegroup:id, g.Basket:cust_id, l.null )" />
    <mvt:if expr="l.exists">
    <mvt:assign name="g.basket:customer:Barrys_Tea_10_1" value="1" />
    </mvt:if>
    </mvt:if>
    </mvt:if>
    <mvt:if expr="g.basket:customer:Barrys_Tea_10_1">
    
    yada yada
    </mvt:if>
    <mvt:assign name="g.basket:customer:Barrys_Tea_10_1" value="''" />
    How do I tell it to only show the message only on the products assigned to the "Barry" Price Group, only to the customers assigned to the "Barry" Price Group?

    Leave a comment:


  • lesliekirk
    replied
    Originally posted by Bruce - PhosphorMedia View Post
    Try adding:

    <mvt:assign name="g.basket:customer:Barrys_Tea_10_1" value="''" />

    After the closing </mvt:if>
    Will that only display the products that are assigned to the "Barry" Price Groups to these assigned customers?

    Leave a comment:


  • Bruce - PhosphorMedia
    replied
    Try adding:

    <mvt:assign name="g.basket:customer:Barrys_Tea_10_1" value="''" />

    After the closing </mvt:if>

    Leave a comment:


  • lesliekirk
    replied
    Originally posted by lesliekirk View Post

    I need to double-check something, because when I test the second code, it seems to be displaying the flag next to every product. I am now wondering if the store owner has misassigned products. Let me double check that and I will follow up here.

    As for how the code is written, they are samples directly from Miva's developer docs...
    Yeah, I'm not going that crazy (yet). There are only 10 products assigned to the Price Group. 168 customers, 0 Collections, 0 Categories. The first snippet does show the 10 products assigned to the "Barry" Price Group. If the customer is not assigned to the Barry price group (but is logged in), they can still see the "Barry" flag. Only the customers assigned to the "Barry" Price Group are supposed to see the "Barry" flag when they are logged in.

    If I use the second snippet as Bruce - PhosphorMedia suggested, it displays the "Barry" flag next to every product in the store as long as the customer is assigned to the "Barry" Price Group.

    ​​​​​​​Nope, we are not there yet.

    Leave a comment:


  • lesliekirk
    replied
    Originally posted by Bruce - PhosphorMedia View Post
    The second code snippet is the one you need as the first just checks to see whether the price group exists the second tests to see if custom is assigned.

    It shows for all products because you need to null out the test condition (l.exists and l.result) after each product call.

    (the difference in the return var result is just a stylistic one. personally i don't string words together any more--i.e., price_group verses pricegroup--Just easier to read.)
    I need to double-check something, because when I test the second code, it seems to be displaying the flag next to every product. I am now wondering if the store owner has misassigned products. Let me double check that and I will follow up here.

    As for how the code is written, they are samples directly from Miva's developer docs...

    Leave a comment:


  • Bruce - PhosphorMedia
    replied
    The second code snippet is the one you need as the first just checks to see whether the price group exists the second tests to see if custom is assigned.

    It shows for all products because you need to null out the test condition (l.exists and l.result) after each product call.

    (the difference in the return var result is just a stylistic one. personally i don't string words together any more--i.e., price_group verses pricegroup--Just easier to read.)

    Leave a comment:


  • lesliekirk
    started a topic Price Group Message

    Price Group Message

    I need to display a message next to a product in a Price Group, but only to customers in that Price Group

    This code puts the message next to only products in the Price Group but shows the message to everyone:

    Code:
    <mvt:do file="g.Module_Feature_PGR_DB" name="l.ok" value="PriceGroup_Load_Name( 'Barrys_Tea_10_1', 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">
    <span class="category-product-flag volume">Barry's Deal</span>
    </mvt:if>
    
    </mvt:if>
    <mvt:assign name="l.settings:pricegroupvar" value="''"/>
    This shows the message to only those in the Price Group, but shows it next to every product:

    Code:
    <mvt:if expr="g.Basket:cust_id">
    <mvt:do name="l.result" file="g.Module_Feature_PGR_DB" value="PriceGroup_Load_Name( 'Barrys_Tea_10_1', l.pricegroup )" />
    <mvt:if expr="l.result">
    <mvt:do name="l.exists" file="g.Module_Feature_PGR_DB" value="PriceGroupXCustomer_Load( l.pricegroup:id, g.Basket:cust_id, l.null )" />
    <mvt:if expr="l.exists">
    <mvt:assign name="g.basket:customer:Barrys_Tea_10_1" value="1" />
    </mvt:if>
    </mvt:if>
    </mvt:if>
    <mvt:if expr="g.basket:customer:Barrys_Tea_10_1">
    <span class="category-product-flag volume">BARRY'S DEAL</span>
    </mvt:if>
    This one is just a bit beyond me (but will probably make perfect sense when I see it).

    Note: I do not know why one uses l.price_group and one uses l.pricegroup

    Thanks,
    Leslie
Working...
X