Last active
August 29, 2015 14:27
-
-
Save ScottDeLuzio/37488af5ede56ffc24e4 to your computer and use it in GitHub Desktop.
Check if product is in cart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function conditional_checkout_field( $checkout ) { | |
echo '<div id="conditional_checkout_field">'; | |
$check_in_cart = conditional_product_in_cart(xxxx); //replace xxxx with the product id | |
// Check if the product is in the cart and show the custom fields if it is | |
if ($check_in_cart === true ) { | |
echo '<h2>'.__('My Custom Checkout Field').'</h2>'; | |
woocommerce_form_field( 'custom_field', array( | |
'type' => 'text', | |
'class' => array('my-field-class form-row-wide'), | |
'label' => __('Label for my Custom Field'), | |
'placeholder' => __('Placeholder to help describe what you are looking for'), | |
), $checkout->get_value( 'custom_field' )); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment