jeudi 30 janvier 2020

display message WHEN THERE IS NO Order. Woocommerce wordpress

I have a function code that i have placed in my theme function.php to display my orders on another page of my wordpress website. This function is placed in child theme.

function woocommerce_orders() {
    $user_id = get_current_user_id();

    if ($user_id == 0) {
        return do_shortcode('[woocommerce_my_account]'); 
    }else{
        ob_start();
        wc_get_template( 'myaccount/my-orders.php', array(
            'current_user' => get_user_by('id', $user_id),
            'order_count'  => $order_count 
        ));

        return ob_get_clean();
    }
}

add_shortcode('woocommerce_orders', 'woocommerce_orders');

This will only display when there is an order placed. Can you help me or guide me to add a message which says that no order has been placed when there is no order placed.




Aucun commentaire:

Enregistrer un commentaire