Announcement

Collapse
No announcement yet.

Dropdown menus ignoring the SELECTED attribute

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

    #16
    NOTE: This is from a Levels ReadyTheme. Remember, the code can't be easiliy mixed and matched with other ReadyThemes

    The button code:

    Code:
    <mvt:if expr="l.settings:product:inv_level NE 'out' OR l.settings:attributemachine:product:inv_level NE 'out'">
         <button id="js-add-to-cart" class="button button-block uppercase add-to-cart bg-green white bold">Add <span class="small-inline-block hide">to Cart</span></button>
    <mvt:else>
         <button id="js-add-to-cart" class="button button-block uppercase add-to-cart bg-green white bold" disabled>Sold Out</button>
    </mvt:if>
    The javascript:

    Code:
    // ---- Update Button For "Out Of Stock" ---- //
    
    function outOfStock () {
    var button = $('#js-add-to-cart');
    var invMsg = $('#js-inventory-message').html();
    
    if (button.is(':disabled') === true) {
    
    
    if (invMsg === 'Please select a valid combination of attributes.') {
    button.addClass('bg-gray').html('Select One');
    }else{
    button.addClass('bg-gray').html('Sold Out');
    }
    }
    else {
    button.removeClass('bg-gray').html('Add <span class="small-inline-block hide">to Cart</span>');
    }
    }
    outOfStock();
    
    MivaEvents.SubscribeToEvent('variant_changed', function () {
    
    outOfStock();
    
    });
    Your mileage may vary.
    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


      #17
      I definitely recommend removing the "out of stock" label on the button. Just keep it saying Add to Cart and disable it. Use MESSAGING to say "please select..." and then re-enable the button when required attributes are selected.
      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


        #18
        We are only using inventory variants to allow price changes on the page - not for actually tracking inventory. Is there a way to approach this the opposite way: keep the Initial Attribute State set to Drop-Down Lists Do Not Contain Select One and then modify attributemachine for only the products that include the Select One?

        Comment

        Working...
        X