woocommerce get product id
global $product;
$product->get_id();
woocommerce get product id
global $product;
$product->get_id();
woocommerce get orders by user id
public function get_sum_of_paid_orders( int $user_id ): int {
$customer_orders = [];
foreach ( wc_get_is_paid_statuses() as $paid_status ) {
$customer_orders += wc_get_orders( [
'type' => 'shop_order',
'limit' => - 1,
'customer_id' => $user_id,
'status' => $paid_status,
] );
}
$total = 0;
foreach ( $customer_orders as $order ) {
$total += $order->get_total();
// your code is here
}
return $total;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us