Support » Plugin: WC Variations Radio Buttons » Disabled variations are visible on product page

  • Disabled variations are visible on product pages after updating to WooCommerce 3.0+. WooCommerce had their own problems with this when 3.0 was released but resolved it in v3.3.2 (9th fix). However, with WC Variations Radio Buttons 2.0.1 enabled the problem persists. How can I hide disabled variations?

    I’m testing on a fresh install of WP 4.9.4 with Twenty Seventeen and no other plugins installed.

    Thank you

Viewing 8 replies - 1 through 8 (of 8 total)
  • For now I came up with some JavaScript that will hide the disabled variations… It would be ideal to find a way to prevent them from being sent to the browser altogether though since this was the default behavior prior to WC 3.0.

    var myDisabledVariations = document.querySelectorAll('.variations_form input[type="radio"]:disabled');
    for (i = 0; i <  myDisabledVariations; i++) {
      myDisabledVariations[i].parentNode.style.display = 'none';
    }
    Plugin Author mantish

    (@mantish)

    Hi,
    This is working fine.
    There’s a difference on how variations work with and without this plugin:
    Normally, with dropdowns, the attributes (options of each dropdown) are shown/hidden depending on the available variations. In this plugin, the attributes (which correspond to a radio button) are enabled/disabled depending on the available variations.

    Thank you for responding but that was not how this plugin behaved prior to WooCommerce 3.0. I setup a test environment where you can see for yourself. This has:

    WP 4.9.5
    Theme: Twenty Seventeen 1.5
    WooCommerce 2.6.14
    WC Variation Radio Buttons 2.0.1
    One variable product with 3 variations
    Test URL:

    http://wcrbold.wpengine.com/?product=variable-product
    http auth: demo / support

    The disabled variations are hidden even with WCVRB enabled.

    I cloned that test install to a new install and updated to WooCommerce 3.3.5. I enabled all variations then re-disabled two of them. Now the disabled variations are visible but disabled. Test URL:

    http://wcrbold.staging.wpengine.com/?product=variable-product
    http auth: demo / support

    Something seems to have changed with how this plugin interacts with WC after updating to WC 3.0+.

    Do you know of a way to hide the disabled variations from the page? The JS solution I came up with works in the console but I haven’t figured out a way to get it working on a live site and would prefer that the disabled variations not be sent to the page at all.

    Thank you

    Plugin Author mantish

    (@mantish)

    Hi,

    The plugin was updated for WC3 taking the original files from WooCommerce as a base. I’m sorry that it changed the behavior regarding disabled variations.

    I’m not sure if it’s possible to change the template files so it doesn’t render the “unavailable” attributes. I think your JS solution is fine, because the attributes are disabled/enabled using a JS script as well

    Do you plan to add that option to your Plugin? as WC seems to have changed what/how it is sent to the browser – in a first quick test the JS from above didnt work :/

    The JS I provided worked for me when I used it in the browser console but I could never get it working in WordPress. I’m far from an expert though. It would be extremely helpful if the plugin was updated to work how it did prior to WC 3.0. As it is now I am having to delete and re-add variations as they go out of stock / come back in stock because for us it doesn’t make sense to display disabled variations.

    BigBugsy, I have this same problem and I am trying to disable them for just a couple of my products. Is that possible and what file do I put that code in? Thanks

    Unfortunately, I never found a solution for this. I am deleting variations when they should be hidden and then have to re-add them later. It’s a pain.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Disabled variations are visible on product page’ is closed to new replies.