I am new in woocommerce and implementing for the first time so basically, I want to get all payment and user details when the user done payment. I need because I want to store in the separate table as per our requirement. Is there any way to get details.

enter image description here

  • What payment platform are you using? ie. Stripe/PayPal, etc. Note that storing these details should be in an encrypted form and you will need to ensure the server you are running your application on is PCI compliant. pcicomplianceguide.org/faq – Steve Oct 11 '17 at 12:37
  • I am using Paytm platform and I am storing only first name, last name, email and location details. – Mr.Happy Oct 11 '17 at 12:41
  • That stuff will be stored with the orders. Is there a reason it needs to be stored separately? – Jacob Peattie Oct 11 '17 at 13:27
  • @JacobPeattie I have to show all transactions in my another admin panel. – Mr.Happy Oct 11 '17 at 13:48
  • You can use Stripe for payments it gives all details you want – Mohammed Khalil Dec 23 '20 at 22:53

Yes, after an order created you can get details of it.

The woocommerce_payment_complete hook is fired when the payment is completed. The only variable passed is the order id, though from that you can get the order object, and ultimately the user.

add_action( 'woocommerce_order_status_completed', 'so_payment_complete' );
function so_payment_complete( $order_id ){
    $order = wc_get_order( $order_id );
     $order_data = $order->get_data(); // The Order data

     $user = $order->get_user();
     if( $user ){
        // do something with the user

   $order_id = $order_data['id'];
   $order_parent_id = $order_data['parent_id'];
   $order_status = $order_data['status'];
   $order_currency = $order_data['currency'];
   $order_version = $order_data['version'];
   $order_payment_method = $order_data['payment_method'];
   $order_payment_method_title = $order_data['payment_method_title'];

   $order_discount_total = $order_data['discount_total'];
   $order_discount_tax = $order_data['discount_tax'];
   $order_shipping_total = $order_data['shipping_total'];
   $order_shipping_tax = $order_data['shipping_tax'];
   $order_total = $order_data['cart_tax'];
   $order_total_tax = $order_data['total_tax'];
   $order_customer_id = $order_data['customer_id']; // ... and so on


   $order_billing_first_name = $order_data['billing']['first_name'];
   $order_billing_last_name = $order_data['billing']['last_name'];
   $order_billing_company = $order_data['billing']['company'];
   $order_billing_address_1 = $order_data['billing']['address_1'];
   $order_billing_address_2 = $order_data['billing']['address_2'];
   $order_billing_city = $order_data['billing']['city'];
   $order_billing_state = $order_data['billing']['state'];
   $order_billing_postcode = $order_data['billing']['postcode'];
   $order_billing_country = $order_data['billing']['country'];
   $order_billing_email = $order_data['billing']['email'];
   $order_billing_phone = $order_data['billing']['phone'];


   $order_shipping_first_name = $order_data['shipping']['first_name'];
   $order_shipping_last_name = $order_data['shipping']['last_name'];
   $order_shipping_company = $order_data['shipping']['company'];
   $order_shipping_address_1 = $order_data['shipping']['address_1'];
   $order_shipping_address_2 = $order_data['shipping']['address_2'];
   $order_shipping_city = $order_data['shipping']['city'];
   $order_shipping_state = $order_data['shipping']['state'];
   $order_shipping_postcode = $order_data['shipping']['postcode'];
   $order_shipping_country = $order_data['shipping']['country'];


You can get details like this of an order after it's payment done. Further, you can store it in your another table.

Hope this will work for you.

  • I have added your function in my theme function.php file and echo all variables but not getting any value. Can you please guide me as i don't have any knowledge in woocommerce. – Mr.Happy Oct 11 '17 at 12:49
  • Or plz try this hook, function mysite_woocommerce_payment_complete( $order_id ) { //your code } add_action( 'woocommerce_order_status_completed', 'mysite_woocommerce_payment_complete' ); This will do whenever you order status will be completed then it will call this function. – Sunil Dora Oct 11 '17 at 12:56
  • Or you can see above answer I have been changed the hook in it, you can try it also. – Sunil Dora Oct 11 '17 at 12:59
  • Is there any changes required in woocommerce setting to use your hook? – Mr.Happy Oct 11 '17 at 13:21
  • no, I don't think so that we need to do any changes in woocommerce settings for it. Thanks. – Sunil Dora Oct 11 '17 at 13:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.