Can you please tell me how can I get product type after product save?
add_action( 'save_post_product', 'nd_update_group_product_attributes_func', 1001, 3 );
function nd_update_group_product_attributes_func($post_ID, $post, $update)
{
if($post->post_type == 'product'){
$childrens = $post->get_children();
$product_type = $post->get_type(); /* this will return simple for all product type*/
}
}
Even I have "grouped" product type.
$product_type = $post->get_type(); on save_post_product hook will return the "simple" when we first create the product and later on update will return "grouped".
2
Answers
if( $_product->is_type( ‘simple’ ) )
$product->is_type( ‘variable’ )
Get the WooCommerce product object using the function
wc_get_product
The hook
woocommerce_after_product_object_save
can be used here