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

时间:2019-03-01 15:48:50

标签: php wordpress if-statement woocommerce orders

我一直在努力使它起作用。我需要在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>'
);

1 个答案:

答案 0 :(得分: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>' );
}

它应该有效(在其中,您将custom-onecustom-two替换为自定义状态标记)