• Resolved joefryfoto

    (@joefryfoto)


    This product is wonderful for converting variation option pulldowns into an attractive table of buttons, but there is one major problem: woocommerce_dropdown_variation_attribute_options_args is triggered twice on any given product page. I discovered this while echoing a variable on a filter and saw the variable was echoing twice. I cross-checked this with other swatch plugins which don’t have this behavior. I’ve tested it on Storefront with other plugins disabled. I’m not doing anything currently with swatches.

    This wouldn’t be so bad if my filter routine wasn’t a little slow to begin with, but two times a little slow equals too slow.

    Otherwise, this is the best plugin for converting pulldowns to buttons I’ve seen; primarily for its attractive layout and its proper, user-friendly handling of disallowed variations – all right out of the box. And at this point I’ve run through about seven of the most popular ones!

    But unfortunately the one flaw makes it unworkable for me. If you can fix this, I will shout praises from the rooftops. I stand ready to help with any info I can.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support fizanzvai

    (@fizanzvai)

    @joefryfoto

    Thanks for reaching out to us and for your investigations.

    Can you please share some more details on how you echoed the variable? I have tested it on my end and found the variable once.

    You can also share your screen record using a tool like- https://loom.com

    It will help us to understand it clearly. Hope to hear from you soon.

    Thread Starter joefryfoto

    (@joefryfoto)

    @fizanzvai – This is the beginning of my snippet filter for my variation attributes dropdowns:

    add_filter( ‘woocommerce_dropdown_variation_attribute_options_args’, ‘filter_dropdown_variation_args’, 10, 1 );

    function filter_dropdown_variation_args( $args ) {

    echo (‘variation attribute args routine<br>’);

    … }

    ###

    The rest of the filter routine is a rather complex “unsetting” of some options for the first attribute; the other attributes are skipped using an if statement reading wc_attribute_label( $args[‘attribute’] ) – but I don’t think any of that should matter.

    With your plugin enabled, it prints out “variation attribute args routine” twice above each attribute on my product screen, meaning that somehow, the routine is called twice? The attribute buttons themselves are not duplicated, but I guess that’s to be expected because this routine is only for setting options $args?

    https://pasteboard.co/SfDPSHGAmRem.png

    When I turn off your plugin, “variation attribute args routine” only prints once.

    https://pasteboard.co/BqDNGSLEM1le.png

    I am wondering if this has anything to do with swatches, which I am not currently wanting to use – at least for now, all I want is the button action. Is there something I might need to turn off?

    I hope I’ve been clear here.; I’d send you a vid, but I’m shy about showing my site/code to the rest of the world 😉

    Thread Starter joefryfoto

    (@joefryfoto)

    This is a follow-up after further discussion with the plugin support team. They responded quickly, affirming that the routine is indeed visited twice. I’ll dare to call it a bug-feature – something they did to help with backwards compatibility.

    I want to correct my notion that it slowed things down. Based on Query Monitor, performance difference is negligible with the plugin enabled. And this is without any caching add-ons – I’m purposely going with none during development. Any perceived slowdown is due to my option filtering alone.

    So false-alarm on a performance hit, and thanks again to the team for a quick solid response; the plugin is great!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Plugin makes variation options run twice’ is closed to new replies.