Announcement

Collapse
No announcement yet.

Conditional Needed to Test Variant Inventory Levels and Not the Parent Prod

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

    Conditional Needed to Test Variant Inventory Levels and Not the Parent Prod

    I am trying to get the waitlist function of toolkit working on a store but they are using product variants to track the individual variant inventory. So when I add a conditional to the PROD page, or the CTGY page testing a product to see if it is out of stock or not, it is saying that the product is out whether the variants have inventory or not. Here is what I have now:

    <mvt:if expr="l.settings:product:inv_level EQ 'out'">
    <a class="btn btn-sm btn-green btn-wait-list-ctgy" href="Javascript:window.open('&mvt:global:sessionu rl;Store_Code=&mvta:global:store:code;&Screen=WAIT LIST&Product_Code=&mvta:product:code;&show_wait=1' ,'image','scrollbars=yes,status=no,width=400,heigh t=300').focus();">
    Email me<br>when available</a>
    </mvt:if>

    Is there a different conditional to use for checking the inventory variants?

    I have looked everywhere and can’t find an answer for this.

    Miva support said to see if anyone had a solution for this.

    Thank you for the help!
    Calvin Nelson
    Director of Web Development
    2C Development Group

    #2
    Re: Conditional Needed to Test Variant Inventory Levels and Not the Parent Prod

    You have a couple options.

    Since Miva's inventory system is all controlled by JavaScript, there are no native template level variables you can check for. It all has to be done in JavaScript.

    However toolkit does provide a function called variantarray which will make the variant data available on the page. If you wanted to do something in the template language this is your best option. The big problem with this is it won't be based on the customers selection.

    You need to tie into Miva's on variant change function to test to see if the current variant selected has inventory available, then show hide the wishlist link based on that

    Code:
    <script>
    MivaEvents.SubscribeToEvent('variant_changed', function(data){
    	var inventory_message = document.getElementById('inventory-message').innerHTML;
    
    
    	if(inventory_message == 'Out Of Stock'){
    		//show wishlist link
    	}else{
    
    
    		//hide wishlist link
    	}
    });
    </script>
    Brennan Heyde
    VP Product
    Miva, Inc.
    [email protected]
    https://www.miva.com

    Comment


      #3
      Re: Conditional Needed to Test Variant Inventory Levels and Not the Parent Prod

      Thank you Brennan, that solves the problem I have on the PROD page. However, that wont work on the CTGY page. Do you have any suggestions on how to test every inventory variant and see if all of them are sold out or not? That is what I am really having problems with.

      Thanks,
      Calvin Nelson
      Director of Web Development
      2C Development Group

      Comment


        #4
        Re: Conditional Needed to Test Variant Inventory Levels and Not the Parent Prod

        So you want to either display the add to cart button or wishlist button on CTGY if all variants are sold out?

        If that is the case you can use toolkits variantarray function to loop though all inventory variants and if all are out of stock, show the wishlist button.
        Brennan Heyde
        VP Product
        Miva, Inc.
        [email protected]
        https://www.miva.com

        Comment

        Working...
        X