Search code examples
csswordpresswoocommerceorderswoocommerce-theming

Remove payment details Woocommerce order's page in backend


I see a post about to translate or change the text "Paid on" on woocommerce backend order's detail page. I integrated it for bacs and local pickup payment.

Replace a specific word for BACS payment method in Woocommerce order edit pages

What I need to add if I want not display the "Paid on" message also when shop manager before set the status to processing (so payment details appears) and then turn back to "wait for payment" or a previous status?

Image attached: Order status is Deleted but it always show the payment details from Completed status set before

enter image description here

Thanks

Update:

Black fields are done because I want to hide real customer informations because I'm sharing the screenshoot here :D

This is to replicate the problem:

  • Customer makes the order
  • Order has a initial custom status created from me called "Verifying Stock"
  • Shop manager make the iter about the stock availability and then set the status to Wait for payment (Bacs or local payment at local pickup)
  • When shop manager set the status to "Processing", on the header appears the information about payment: "Paid on " and "IP: ..."
  • If the shop manager set a previous status of "processing", for example "wait for payment", the information "paid on" remains forever, i cannot remove them or update again.

I need to remove details if the order status is different from processing or completed order status.

Thanks


Solution

  • As you shared the screenshot I implemented the logic for you.

    You can try this for temporary hide billing, shipping address and IP address

    add_action( 'woocommerce_admin_order_data_after_order_details', 'hide_custom_details' );
    function hide_custom_details($order) { 
      $status = array('processing','completed','refunded','cancelled');
      $order_status = $order->get_status();
      //if(!is_admin() && !in_array($order_status, $status)) { 
      if(!in_array($order_status, $status)) { 
      ?>
      <style> 
         #order_data .order_data_column:nth-child(2),
         #order_data .order_data_column:nth-child(3),
         #order_data .woocommerce-order-data__meta.order_number .woocommerce-Order-customerIP{ 
               display: none !important 
         } 
      </style>
     <?php } 
    }
    

    If you want to update more, so first Inspect(ctrl+shift+i) and copy class/id as you want to hide and paste inside given CSS.

    If you want that, the admin can view every detail then add "!is_admin() &&" inside if the condition like commented if conditions. you can also update the status accordingly.

    enter image description here