简体   繁体   English

链接 Dokan Woocommerce 电子邮件通知的订单号

[英]Linking the order number for Dokan Woocommerce email notifications

I'm using Dokan and about up and running but have a couple issues with the stock email templates from Woocommerce.我正在使用 Dokan 并且正在运行,但是 Woocommerce 的库存电子邮件模板存在一些问题。

  1. On the new order email, the order number is also a link.在新订单电子邮件上,订单号也是一个链接。 Ideally, that would link to their order in Dokan.理想情况下,这将链接到他们在 Dokan 中的订单。 However, the link address is to my (as the admin) wordpress site and directs them to log into wordpress, for which they obviously don't have credentials.但是,链接地址指向我(作为管理员)的 wordpress 站点,并指示他们登录 wordpress,而他们显然没有凭据。

  2. Customers are sent various emails about their orders but the order number text contains no link to the order on my site.客户会收到有关他们订单的各种电子邮件,但订单号文本不包含指向我网站上订单的链接。

How can we go about adding the correct link into these emails?我们如何将正确的链接添加到这些电子邮件中? I'm just learning php so skills are very limited.我只是在学习php,所以技能非常有限。

Here's the code for admin-new-order & customer-completed-order:以下是 admin-new-order 和 customer-completed-order 的代码:

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

 /**
  * @hooked WC_Emails::email_header() Output the email header
  */
 do_action( 'woocommerce_email_header', $email_heading, $email ); ?>

 <p><?php printf( __( 'You have received an order from %s. The order is as follows:', 'woocommerce' ), $order->get_formatted_billing_full_name() ); ?></p>

 <?php

 /**


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

/**
 * @hooked WC_Emails::email_header() Output the email header
 */
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>

<p><?php printf( __( "Hi there. Your recent order on %s has been completed. Your order details are shown below for your reference:", 'woocommerce' ), get_option( 'blogname' ) ); ?></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 );

  * @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 );

New order is made for admins or shop managers, that's why the order link is linked to backend order edit pages (only for Admin notifications) .新订单是为管理员或商店经理制作的,这就是订单链接链接到后端订单编辑页面的原因(仅适用于管理员通知)

This order number is located in emails/email-order-details.php订单号位于emails/email-order-details.php

This template can be overridden by copying it to yourtheme/woocommerce/emails/email-order-details.php, see: Template Structure + Overriding Templates via a Theme可以通过将其复制到 yourtheme/woocommerce/emails/email-order-details.php 来覆盖此模板,请参阅:模板结构 + 通过主题覆盖模板

If you want to have a link in customer emails that goes on their my account order view page (and same thing for admin email notifications), you need to replace this:如果您希望在客户电子邮件中有一个链接,该链接会出现在他们的我的帐户订单查看页面上(管理员电子邮件通知也是如此),您需要替换以下内容:

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

$text_align = is_rtl() ? 'right' : 'left';

do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text, $email ); ?>

    <?php if ( ! $sent_to_admin ) : ?>
        <h2><?php printf( __( 'Order #%s', 'woocommerce' ), $order->get_order_number() ); ?></h2>
    <?php else : ?>
        <h2><a class="link" href="<?php echo esc_url( admin_url( 'post.php?post=' . $order->get_id() . '&action=edit' ) ); ?>"><?php printf( __( 'Order #%s', 'woocommerce' ), $order->get_order_number() ); ?></a> (<?php printf( '<time datetime="%s">%s</time>', $order->get_date_created()->format( 'c' ), wc_format_datetime( $order->get_date_created() ) ); ?>)</h2>
    <?php endif; ?>

By this:通过这个:

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

$text_align = is_rtl() ? 'right' : 'left';

do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text, $email ); ?>

<?php if ( ! $sent_to_admin ) : ?>
    <h2><a class="link" href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ) . get_option( 'woocommerce_myaccount_view_order_endpoint' ) . '/' . $order->get_order_number(); ?>"><?php printf( __( 'Order #%s', 'woocommerce' ), $order->get_order_number() ); ?></a></h2>
<?php else : ?>
        <h2><a class="link" href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ) . get_option( 'woocommerce_myaccount_view_order_endpoint' ) . '/' . $order->get_order_number(); ?>"><?php printf( __( 'Order #%s', 'woocommerce' ), $order->get_order_number() ); ?></a> (<?php printf( '<time datetime="%s">%s</time>', $order->get_date_created()->format( 'c' ), wc_format_datetime( $order->get_date_created() ) ); ?>)</h2>
    <?php endif; ?>

Now you will have the order number linked to their corresponding my account / order-view page for all notifications, included the admin email notifications as "New Order"…现在,您将订单号链接到所有通知的相应我的帐户/订单查看页面,包括作为“新订单”的管理员电子邮件通知......


Update related to the comment (for the correct "vendor" path, the replacement will be:与评论相关的更新(对于正确的“供应商”路径,替换将是:

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

$text_align = is_rtl() ? 'right' : 'left';

do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text, $email ); ?>

<?php if ( ! $sent_to_admin ) : ?>
    <h2><a class="link" href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ) . get_option( 'woocommerce_myaccount_view_order_endpoint' ) . '/' . $order->get_order_number(); ?>"><?php printf( __( 'Order #%s', 'woocommerce' ), $order->get_order_number() ); ?></a></h2>
<?php else : ?>
    <h2><a class="link" href="<?php echo home_url( '/' ) . 'dashboard/orders/?order_id=' . $order->get_order_number(); ?>"><?php printf( __( 'Order #%s', 'woocommerce' ), $order->get_order_number() ); ?></a> (<?php printf( '<time datetime="%s">%s</time>', $order->get_date_created()->format( 'c' ), wc_format_datetime( $order->get_date_created() ) ); ?>)</h2>
<?php endif; ?>

暂无
暂无

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

相关问题 重新排列 WooCommerce 电子邮件通知中的订单详细信息总数 - Rearrange order detail totals on WooCommerce email notifications 在 Woocommerce 电子邮件通知中显示订单客户备注 - Display order customer note in Woocommerce email notifications 订单自定义字段未显示在 WooCommerce email 通知上 - Order custom fields not displayed on WooCommerce email notifications 将 Woocommerce 中的“回复”更改为 email header 以获取新订单和发货 Z0C83F57C2386A0BABEB4AZEF9 通知 - Change “reply to” email header in Woocommerce for New Order and shipped email notifications 隐藏WooCommerce电子邮件已完成订单通知中的付款说明 - Hide payment instructions from WooCommerce email completed order notifications WooCommerce:使用自定义 email 通知添加自定义订单状态 - WooCommerce: Add Custom order statuses with custom email notifications 将优惠券代码名称添加到 Woocommerce 查看订单详细信息和电子邮件通知 - Add the Coupon Code names to Woocommerce View Order details and email notifications 在 Woocommerce 电子邮件通知中显示自定义订单状态的付款链接 - Display a payment link for custom order statuses in Woocommerce email notifications "在 Woocommerce 订单电子邮件通知中获取产品名称或 ID" - Get the product name or id in Woocommerce order email notifications 在 WooCommerce email 通知上下载前显示订单详细信息 - Display Order details before downloads on WooCommerce email notifications
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM