• My question is that what is the intended purpose of wrapping almost all function in wc-conditional-functions.php in a function_exists conditional?

    First I thought I’ll be able to override these in my theme, just like many other functions in WooCommerce wrapped in function_exists clauses, but it turns out that this file is loaded on plugin load basically meaning that only MU plugins could ever reliably override these, as other plugins may or may not be loaded before WooCommerce, and theme files are always loaded after.

    I’ve traced back the wrapping in conditionals to here: https://github.com/woocommerce/woocommerce/commit/730e21fdbc998137bbfdf0951fae7c614f14033d but the commit message only state the obvious.

    I guess the explanation is that 14 years ago the way WordPress worked and plugins were loaded could be different, and these conditional checks just stayed there, but looking from today’s perspective they don’t serve any real purpose I guess, right?

    It would be nice to be able to override these from a theme for special use-cases, that’s how I had to see this is not really possible, despite what the conditional checks would suggest.

    Also, shouldn’t these be deprecated at some point?

Viewing 1 replies (of 1 total)
  • Plugin Support Zubair Zahid (woo-hc)

    (@doublezed2)

    Hello Bence Szalai,

    Thank you for contacting WooCommerce support.

    I understand your question. These functions are wrapped in function_exists conditionals, but overriding them from a theme is not possible due to the way WooCommerce loads.

    If you want to discuss potential changes or deprecation, the best place would be the WooCommerce GitHub repository or the Woo Community Slack.

    Please don’t hesitate to contact us again if you have more questions or concerns.
    We are here to help ??

    Best regards.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.