1 回答

TA貢獻1966條經驗 獲得超4個贊
woocommerce_order_status_changed
有4個參數這一行 ->
if ($product_id!="10")
說不等于,你也比較一個字符串而不是一個數值
試試這個方法
function action_woocommerce_order_status_changed( $order_id, $old_status, $new_status, $order ) {
// Compare
if( $old_status === 'approved' ) {
// Get items
$items = $order->get_items();
foreach ( $items as $item ) {
// Get product id
$product_id = $item->get_product_id();
if ($product_id == 10 ) {
$order->update_status( 'processing' );
break;
}
}
}
}
add_action( 'woocommerce_order_status_changed', 'action_woocommerce_order_status_changed', 10, 4 );
- 1 回答
- 0 關注
- 113 瀏覽
添加回答
舉報