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 關注
- 414 瀏覽
添加回答
舉報