Home > Software engineering >  How to display total amount on the order edit page woocamerce
How to display total amount on the order edit page woocamerce

Time:10-07

I have this code to display field order total amount on the order edit page:

add_action( 'woocommerce_admin_order_data_after_billing_address', 'custom_checkout_field_display_admin_order_meta', 10, 1 );
function custom_checkout_field_display_admin_order_meta($order){

    $method = get_post_meta( $order->id, '_payment_method', true );
    if($method != 'pec_gateway_check')
        return;

    echo date('Y/m/d', strtotime(" 40 days")) . " تاریخ چک صیادی";
}

I want add below code to show total amount in this page: How to do that?

  global $woocommerce;
  $carttotal = $woocommerce->cart->total;
  $total35 = $carttotal*0.35;
  $total65 = $carttotal*0.65;

    echo number_format($total35) . " ریال پرداخت شده";
    echo number_format($total65) . " ریال مبلغ چک پرداختی";

CodePudding user response:

From your question, it sounds like you just need to add the code you've written to the function you already have. So something like this:

add_action( 'woocommerce_admin_order_data_after_billing_address', 'custom_checkout_field_display_admin_order_meta', 10, 1 );
function custom_checkout_field_display_admin_order_meta($order){
    global $woocommerce;

    $method = get_post_meta( $order->id, '_payment_method', true );
    if($method != 'pec_gateway_check')
        return;

    echo date('Y/m/d', strtotime(" 40 days")) . " تاریخ چک صیادی";

    $carttotal = $woocommerce->cart->total;
    $total35 = $carttotal*0.35;
    $total65 = $carttotal*0.65;

    echo number_format($total35) . " ریال پرداخت شده";
    echo number_format($total65) . " ریال مبلغ چک پرداختی";
}
  • Related