繁体   English   中英

如何在Woocommerce客户邮件中添加“相关产品”

[英]How to add “related products” in Woocommerce Customer Mails

我想在Woocommerce客户邮件中显示4个相关产品,但是当我只是在customer-processing-order.php调用短customer-processing-order.php没有任何反应。

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

/**
 * @hooked WC_Emails::email_header() Output the email header
 */
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
<?php echo do_shortcode('[related_products limit="4"]'); ?>

<p><?php _e( "Your order has been received and is now being processed. Your order     details are shown below for your reference:", 'woocommerce' ); ?></p>

<?php

/**
 * @hooked WC_Emails::order_details() Shows the order details table.
 * @hooked WC_Structured_Data::generate_order_data() Generates structured data.
 * @hooked WC_Structured_Data::output_structured_data() Outputs structured data.
 * @since 2.5.0
 */
do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );

/**
 * @hooked WC_Emails::order_meta() Shows order meta data.
 */
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );

/**
 * @hooked WC_Emails::customer_details() Shows customer details
 * @hooked WC_Emails::email_address() Shows email address
 */
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );

/**
 * @hooked WC_Emails::email_footer() Output the email footer
 */
do_action( 'woocommerce_email_footer', $email );

我知道需要一个钩子或者我可以调用的东西来显示这些相关的产品,但到目前为止我所尝试的都没有工作或崩溃整个系统。

试试下面的代码。 这可能有所帮助。 在functions.php文件中添加此代码

add_action( 'woocommerce_email_after_order_table', 'custom_related_product', 10, 2 );
function custom_related_product( $order, $is_admin_email ) {
    echo do_shortcode('[related_products limit="4"]');
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM