Created
February 18, 2014 13:42
-
-
Save corsonr/9071214 to your computer and use it in GitHub Desktop.
WooCommerce - Store terms and conditions value within the database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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