• I have the WooCommerce Brands plugin installed (https://www.woothemes.com/products/brands/) as well as WooCommerce New Product Badge. In the admin panel, when I save the Brands settings, it sets the New Product Badge settings to blank and vice versa: when I save the New Badge setting, it sets the Brands settings to blank.

    I started investigating the code and it looks like both plugins use the ‘woocommerce_update_options_catalog’ and ‘woocommerce_update_options_products’ hooks to save. When saving from WooCommerce > Settings > Products > Display, it runs the save for both Brands and New Product Badge, but the Brands options are set to blank. When on WooCommerce > Settings > Products > Brands, it runs the save for both Brands and New Product Badge, but the New Product Badge settings are blank.

    Any ideas??

    https://www.ads-software.com/plugins/woocommerce-new-product-badge/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter acmdesigns

    (@acmdesigns)

    I did some more investigation. It seems like it’s not a conflict. It seems to be an error in implementation of both plugins of the save action.

    In the constructor, the following actions are registered:

    add_action( 'woocommerce_update_options_catalog', array( $this, 'save_admin_settings' ) );
    
    add_action( 'woocommerce_update_options_products', array( $this, 'save_admin_settings' ) );

    When a user is not on the page that these settings are visible, it saves the setting with an empty variable. For example, the New Product Badge settings are on Display tab. If I’m on the General tab, the New Product Badge settings will be overwritten with an empty value.

    I wrapped the above code in an if statement that checks the current tab:

    if (isset($_GET['section'] ) && $_GET['section'] == 'display') {
        add_action( 'woocommerce_update_options_catalog', array( $this, 'save_admin_settings' ) );
    
        add_action( 'woocommerce_update_options_products', array( $this, 'save_admin_settings' ) );
    }

    This seems to fix the problem, but I don’t know if it’s actually a good fix.

    Thread Starter acmdesigns

    (@acmdesigns)

    Any help?

    Thread Starter acmdesigns

    (@acmdesigns)

    I sent a ticket to WooThemes and they determined it’s a bug in how the woocommerce_update_options_products hook is used in BOTH plugins. The conditional statement I added in the sample above is needed for both plugins (and any other plugin using this hook).

    For new badge plugin, it should read:
    if (isset($_GET['section'] ) && $_GET['section'] == 'display') { ... }

    For WooCommerce Brands plugin, it should read:
    if (isset($_GET['section'] ) && $_GET['section'] == 'brands') { ... }

    TO THE AUTHORS of the New Poduct Badge plugin, please fix this bug!

    Adam

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Conflicts with WooCommerce Brands plugin’ is closed to new replies.