Untitled
unknown
plain_text
8 months ago
1.0 kB
3
Indexable
add_filter('b2bking_total_order_amount_used_group_rules', function($total, $user_id){
// Get all orders for the user
$args = array(
'customer_id' => $user_id,
'status' => array('wc-completed', 'wc-processing', 'wc-on-hold'),
'limit' => -1, // Get all orders
);
$orders = wc_get_orders($args);
$calculated_total = 0;
// Loop through each order
foreach ($orders as $order) {
$order_id = $order->get_id();
// Check if the order is a suborder using the provided function
if (!is_suborder($order_id)) {
// Add the order total to our running total
$calculated_total += $order->get_total();
}
}
return $calculated_total;
}, 10, 2);
// The is_suborder function as provided
function is_suborder($order_id){
$order = wc_get_order($order_id);
if($order->get_parent_id()){
if($order->get_parent_id() > 0){
return true;
}
}
return false;
}Editor is loading...
Leave a Comment