Как изменить поле доставки WooCommerce в электронных письмах с новым заказом?

Я пытаюсь изменить порядок полей доставки в электронных письмах с новым заказом WooCommerce, однако изменение поля доставки в email-address.php приведет к поломке страницы оформления заказа. Как я могу это изменить?

Вот как я модифицирую:

0 Исходный код:

$text_align = is_rtl() ? 'right' : 'left';
$address    = $order->get_formatted_billing_address();
$shipping   = $order->get_formatted_shipping_address();

?><table id="addresses" cellspacing="0" cellpadding="0" style="width: 100%; vertical-align: top; margin-bottom: 40px; padding:0;" border="0">
    <tr>
        <td style="text-align:<?php echo esc_attr( $text_align ); ?>; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; border:0; padding:0;" valign="top" width="50%">
            <h2><?php esc_html_e( 'Billing address', 'woocommerce' ); ?></h2>

            <address class="address">
                <?php echo wp_kses_post( $address ? $address : esc_html__( 'N/A', 'woocommerce' ) ); ?>
                <?php if ( $order->get_billing_phone() ) : ?>
                    <br/><?php echo esc_html( $order->get_billing_phone() ); ?>
                <?php endif; ?>
                <?php if ( $order->get_billing_email() ) : ?>
                    <br/><?php echo esc_html( $order->get_billing_email() ); ?>
                <?php endif; ?>
            </address>
        </td>
        <?php if ( ! wc_ship_to_billing_address_only() && $order->needs_shipping_address() && $shipping ) : ?>
            <td style="text-align:<?php echo esc_attr( $text_align ); ?>; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; padding:0;" valign="top" width="50%">
                <h2><?php esc_html_e( 'Shipping address', 'woocommerce' ); ?></h2>

                <address class="address"><?php echo wp_kses_post( $shipping ); ?></address>
            </td>
        <?php endif; ?>
    </tr>
</table>

1. Успешно изменено поле Биллинг :

<address class="address">
    <?php //echo wp_kses_post( $address ? $address : esc_html__( 'N/A', 'woocommerce' ) ); ?>
        Name: <?php echo $order->billing_first_name; ?><?php echo $order->billing_last_name; ?><br>
        Address:<?php echo $order->billing_country; ?><?php echo $order->billing_postcode; ?><?php echo $order->billing_city; ?><?php echo $order->billing_state; ?><?php echo $order->billing_address_1; ?>
    <?php if ( $order->get_billing_phone() ) : ?>
        <br/>Phone:<?php echo esc_html( $order->get_billing_phone() ); ?>
    <?php endif; ?>
    <?php if ( $order->get_billing_email() ) : ?>
        <br/>Email:<?php echo esc_html( $order->get_billing_email() ); ?>
    <?php endif; ?>
</address>
</td>

2.Это я хочу изменить поле доставки, но не работает :

<td style="text-align:<?php echo esc_attr( $text_align ); ?>; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; padding:0;" valign="top" width="50%">
                <h2><?php esc_html_e( 'Shipping address', 'woocommerce' ); ?></h2>

                <address class="address">
                    <?php //echo wp_kses_post( $shipping ); ?>
                         Shipping Name:<?php echo esc_html($order->get_shipping_first_name() ); ?><?php echo esc_html($order->get_shipping_last_name() ); ?><br>
                         Shipping Address:<?php echo $order->esc_html(get_shipping_country() ); ?><?php echo esc_html($order->get_shipping_postcode() ); ?><?php echo esc_html($order->get_shipping_city() ); ?><?php echo esc_html($order->get_shipping_state() ); ?><?php echo esc_html($order->get_shipping_address_1() );?>
                    <?php if ( $order->get_shipping_phone() ) : ?>
                         <br/>Shipping Phone:<?php echo esc_html( $order->get_shipping_phone() ); ?>
                <?php endif; ?>
                <?php if ( $order->get_shipping_email() ) : ?>
                         <br/>Shipping Email:<?php echo esc_html( $order->get_shipping_email() ); ?>
                <?php endif; ?>


                </address>

Любая помощь Где я могу ее получить и изменить?

Спасибо


person Jei-zen-Zheng    schedule 06.03.2019    source источник


Ответы (1)


Привет, ваш код идеален, за исключением следующих строк

1> if ( $order->get_shipping_phone() )
2> if ( $order->get_shipping_email() )

в строках выше get_shipping_phone и get_shipping_email - это методы, которые недоступны в самой woocommerce, поэтому вы можете использовать get_billing_email и get_billing_phone вместо них, если хотите.

person Rajdeep Tayde    schedule 06.03.2019