0

我将文件“email-order-details.php”复制到我的子主题中。现在我可以修改 html,但想在我的表格中添加一个额外的列用于产品图像。使用此代码,我可以显示图像和 sku,但它与产品名称、sku、产品描述在同一列中。

        <?php
        echo wc_get_email_order_items( $order, array( // WPCS: XSS ok.
            'show_sku'      => $true,
            'show_image'    => false,
            'image_size'    => array( 32, 32 ),
            'plain_text'    => $plain_text,
            'sent_to_admin' => $sent_to_admin,
        ) );
        ?>

我还想显示没有 () 的 sku,并且我想将它放在列的顶部。我认为必须有一个数组或变量或类似的东西来获取日期。

这条线,例如显示价格,谁能告诉我如何以同样的方式显示 sku 和产品图像?

<th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Price', 'woocommerce' ); ?></th>

先感谢您

4

1 回答 1

0

试试这个片段代码,我在子主题的functions.php中使用它:

function sww_add_wc_order_email_images( $table, $order ) {

ob_start();

$template = $plain_text ? 'emails/plain/email-order-items.php' : 'emails/email-order-items.php';
wc_get_template( $template, array(
    'order'                 => $order,
    'items'                 => $order->get_items(),
    'show_download_links'   => $show_download_links,
    'show_sku'              => $show_sku,
    'show_purchase_note'    => true,
    'show_image'            => true,
    'image_size'        => array( 200, 200 )
) );

return ob_get_clean();
}
add_filter( 'woocommerce_email_order_items_table', 'sww_add_wc_order_email_images', 10, 2 );
于 2018-10-16T23:30:01.580 回答