【问题标题】:Add payment link in WooCommerce customer invoice emails /failed order emails? [duplicate]在 WooCommerce 客户发票电子邮件/订单失败电子邮件中添加付款链接? [复制]
【发布时间】:2020-05-03 17:39:40
【问题描述】:

我最近注意到客户发票电子邮件缺少付款链接。我尝试了各种主题并禁用了所有其他插件,但没有运气。

即使付款失败,以下是全部完成的方式:http://prntscr.com/s9x8o5

我看到客户发票模板http://prntscr.com/s9x902 中的代码似乎是正确的,但由于某种原因无法正常工作。即使订单状态失败,此行也不会显示。

关于如何将付款链接放回那里的任何想法?我在某处缺少设置吗?

【问题讨论】:

  • 尝试下面的代码并相应地更新问题
  • 请检查您的订单状态是否为待处理。 IIRC,付款链接应该显示订单是否处于待处理状态。

标签: wordpress email woocommerce orders


【解决方案1】:

如果对象正确,请尝试在电子邮件顶部打印订单对象。

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

<?php /* translators: %s: Customer first name */ ?>
<p><?php printf( esc_html__( 'Hi %s,', 'woocommerce' ), esc_html( $order->get_billing_first_name() ) ); ?></p>
<?php

echo '<pre>$order:-';
print_r( $order );
echo '</pre>';

?>
<?php if ( $order->has_status( 'pending' ) ) { ?>
    <p>
    <?php
    printf(
        wp_kses(
            /* translators: %1$s Site title, %2$s Order pay link */
            __( 'An order has been created for you on %1$s. Your invoice is below, with a link to make payment when you’re ready: %2$s', 'woocommerce' ),
            array(
                'a' => array(
                    'href' => array(),
                ),
            )
        ),
        esc_html( get_bloginfo( 'name', 'display' ) ),
        '<a href="' . esc_url( $order->get_checkout_payment_url() ) . '">' . esc_html__( 'Pay for this order', 'woocommerce' ) . '</a>'
    );
    ?>
    </p>

<?php } else { ?>
    <p>
    <?php
    /* translators: %s Order date */
    printf( esc_html__( 'Here are the details of your order placed on %s:', 'woocommerce' ), esc_html( wc_format_datetime( $order->get_date_created() ) ) );
    ?>
    </p>
    <?php
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-05-10
    • 2016-10-26
    • 2023-01-16
    • 2017-08-08
    • 2021-10-27
    • 2019-01-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多