📌  相关文章
📜  新订单电子邮件过滤器 woocommerce - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:53.560000             🧑  作者: Mango

代码示例1
add_action( 'woocommerce_email_order_details', function( $order, $sent_to_admin )
{
    if ( $sent_to_admin && ! defined('TST_ADMIN_EMAIL') ) {
        define( 'TST_ADMIN_EMAIL', true );
    }
}, 9, 2 );

add_filter( 'woocommerce_email_order_item_quantity', 'tst_filter_woocommerce_email_order_item_quantity', 10, 2 );
function tst_filter_woocommerce_email_order_item_quantity( $qty_display, $item )
{
    if (
        defined('TST_ADMIN_EMAIL')
        && true === TST_ADMIN_EMAIL
        && 'line_item' === $item->get_type()
    ) {
        $product = $item->get_product();
        $product_id = $product->get_id();

        if ( $product_id == 6960 ) {
            $qty_display = $qty_display * 2;
        }
    }

    return $qty_display; 
};