Announcement

Collapse
No announcement yet.

Help with inventory conditional statement.

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

    Help with inventory conditional statement.

    Newbie to M5-9, need help with the following inventory conditional statements and was not able to find conditional statement documentation online.

    Code:
    <IF STOCK GT 1>
         Only a few in stock!
    <IF STOCK LE 1>
         Only 1 left in stock!            
    <END IF>
    I have a very good idea how conditionals statements (MM4.24c) work, problem is the code is completely different, but I am eager to learn.
    Thank you, Bill Davis

    #2
    I'm thinking that the Inventory Settings can do this sort of "heavy lifting" for you. You have the ability to set a level for a Low Stock message, and an Out of Stock message plus the ability to display a quantity.
    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


      #3
      Leslie is correct, the built in inventory system has the functionality built in. There is a low stock level where you can set a trigger for the low stock level and a custom inventory message once it gets to that level.

      Here is some information on how to configure that:

      http://docs.miva.com/reference-guide/products-inventory

      Here is the conditional you're looking for:

      Code:
      <mvt:if expr="l.settings:product:inv_available GT 1">
          Only a few in stock!
      <mvt:elseif expr="l.settings:product:inv_available LE 1">
          Only 1 left in stock!
      </mvt:if>
      Here are some developer resources to get you started learning the Miva Template Language:

      http://docs.miva.com/developers

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

      Comment


        #4
        Thanks to both of you!!!
        Thank you, Bill Davis

        Comment


          #5
          How do I change the conditional statement below to also display when GE 50 AND product in stock?

          Would conditional also work if product attribute is in stock, or need something more complex?

          Been searching documentation for hours and was not able to find one example that contained the use of the logical conditional statement AND, much less combined with any kind of inventory condition.

          Code:
          <mvt:if expr="l.settings:product:price GE 50">
              <div class="column whole">
                  <p class="h5"><span class="levels-icon-truck"></span> This item qualifies for Free US Shipping & Handling!</p>
              </div>
          </mvt:if>
          Thank you, Bill Davis

          Comment


            #6
            Originally posted by William Davis View Post
            How do I change the conditional statement below to also display when GE 50 AND product in stock?

            Would conditional also work if product attribute is in stock, or need something more complex?

            Been searching documentation for hours and was not able to find one example that contained the use of the logical conditional statement AND, much less combined with any kind of inventory condition.

            Code:
            <mvt:if expr="l.settings:product:price GE 50">
            <div class="column whole">
            <p class="h5"><span class="levels-icon-truck"></span> This item qualifies for Free US Shipping & Handling!</p>
            </div>
            </mvt:if>
            It just occurred to me that I could easily remove the entire conditional from PROD template page and display it through In Stock and Low Stock Inventory templates.
            Thank you, Bill Davis

            Comment

            Working...
            X