Skip to content

Instantly share code, notes, and snippets.

@lmartins
Forked from corsonr/gist:9071214
Created October 8, 2014 07:43
Show Gist options
  • Save lmartins/04f81dbad4246fd49d1e to your computer and use it in GitHub Desktop.
Save lmartins/04f81dbad4246fd49d1e to your computer and use it in GitHub Desktop.
WooCommerce - Store terms and conditions value within the database
<?php
/**
* Store terms and conditions value within the database
**/
add_action('woocommerce_checkout_update_order_meta', 'woo_save_terms_and_conditions_status');
function woo_save_terms_and_conditions_status( $order_id ) {
if ($_POST['terms']) update_post_meta( $order_id, '_terms', esc_attr($_POST['terms']));
}
add_action( 'woocommerce_admin_order_data_after_billing_address', 'woo_display_terms_and_conditions_status', 10, 1 );
function woo_display_terms_and_conditions_status($order){
$terms = get_post_meta( $order->id, '_terms', true );
$terms_status = ( $terms == 'on' ? __('accepted') : __('undefined') );
echo '<p><strong>'.__('Terms & conditions').':</strong> ' . $terms_status . '</p>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment