Viewing 3 replies - 1 through 3 (of 3 total)
  • Saif

    (@babylon1999)

    Hello @zaheer01,

    Thank you for reaching out!

    I am working on a project where I have to check if the category does not have a (Default Google product category), simply delete that category. But the problem is how can I check programmatically? right now I have category IDs only. Is there any function or hook to check?

    I understand you want to delete a category in bulk if the “Default Google product category” is not set for that category. This is actually more related to WordPress core than our plugin.

    The “Default Google product category” values are added to the category term as metadata, so you can simply check if the category has one or all of the plugin’s metadata starting with _wc_facebook, if not → delete it.

    To check the linked metadata values to each category, you can use a plugin like JSM Show Term Meta.


    Link to image: https://d.pr/i/cyqCjW

    I trust this guides you in the right direction! Let us know if you have any other questions! :‎)

    Thread Starter zaheer01

    (@zaheer01)

    I think that is the perfect solution, so this is the code.

    $term_args = array(
    ‘taxonomy’ => ‘product_cat’,
    );

    $terms = get_terms( $term_args );

    $term_ids = array();
    foreach( $terms as $term ) {

    echo "ID: ".$term->term_id."<br>";
    $key = get_term_meta( $term->term_id, '_wc_facebook_google_product_category', true );
    
    echo "Key:".$key."<br>";

    }

    • This reply was modified 7 months ago by zaheer01.
    Plugin Support carolm29 (woo-hc)

    (@carolm29)

    Hey, @zaheer01!

    I’m glad we were able to help and thank you for sharing the code here. It will help other users looking to do the same 😃

    Since the issue is solved, I’ll mark this as resolved, okay?

    Feel free to reach out if you need any further assistance or have any questions.

    Have a wonderful day!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How can I check if category have (Default Google product category)?’ is closed to new replies.