私はWooCommerce通知をカスタマイズしようとしています。この便利な答えWooCommerce Notice Messages, how do I edit them?に基づいて add_filterフックで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')
が、私はこの思い付いた: これは私が交換するためにしようとしているの通知である
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エラーになり、私は把握することはできませんなぜ正確に。
ありがとうございます!