mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-29 11:32:21 +08:00
https://stackoverflow.com/questions/79190676/display-a-checkbox-only-for-specific-product-in-woocommerce-cart-page
11 lines
452 B
Text
11 lines
452 B
Text
add_action('woocommerce_proceed_to_checkout', 'cart_disclaimer1_test', 10);
|
|
function cart_disclaimer1_test() {
|
|
// Here, define the targeted product ID
|
|
$targeted_product_id = 121;
|
|
|
|
// Check if the targeted product is in cart
|
|
if ( in_array( $targeted_product_id, array_column( WC()->cart->get_cart(), 'product_id' ) ) ) {
|
|
echo '<input type="checkbox" name="disclaimer1" required />';
|
|
echo '<p>This is a test</p>';
|
|
}
|
|
}
|