Get orders of a specific customer woocommerce

Try using wordpress get_posts() instead $user_id = 22; $orders = get_posts( array( ‘meta_key’ => ‘_customer_user’, ‘meta_value’ => $user_id, ‘post_type’ => ‘shop_order’, ‘post_status’ => array_keys( wc_get_order_statuses() ), ‘numberposts’ => -1 )); echo ‘<pre>’; print_r( $orders ); echo ‘</pre>’;

Add User Role: Pre-saved in User-Meta [SOLVED]

That’s because you’re not passing an actual ID to get_user_meta, but merely a string of id: $get_portal_number = get_user_meta(‘id’, ‘portal_number’, false); In addition, the third parameter is set to false, which will return an array. You’re passing that value straight to $user->add_role, but that expects a string. You either have to loop over your post … Read more

plugin wraps the entire content

There are 2 major problems. The first is that you output the opening div directly in the shortcode. Shortcodes must never echo or output directly, they always return a HTML string. As a result, before the post content is even displayed, this has already been sent to the browser: <div class=”blog__grid”> You’re very lucky you’re … Read more