Based on my previous question + the answer to the question
How to save from WooCommerce checkout a custom checkbox field state?
I have an additional checkbox on WooCommerce checkout page, but when the order is complete I don't see the additional field on the thankyou page. My checkbox save value 1
or 0
in meta_data
when checkbox is checked or unchecked
$order->update_meta_data( 'ritiro_sede', $value );
I would like to see word SI
if checkbox is checked and word NO
if checkbox is unchecked, but this function not work:
Does anyone have any idea what might be wrong?
add_action( 'woocommerce_thankyou', 'my_custom_checkout_field_display_order_data_ritiro_sede', 10, 1 );
add_action( 'woocommerce_view_order', 'my_custom_checkout_field_display_order_data_ritiro_sede', 10, 1 );
function my_custom_checkout_field_display_order_data_ritiro_sede( $order ){
$ritiro_sede = get_post_meta( $order_id, 'ritiro_sede', true );
if( $ritiro_sede == 1 )
echo '<p><strong>Ritiro In sede: </strong> <span style="color:red;">SI</span></p>';
if( $ritiro_sede == 0 )
echo '<p><strong>Ritiro In sede: </strong> <span style="color:red;">NO</span></p>';
//echo '<p>'. __('Ritiro in Sede: ') . get_post_meta($order->get_id(), 'ritiro_sede', true .'</p');
//echo '<p>'. __('Ritiro in Sede: ','theme_name') . get_value($order->get_the_id(), 'ritiro_sede', true .'</p>');
}
Aucun commentaire:
Enregistrer un commentaire