• Hi Rene,

    I have a customer of my WooCommerce Wholesale Ordering plugin that uses your plugin for bulk discounts, but does NOT want them to apply to Wholesale Customers (since they already can order at low wholesale prices via my plugin).

    You don’t have any hooks in place to allow other plugins to modify if your plugin applies discounts or not (or shows). However, you have the global ‘woocommerce_t4m_enable_bulk_discounts’ option to determine whether or not your woocommerce hooks are added. I can filter that option value via the WordPress pre_option_$option filter hook. However, in order to check if the current user is retail or wholesale, the current user needs to already be initialized.

    The problem is that your plugin adds all the WooCommerce hooks at the ‘woocommerce_loaded’ action hook, which is before the rest of WordPress is initialized, so the current user doesn’t exist yet.

    All you need to do is change the hook that your function taps into to the ‘init’ hook (which is still after WooCommerce has loaded, so it still works perfectly), and then I can send my client a simple little function to alter whether or not your hooks are added based on the current customer. I could also add that little function as a compatibility setting in a future update for my own plugin and let people know it works with yours.

    In short, you just need to change one thing on line 65 of your main plugin file. Simply change:

    add_action( 'woocommerce_loaded', array( $this, 'woocommerce_loaded' ) );

    to:

    add_action( 'init', array( $this, 'woocommerce_loaded' ) );

    Doesn’t affect the operation of your plugin at all to change that action hook, and makes life easier for the customers of my plugin who only want discounts for retail customers.

    THANKS!!!

  • The topic ‘Minor Change request for compatibility with other plugins’ is closed to new replies.