• Resolved etushar

    (@etushar)


    Hi,
    I have a code that successfully creates a shortcode for any customer’s last order. It gets the order details of the last order of a logged-in user. Instead of this, I need a code that gets the last order info regardless of any customer whether they’re logged in or not.

    add_shortcode( 'custom-woocommerce-total' , 'custom_total' );
    function custom_total(){
        $customer_id = get_current_user_id();
        $order = wc_get_customer_last_order( $customer_id );
        return $order->get_total();
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    Hi there 👋

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Cheers.

    Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    We’ve not seen any activity on this thread for a while, so I’m marking this thread as resolved.

    Hopefully, you were able to find a solution to your problem! If you have further questions, please feel free to open a new topic.

    Cheers!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Get last order info PHP’ is closed to new replies.