0
同様の質問がありましたが、代わりに特定の出荷クラスでこのコードを実装したいと考えています。ここでは、コードは次のようになります。特定の出荷クラスに基づくWooCommerceチェックアウトメッセージ
add_action('woocommerce_after_checkout_form', 'allclean_add_checkout_content', 12);
function allclean_add_checkout_content() {
// set your special category name, slug or ID here:
$special_cat = 'special_category';
$bool = false;
foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) {
$item = $cart_item['data'];
if (has_term($special_cat, 'product_cat', $item->id))
$bool = true;
}
// If the special cat is detected in one items of the cart
// It displays the message
if ($bool)
echo '<div class="checkoutdisc">This is Your custom message displayed.</div>';