【问题标题】:Modify Quantity of certain products in woocommerce emails修改woocommerce电子邮件中某些产品的数量
【发布时间】:2020-02-05 23:12:32
【问题描述】:

我需要使订单电子邮件中的数量仅针对特定产品显示为双倍。我修改了 email-order-items.php 如下(不工作):

在第 28 行添加:$product_id = $product->get_product_id(); 在第 79 行添加:

if( $product_id == 6960) {
    $qty_display = '<del>' . esc_html( $qty ) . '</del> <ins>' . esc_html( $qty * 2 ) . '</ins>';
}

https://github.com/woocommerce/woocommerce/blob/master/templates/emails/email-order-items.php

【问题讨论】:

    标签: php wordpress woocommerce


    【解决方案1】:

    您可以为此使用以下功能, 如果您不知道如何或在何处添加此代码,请查看以下链接

    https://www.wpbeginner.com/beginners-guide/beginners-guide-to-pasting-snippets-from-the-web-into-wordpress/

    function filter_woocommerce_email_order_item_quantity( $qty_display, $item ) {
        $product = $item->get_product();
        $product_id = $product->get_id();
    
        if ( $product_id == 6960 ) {
            $qty_display = $qty_display * 2;
        }
    
        return $qty_display; 
    }; 
    add_filter( 'woocommerce_email_order_item_quantity', 'filter_woocommerce_email_order_item_quantity', 10, 2 ); 
    

    【讨论】:

    • 这行得通。感谢您花时间回答,非常感谢。
    • 快速提问...我怎样才能使这个仅用于管理员订单电子邮件?
    猜你喜欢
    • 2021-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-04
    • 2021-04-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多