Announcement

Collapse
No announcement yet.

Related Products Conditional

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

    Related Products Conditional

    Hi, I've seen another thread that had an apparently old version of a conditional regarding whether or not a product has related items assigned. Unfortunately it didn't appear to work properly in my case.

    I've tried to write my own but having no luck there either:

    <mvt:if expr="l.settings:related_products_count GT 0">
    Run some code...
    </mvt:if>

    Anyone have a suggestion on how best to do this?

    #2
    Re: Related Products Conditional

    That should work if you are on CSSUI. If you have an MMUI store (older) it would be:

    Code:
    <mvt:if expr="l.settings:product_count NE 0">
    
    </mvt:if>
    Brennan Heyde
    VP Product
    Miva, Inc.
    [email protected]
    https://www.miva.com

    Comment


      #3
      Re: Related Products Conditional

      Thanks Brennan! I'm wondering then if it's a problem with the items I'm trying to hide with that conditional. Basically, I am creating a set of related products for a particular genre of product (for example, a bunch of rugs that all use the same pattern). We're using an older CSSUI store (several years old) and the templates aren't quite up to date.

      So what I want to do is hide the empty price and add to cart buttons in the Product Display Layout, such as:

      <mvt:if expr="l.settings:related_products_count GT 0">

      <div class="product-price">
      <mvt:if expr="NOT ISNULL l.settings:product:customfield_values:customfields :FullPrice">
      <div>Regular Price: <b><s>&mvt:product:customfield_values:customfields :FullPrice;</s></b></div>
      </mvt:if>

      <b>Price:</b> <span id="price-value" class="bold">&mvt:product:formatted_price;</span></div>

      <mvt:item name="cim_vol" param="checkprice" />
      <mvt:if expr="volprice_aslowas_on EQ 0">

      <mvt:else>
      <mvt:item name="cim_vol" param="lowestprice" /><br />
      <div style="width:200px; text-align:left;"><mvt:item name="cim_vol" param="table" /></div>
      </mvt:if>

      <mvt:if expr="l.settings:product:weight NE 0">
      <div class="product-weight"><b>Shipping Weight:</b> <span class="bold">&mvt:product:weight;</span> &mvt:store:wtunits;</div>
      </mvt:if>
      <div id="inventory-message">
      <mvt:if expr="l.settings:product:inv_active">
      &mvt:product:inv_short;
      </mvt:if>
      </div>
      <div class="product-quantity"><b>Quantity in Basket:</b>
      <mvt:if expr="l.settings:product:quantity EQ 0">
      <span class="italic">None</span>
      <mvt:else>
      <span class="bold">&mvt:product:quantity;</span>
      </mvt:if>
      </div>
      </div>
      <div class="product-details-2">
      <form method="post" action="&mvt:global:sessionurl;Screen=BASK">
      <div class="product-description">&mvt:product:descrip;</div>
      <input type="hidden" name="Old_Screen" value="&mvte:global:Screen;" />
      <input type="hidden" name="Old_Search" value="&mvte:global:Search;" />
      <input type="hidden" name="Action" value="ADPR" />
      <input type="hidden" name="Store_Code" value="&mvte:store:code;" />
      <input type="hidden" name="Product_Code" value="&mvte:product:code;" />
      <input type="hidden" name="Category_Code" value="&mvte:global:category_code;" />
      <input type="hidden" name="Offset" value="&mvte:global:Offset;" />
      <input type="hidden" name="AllOffset" value="&mvte:global:AllOffset;" />
      <input type="hidden" name="CatListingOffset" value="&mvte:global:CatListingOffset;" />
      <input type="hidden" name="RelatedOffset" value="&mvte:global:RelatedOffset;" />
      <input type="hidden" name="SearchOffset" value="&mvte:global:SearchOffset;" />
      <div class="product-attributes"><mvt:item name="product_attributes" param="product:id" /></div>
      <div class="purchase-buttons"><b>Quantity:</b> <mvt:item name="cim_qmin" param="prod" /> <mvt:item name="buttons" param="AddToBasket" /> <a href="&mvt:global:secure_sessionurl;Screen=GIFT&Su bScreen=GIFT&Store_Code=&mvta:global:Store_Code;&P roduct_Code=&mvta:product:code;&Action=ADDONE">+ Add to Wish List</a>
      </div>

      </mvt:if>
      Unfortunately this seems to work on all products, instead of just those who have related products assigned.

      Perhaps what I'm trying to do isn't possible? I would use attributes but, as I mentioned, the store is a bit old and trying to use attribute templates seems to cause a lot of other problems.

      Comment


        #4
        Re: Related Products Conditional

        What you're trying to do is not going to work. The conditional you are using l.settings:related_products_count GT 0 is only checking if the current product you are viewing has attributes or not. Can you perhaps have a custom field and determine to show the products based on that custom field?


        Brennan Heyde
        VP Product
        Miva, Inc.
        [email protected]
        https://www.miva.com

        Comment


          #5
          Re: Related Products Conditional

          Hi Brennan,

          Thanks for your suggestion. So, I've created a custom field that will let us mark if the product just be a list of related products. Here's what I'm trying:

          <mvt:if expr="l.settings:product:customfield_values:custom fields:combinedproduct EQ 'yes'">
          This is a combined product.

          <mvt:else>
          Show the regular product price, Add to Cart button.
          </mvt:if>

          So far, I never get the "This is a combined product" message, even if I enter "yes" in the custom field.

          Comment

          Working...
          X