Why does the woocommerce product Attribute remains visible even after I delete it from the Database?

Viewed 104

To begin with I have created a simple plugin that contains this piece of code:

function woo_create_credit_attribute_taxonomy() {

    $attributes = wc_get_attribute_taxonomies();

    $slugs = wp_list_pluck( $attributes, 'remaining_credits' );

    if ( ! in_array( 'remaining_creds', $slugs ) ) {

        $args = array(
            'slug'    => 'remaining_creds',
            'name'   => __( 'Remaining Credits', 'bidrop-credits' ),
            'type'    => 'select',
            'orderby' => 'menu_order',
            'has_archives'  => false,
        );

        $result = wc_create_attribute( $args );
    }
}
 
// On Activation create the credit attribute taxonomy
add_action( 'admin_init', 'woo_create_credit_attribute_taxonomy' );

This piece of code, simply creates a new Woocommerce Product Attribute.

And in the uninstall.php file of the same plugin, I use the WPDB query below to remove it uppon uninstall.

global $wpdb;
$wpdb->query("DELETE FROM {$wpdb->prefix}woocommerce_attribute_taxonomies WHERE 1");

Notes: The Attribute is succesfully being deleted from the Database, but remains visible on front-end and when I try deleting it from the front-end it seems to be stuck there, Until I deactive and Reactivate Woocommerce.

Any ways I could adjust this code to flush_rewrite the woocommerces rules?

I have already tried the cassual flush_rewrite_rules() built-in function from wordpress. But it has no better results.

Thanks in advance for your time and effort

0 Answers
Related