在Woocommerce电子邮件通知中显示自定义订单状态的付款链接

问题描述 投票:1回答:1

我一直在努力让这个工作起来。我需要在我的woocommerce电子邮件中显示此付款链接,但仅限于某些(自定义)订单状态。怎么做?谢谢 :)

    printf(
    wp_kses(
        /* translators: %1s item is the name of the site, %2s is a html link */
        __( '%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__( 'Click here to pay for this order', 'woocommerce' ) . '</a>'
);
php wordpress if-statement woocommerce orders
1个回答
1
投票

您将使用WC_Order方法get_status(),例如:

if( in_array( $order->get_status(), array( 'custom-one', 'custom-two') ) ) {
    printf( wp_kses(
        /* translators: %1s item is the name of the site, %2s is a html link */
        __( '%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__( 'Click here to pay for this order', 'woocommerce' ) . '</a>' );
}

它应该工作(你将用你的自定义状态slugs替换custom-onecustom-two

© www.soinside.com 2019 - 2024. All rights reserved.