我想在添加产品或属性或更新属性时创建webhook 例如:
function add_this_to_new_products( $new_status, $old_status, $post ) {
$defaults = array ( 'shopid' => array (
'name' => 'shopid',
'value' => 'mahdi',
'position' => 1,
'is_visible' => 1,
'is_variation' => 1,
'is_taxonomy' => 1,
),
);
update_post_meta( $post->ID , '_product_attributes', $defaults );
}
add_action( 'transition_post_status', 'add_this_to_new_products', 10, 3 );
或
function add_this_to_new_products( $new_status, $old_status, $post ) {
$defaults = get_bloginfo();
update_post_meta( $post->ID , '_product_attributes', $defaults );
}
add_action( 'transition_post_status', 'add_this_to_new_products', 10, 3 );
但这些都不起作用。请指导我。谢谢