我安装了woocommerce产品附加组件扩展。 (可从woocommerce获得的基本版本)
我有一个附加产品添加到了几种产品中,有人在这些产品中为课程选择“虚拟”或“个人”。
我想根据此值在购物车中显示一条消息。
add_action( 'woocommerce_after_cart_contents', 'check_cart' );
function check_cart() {
$virt = '';
$out = '';
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
//get the value of the add-on and set as $virt
}
if ($virt == 'Virtual') {
$out = 'My Message';
}
return $out;
}