CopyPastor

Detecting plagiarism made easy.

Score: 0.7897248268127441; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2019-01-03
by Dipak384

Original Post

Original - Posted on 2016-12-02
by omukiguy



            
Present in both answers; Present only in the new answer; Present only in the old answer;

You should use 'My Field' instead of my_field. As you have saved the custom field with this key. This will definitely solve your problem.
add_filter('woocommerce_email_order_meta_keys', 'my_custom_checkout_field_order_meta_keys'); function my_custom_checkout_field_order_meta_keys( $keys ) { $keys[] = '_my_field'; return $keys; }
add_filter( 'woocommerce_checkout_fields' , 'brown_remove_billing_postcode_checkout' );
function brown_remove_billing_postcode_checkout( $fields ) {
// Add New Fields $fields['billing']['billing_delivery_date'] = array( 'label' => __('Delivery Date', 'woocommerce'), 'placeholder' => _x('yyyy-mm-dd', 'placeholder', 'woocommerce'), 'required' => true, 'class' => array('form-row-wide'), 'clear' => true, 'autocomplete' => false );
//Update the order meta with field value. Don't miss the underscore before _b $fields['billing_delivery_date'] = get_post_meta( $order->id, '_billing_delivery_date', true );
return $fields; }
You need to add to your functions.php
add_filter('woocommerce_email_order_meta_keys', 'my_woocommerce_email_order_meta_keys');
function my_woocommerce_email_order_meta_keys( $keys ) { $keys['Delivery Date'] = '_billing_delivery_date'; return $keys; }
I hope this is helps you.
Thank you.

I had similar trouble of printing the result until I added an underscore before 'my_field'.
So use
add_filter('woocommerce_email_order_meta_keys', 'my_custom_checkout_field_order_meta_keys'); function my_custom_checkout_field_order_meta_keys( $keys ) { $keys[] = '_my_field'; return $keys; }
it seems when woocommerce is querying the meta data for use in admin section, an underscore is added. So for a field you created as
add_filter( 'woocommerce_checkout_fields' , 'brown_remove_billing_postcode_checkout' ); function brown_remove_billing_postcode_checkout( $fields ) { // Add New Fields $fields['billing']['billing_delivery_date'] = array( 'label' => __('Delivery Date', 'woocommerce'), 'placeholder' => _x('yyyy-mm-dd', 'placeholder', 'woocommerce'), 'required' => true, 'class' => array('form-row-wide'), 'clear' => true, 'autocomplete' => false );
//Update the order meta with field value. Don't miss the underscore before _b $fields['billing_delivery_date'] = get_post_meta( $order->id, '_billing_delivery_date', true ); return $fields; } You need to add to your functions.php
/*---------------------------------------------- Add Delivery Date Field to the order emails -------------------------------------------------*/ add_filter('woocommerce_email_order_meta_keys', 'my_woocommerce_email_order_meta_keys'); function my_woocommerce_email_order_meta_keys( $keys ) { $keys['Delivery Date'] = '_billing_delivery_date'; return $keys; }


        
Present in both answers; Present only in the new answer; Present only in the old answer;