【发布时间】:2022-01-07 05:12:47
【问题描述】:
我想阻止客户每 24 小时销售一次。
检查该客户在过去 24 小时内是否有其他购买,并在付款前显示错误并要求稍后退货
到目前为止我已经尝试过什么
function prevent_repeat_order() {
$last_24_hours_from_order_results = wc_get_customer_last_order($user_id);
(array( 'date_created' => '>=' . (time() - 86400), // time in seconds 'paginate' => true // adds a total field to the results ));
if ( $last_24_hours_from_last_order->total > 1 ) {
wc_add_notice('Too many orders in the last 24 hours. Please return later.', 'error');
}
}
add_action('woocommerce_checkout_process', 'prevent_repeat_order', 10, 0);
【问题讨论】:
标签: php wordpress woocommerce hook-woocommerce orders