Skip to content

Product Type filter breaks javascript when filtered  #11188

@digitalchild

Description

@digitalchild

Using the product_type_selector filter from wc_get_product_types() in a plugin during the 'plugins_loaded' action to remove a product type will result in breaking show_hide_panels javascript function in https://github.com/woothemes/woocommerce/blob/master/assets/js/admin/meta-boxes-product.js#L127

The javascript still needs to know all of the product types so that it can show hide correctly instead of the filtered product types.

This was changed in the following commit : b57030a

Reverting the change in the includes/admin/class-wc-admin-assets.php fixes the issue.

Code to reproduce has to be in a plugin:

function filter_product_types( $types ){ 
    return array(
        'simple'   => __( 'Simple product', 'woocommerce' ),
        'grouped'  => __( 'Grouped product', 'woocommerce' ),
        'variable' => __( 'Variable product', 'woocommerce' )
    );
} 

function plugin_init(){ 
    add_filter( 'product_type_selector',  'filter_product_types' ); 
}

add_action( 'plugins_loaded', 'plugin_init' ); 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions