我的函數(shù)導致錯誤 ?WC_Abstract_Legacy_Order->__get, wc_doing_it_wrong?。我已經(jīng)了解了同樣的問題,但仍然找不到我的函數(shù)中錯誤調用的位置,請幫助。Woocommerce 4.3。這是函數(shù):add_action( 'init', 'loyal_customer_auto_coupon', 10, 1);function loyal_customer_auto_coupon(){ if ( is_user_logged_in() ) { $customer = get_current_user_id(); $acf_user = 'user_' . $customer; $loyal = get_field('loyal_customer_coupon', $acf_user); if ($loyal == '') { $all_orders = wc_get_customer_order_count( $customer ); if ( $all_orders > 4 ) { $args = array( 'customer_id' => $customer ); $orders = wc_get_orders($args); $completed_order_count = 0; foreach ($orders as $order) { if ( $order->status == 'completed' ) { if ( $order->total > 14.99 ) { $completed_order_count++; } } } } } }}
1 回答

楊__羊羊
TA貢獻1943條經(jīng)驗 獲得超7個贊
由于無法直接訪問 WooCommerce 3 對象屬性,因此您將使用WC_Order
方法。所以在你的代碼中,替換
$order->status
經(jīng)過$order->get_status()
$order->total
經(jīng)過$order->get_total()
它應該可以解決你的問題。
- 1 回答
- 0 關注
- 121 瀏覽
添加回答
舉報
0/150
提交
取消