• Resolved networkwebmasters

    (@networkwebmasters)


    I want to remove all attributes from product edit page.

    Steps:-
    WooCommerce -> Products -> All Products -> Edit Product -> Product data Section -> Attributes

    Here only two buttons “Expand & Close” available.

    I want “Clear All Attributes” button here.

    How can i get this button?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support lionel.a11n

    (@lioneldaniel)

    Hello @networkwebmasters,

    If no attributes have been added to a product, the ‘Attributes’ tab will only show the attribute action drop-down and the ‘Save attributes’ button (which will do nothing in this case). A blank Attributes table looks like this:

    If your product has attributes you want to remove, you’ll have to remove them one at a time in the Product Edit screen – there is no ‘Clear all attributes’ feature in core WooCommerce:

    If you are trying to completely remove the ‘Attributes’ tab from the Product Data metabox, that would take custom code and should be done with care as to not hide this tab on variable products.

    If that doesn’t answer your question, can you tell us what you’re hoping to achieve? We look forward to hearing back from you, and if you have any further questions or details please include those in your reply. Thanks!

    Thread Starter networkwebmasters

    (@networkwebmasters)

    3rd Point
    i want to completely remove all attributes from product data in one click, and this feature must be available in woocommerce core.

    Can you suggest javascript code for this issue?

    Plugin Support Rafy

    (@nawaz0705)

    Hi @networkwebmasters

    You can follow the steps suggested in this forum thread: https://www.ads-software.com/support/topic/how-to-delete-all-product-attributes/

    Before trying any SQL query or custom code snippet, I would recommend making sure that you have a good backup in place of your full site and database.

    Let us know if this helps!

    Thread Starter networkwebmasters

    (@networkwebmasters)

    <?php
    include 'wp-load.php';
    
    $attributes = json_decode(json_encode(wc_get_attribute_taxonomies()),true);
    sort($attributes);
    
    foreach ($attributes as $key => $attribute) {
        $deleted = wc_delete_attribute( $attribute['attribute_id'] );
        echo '<pre>';
        print_r(sprintf('Deleting %s - Result %s',$attribute['attribute_label'], $deleted));
        echo '</pre>';
    }

    Hi @nawaz0705

    Can you tell me this code delete all attributes from all product?
    I want to only remove currently editing product attributes. how can i add product id in above code?

    Plugin Support lionel.a11n

    (@lioneldaniel)

    Hello @networkwebmasters,

    Customizing PHP isn’t really the purpose of this support forum. To help you get help developing some custom code to do what you want, here are some WooCommerce community links where you might find a programmer to help customize the snippet for your needs:

    Like Rafy suggested, definitely back up before testing any queries or custom snippets on a live site. While you might get a snippet meant to do what you are looking for, you are ultimately responsible for any code you run on your site.

    I hope that points you in the right direction. I will leave this thread ‘unresolved’ for awhile in case another community member has a suggestion for you, but note this is not a feature of core WooCommerce so we will be marking this thread ‘Resolved’ as out of scope of the core plugin after a little while. Thanks!

    • This reply was modified 2 years, 2 months ago by lionel.a11n.
    Thread Starter networkwebmasters

    (@networkwebmasters)

    Can you tell me this code delete all attributes from all product?

    Plugin Support lionel.a11n

    (@lioneldaniel)

    Hello @networkwebmasters,

    It doesn’t look like any community members have a custom suggestion for you. I suggest you check out the Community Slack or Facebook Group for community help with developer-level questions.

    If you are interested in building your own solution you might also find our WooCommerce Developer Docs handy, and the web has numerous code examples and tutorials on writing PHP for WordPress.

    Since the purpose of this forum is aimed at supporting existing functionality, I am marking this thread as ‘resolved’ as this question isn’t in the scope of the core plugin. If you have further questions about WooCommerce’s core functionality, feel free to open a new thread. Thank you!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to remove all attributes from product edit page?’ is closed to new replies.