如何在woocommerce中创建/更新新产品/属性时创建webhook

时间:2017-05-13 09:11:48

标签: wordpress woocommerce webhooks

我想在添加产品或属性或更新属性时创建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 );

但这些都不起作用。请指导我。谢谢

0 个答案:

没有答案