【发布时间】:2021-01-08 11:39:33
【问题描述】:
我正在尝试自定义 WooCommerce 通知。 这是我要替换的通知:
wc_add_notice( sprintf( __( '%s has been removed from your cart because it can no longer be purchased. Please contact us if you need assistance.', 'woocommerce' ), $_product->get_title() ), 'error' )
基于这个有用的答案WooCommerce Notice Messages, how do I edit them?,我想出了这个:
function my_woocommerce_membership_notice( $error ) {
if ( '%s has been removed from your cart because it can no longer be purchased. Please contact us if you need assistance.' == $error ) {
$error = '%s has been removed from your cart because you added a membership product. Please complete the membership purchase first.';
}
return $error;
}
add_filter( 'woocommerce_add_error', 'my_woocommerce_membership_notice' );
这会导致 HTTP500 错误,我无法弄清楚究竟是什么原因。
谢谢!
【问题讨论】:
标签: php wordpress woocommerce cart hook-woocommerce