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
add_action('woocommerce_after_order_notes', 'conditional_checkout_field'); |
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>'; | |
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
DELETE FROM wp_options | |
WHERE option_name LIKE '_wc_session_%' OR option_name LIKE '_wc_session_expires_%'; |
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
DELETE FROM wp_options | |
WHERE option_name LIKE '_transient_wc_%' OR option_name LIKE '_transient_timeout_wc_%'; |
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
User-agent: * | |
Disallow: /*add-to-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
/** | |
* Add the field to the checkout page | |
*/ | |
add_action( 'woocommerce_after_order_notes', 'some_custom_checkout_field' ); | |
function some_custom_checkout_field( $checkout ) { | |
echo '<div id="some_custom_checkout_field"><h2>' . __('My Field Header') . '</h2>'; | |
woocommerce_form_field( 'some_field_name', array( |
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 | |
/** | |
* Process the checkout | |
*/ | |
add_action('woocommerce_checkout_process', 'some_custom_checkout_field_process'); | |
function some_custom_checkout_field_process() { | |
// Check if the field is set, if not then show an error message. | |
if ( ! $_POST['some_field_name'] ) | |
wc_add_notice( __( 'Please enter something here.' ), 'error' ); |
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 | |
/** | |
* Update the order meta with field value | |
*/ | |
add_action( 'woocommerce_checkout_update_order_meta', 'some_custom_checkout_field_update_order_meta' ); | |
function some_custom_checkout_field_update_order_meta( $order_id ) { | |
if ( ! empty( $_POST['some_field_name'] ) ) { | |
update_post_meta( $order_id, 'Some Field', sanitize_text_field( $_POST['some_field_name'] ) ); | |
} |
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 | |
/** | |
* Add the field to order emails | |
**/ | |
add_filter( 'woocommerce_email_order_meta_keys', 'some_order_meta_keys' ); | |
function some_order_meta_keys() { | |
if (get_post_meta( get_the_ID(), 'Some Field')) { | |
echo 'This is the custom information you entered in Some Field: ' . get_post_meta( get_the_ID(), 'Some Field', true) . '<br />'; | |
} |
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 | |
// WooCommerce Checkout Fields Hook | |
add_filter( 'woocommerce_checkout_fields' , 'custom_wc_checkout_fields' ); | |
// Change order comments placeholder and label, and set billing phone number to not required. | |
function custom_wc_checkout_fields( $fields ) { | |
$fields['order']['order_comments']['placeholder'] = 'Enter your placeholder text here.'; | |
$fields['order']['order_comments']['label'] = 'Enter your label here.'; | |
$fields['billing']['billing_phone']['required'] = false; | |
return $fields; |
OlderNewer