Skip to content

Instantly share code, notes, and snippets.

@corsonr
Created February 18, 2014 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save corsonr/9071214 to your computer and use it in GitHub Desktop.
Save corsonr/9071214 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