Get the customer ID from an order ID in WooCommerce

前端 未结 2 1769
粉色の甜心
粉色の甜心 2020-12-31 17:51

I want to get the \"mycred\" balance of a customer through the order while using WP ALL Export to export the customer balance based on orders to a spreadsheet. It\'s actuall

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-31 18:16

    For those who want to specifically add the customer mycred balance from an ORDER into the CSV sheet within WP All Export here is the bit of code I used. Thank you for your help getting it solved.

    While editing an ORDER export in WP ALL EXPORT, add a new data object and click on it and "Export the value returned by a PHP function" then add the following function in the code editor:

    function all_export_mycred($balance)
    {
        global $woocommerce, $post;
    
        $order = new WC_Order($post->ID);
        $user_id = $order->get_user_id( );
    
        $balance = mycred_get_users_balance( $user_id );
    
                return $balance;
    
        }
    

    Then make sure to add the "all_export_mycred" to the php return field.

提交回复
热议问题