1 回答
TA贡献1856条经验 获得超5个赞
这是代码的最终版本,在阅读了上面“7uc1f3r”提供的参考资料之后。谢谢您的帮助。
add_action( 'woocommerce_review_order_before_submit', 'add_custom_checkbox' );
function add_custom_checkbox() {
## ----- CHECK IF CERTAIN PRODUCTS (COULD ALSO BE VARIABLE PRODUCTS) ARE IN CART ----- ##
$product_ids = array (9145, 9151, 9152, 9153, 9155, 9156); // Search for this products (PARENT ID)
// Loop though cart items searching for the defined products
foreach( WC()->cart->get_cart() as $cart_item ) {
// Product id
$product_id = $cart_item['product_id'];
// Display checkbox if product found in cart
if ( in_array( $product_id, $product_ids) ) {
echo add_my_checkout_tickbox();
}
}
}
- 1 回答
- 0 关注
- 373 浏览
添加回答
举报