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

问题描述:

我使用Dokan并启动并运行,但与Woocommerce的股票电子邮件模板有几个问题。链接Dokan Woocommerce电子邮件通知的订单号码

  1. 在新的订单邮件上,订单号也是一个链接。理想情况下,这将与他们在Dokan的订单相关联。但是,链接地址是我的(作为管理员)WordPress的网站,并指示他们登录到wordpress,他们显然没有凭据。

  2. 向客户发送有关其订单的各种电子邮件,但订单号文本不包含指向我网站订单的链接。

我们如何才能在这些电子邮件中添加正确的链接?我只是学习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(__('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); 

新秩序是管理员或商店经理女佣,这就是为什么顺序链接连接到后端订单编辑页面(仅限管理员通知)

订单号位于emails/email-order-details.php

这个模板可以通过复制它yourtheme/woocommerce /电子邮件/电子邮件阶details.php被覆盖,请参阅:Template Structure + Overriding Templates via a Theme

如果您想要在我的帐户订单查看页面上显示客户电子邮件中的链接(以及管理员电子邮件通知的相同内容),则需要将其替换为:

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; ?> 

通过这样的:

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; ?> 

现在你将有链接到其相应的帐户/订单查看页面的所有通知的订单号,包括管理员电子邮件通知作为“新秩序“......


相关评论(正确的更新‘供应商’的路径,替换将是:

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; ?> 
+0

这对客户来说非常适合。但是,供应商的链接无效。也许只要简单地链接到他们的主订单页面,即https://yodega.com/dashboard/orders/就可以工作。这会很简单吗?非常感谢!!作为参考,订单的URL(供应商)如下所示:https://yodega.com/dashboard/orders/?order_id=637&_wpnonce=5228c29520。指向特定订单的链接会很好。再次谢谢你。 –