如果用户选择了信用卡支付方式,点击[下单],跳转到银行网站,点击[取消],又跳回到WooCommerce感谢页面,我该如何显示一些自定义的错误信息?
WooCommerce感谢页面模板代码总结如下(以防我知道如何在我的子主题中添加自定义WooCommerce模板):
if ( $order ) : ?>
<?php if ( $order->has_status( 'failed' ) ) : ?>
<p><?php _e( 'Unfortunately your order cannot be processed as the originating bank/merchant has declined your transaction.', 'woocommerce' ); ?></p>
<?php else : ?>
<p><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', __( 'Thank you. Your order has been received.', 'woocommerce' ), $order ); ?></p>
<?php endif; ?>
<?php do_action( 'woocommerce_thankyou_' . $order->payment_method, $order->id ); ?>
<?php do_action( 'woocommerce_thankyou', $order->id ); ?>
<?php else : ?>
<p><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', __( 'Thank you. Your order has been received.', 'woocommerce' ), null ); ?></p>
<?php endif; ?>银行取消支付案例在此代码中位于何处?如何显示“您取消了银行付款,您的订单已取消”这样的自定义消息?
发布于 2015-06-29 03:40:04
function wdm_my_custom_message( $order_id ){
global $woocommerce;
$order=new WC_Order($order_id);
if ( $order->has_status( 'failed' ) ) {
$woocommerce->add_error( __( 'you cancelled bank payment, your order has been cancelled.', 'woocommerce' ) );
}
}
add_action( 'woocommerce_thankyou','wdm_my_custom_message',10,1);这将帮助你实现你的目标。
https://stackoverflow.com/questions/31088529
复制相似问题