Skip to main content
Update title, content improvement, format tags added
Source Link

WooCommerce: display text instead of raw checkbox value in woocommerce email

I have successfully setup some custom fields on checkout and it all works fine. I

I have a checkbox as one of the fields. 'my_gift_wrap_checkbox'
I, my_gift_wrap_checkbox, and I managed to write code to display text in the orders page ('yes please!'yes please!' or 'No thank you''no thank you') instead of a simple blankblank or '1'1 if it is checked or not.
I

I can't figure out how to achieve the same in the email code.
My My code is:

/**
 * Add the field to order emails
 **/
add_filter('woocommerce_email_order_meta_keys', 'my_woocommerce_email_order_meta_keys');

function my_woocommerce_email_order_meta_keys( $keys ) {
    $keys['Gift wrap?'] = 'my_gift_wrap_checkbox';
    $keys['Gift wrap instructions'] = 'my_gift_wrap_field';
    return $keys;
}

` /**Right now:

  • Add the field to order emails **/ add_filter('woocommerce_email_order_meta_keys'If it's checked, 'my_woocommerce_email_order_meta_keys');I get Gift wrap?: 1
  • I want Gift wrap?: Yes please!
  • If it's not checked, it shows Gift wrap?:
  • I want Gift wrap?: No thank you.

function my_woocommerce_email_order_meta_keys( $keys ) { $keys['Gift wrap?'] = 'my_gift_wrap_checkbox'; $keys['Gift wrap instructions'] = 'my_gift_wrap_field'; return $keys; } `

Right now if it is checked I get 'Gift wrap?: 1'
I want 'Gift wrap?: Yes please!'
If not checked it shows 'Gift wrap?:'
I want 'Gift wrap?: No thank you.'

display text instead of raw checkbox value in woocommerce email

I have successfully setup some custom fields on checkout and it all works fine. I have a checkbox as one of the fields. 'my_gift_wrap_checkbox'
I managed to write code to display text in the orders page ('yes please!' or 'No thank you') instead of a simple blank or '1' if it is checked or not.
I can't figure out how to achieve the same in the email code.
My code is

` /**

  • Add the field to order emails **/ add_filter('woocommerce_email_order_meta_keys', 'my_woocommerce_email_order_meta_keys');

function my_woocommerce_email_order_meta_keys( $keys ) { $keys['Gift wrap?'] = 'my_gift_wrap_checkbox'; $keys['Gift wrap instructions'] = 'my_gift_wrap_field'; return $keys; } `

Right now if it is checked I get 'Gift wrap?: 1'
I want 'Gift wrap?: Yes please!'
If not checked it shows 'Gift wrap?:'
I want 'Gift wrap?: No thank you.'

WooCommerce: display text instead of raw checkbox value email

I have successfully setup some custom fields on checkout and it all works fine.

I have a checkbox as one of the fields, my_gift_wrap_checkbox, and I managed to write code to display text in the orders page ('yes please!' or 'no thank you') instead of a simple blank or 1 if it is checked or not.

I can't figure out how to achieve the same in the email code. My code is:

/**
 * Add the field to order emails
 **/
add_filter('woocommerce_email_order_meta_keys', 'my_woocommerce_email_order_meta_keys');

function my_woocommerce_email_order_meta_keys( $keys ) {
    $keys['Gift wrap?'] = 'my_gift_wrap_checkbox';
    $keys['Gift wrap instructions'] = 'my_gift_wrap_field';
    return $keys;
}

Right now:

  • If it's checked, I get Gift wrap?: 1
  • I want Gift wrap?: Yes please!
  • If it's not checked, it shows Gift wrap?:
  • I want Gift wrap?: No thank you.
Source Link

display text instead of raw checkbox value in woocommerce email

I have successfully setup some custom fields on checkout and it all works fine. I have a checkbox as one of the fields. 'my_gift_wrap_checkbox'
I managed to write code to display text in the orders page ('yes please!' or 'No thank you') instead of a simple blank or '1' if it is checked or not.
I can't figure out how to achieve the same in the email code.
My code is

` /**

  • Add the field to order emails **/ add_filter('woocommerce_email_order_meta_keys', 'my_woocommerce_email_order_meta_keys');

function my_woocommerce_email_order_meta_keys( $keys ) { $keys['Gift wrap?'] = 'my_gift_wrap_checkbox'; $keys['Gift wrap instructions'] = 'my_gift_wrap_field'; return $keys; } `

Right now if it is checked I get 'Gift wrap?: 1'
I want 'Gift wrap?: Yes please!'
If not checked it shows 'Gift wrap?:'
I want 'Gift wrap?: No thank you.'