0
私はかなり新しいPHPです。 WooCommerceを使用してWordpressサイトで作業しています。 「$ 400以上のご注文で送料を無料にしてください...」と表示された通知を追加しましたが、アイテムが削除されたりカートに追加されたりすると複数回表示されます。一度しか表示されないようにしたいと思います。 は、ここに私のコードです:WooCommerce通知、一度だけ実行する
あなたは、関数sp_custom_noticeに追加するアクションfunction sp_custom_notice() {
if (! is_cart()) {
return;
}
$subtotal = WC()->cart->get_cart_subtotal();
$free_shipping_threshold = 400;
$notice_freeship = wc_add_notice('Get FREE shipping on orders over $400. Only valid in the US, not valid on bullets. <a href="https://bulletcentral.com/shipping/#promo">For more information, click here</a>', 'notice');
if ($subtotal < $free_shipping_threshold) {
return $notice_freeship;
}
}