L
L
Lord_Dantes2019-05-31 19:02:56
WordPress
Lord_Dantes, 2019-05-31 19:02:56

When updating or creating a specific post type, how do I update all WooCommerce products?

When you update the custom post type "group_products", you need to update all WooCommerce products automatically.
Like how to click on the "Update" button only for all products and automatically.
I think that you can do something with save_post but the link does not work like if save_post_group_products, save_post_products. Tipo xs tell me what can be done?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Yanchevsky, 2019-05-31
@Lord_Dantes

I don't really understand what the link is.
Should work like this (if WP version 3.7 or higher)

add_action( 'save_post_group_products', 'my_save_post' );
function my_save_post( $post_id ) {
  // 7 - это ID товара
  // Если хотите обновить все товары и товаров немного, то можно, например, запросить их через WP_Query и обновить циклом.
  wp_update_post( array( 'ID' => 7, 'post_status' => 'private' ) );
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question