Skip to content

Instantly share code, notes, and snippets.

@bhavik-kiri
Last active November 6, 2017 02:11
Show Gist options
  • Save bhavik-kiri/58797d0dff1141eed29d3e6ba07248f2 to your computer and use it in GitHub Desktop.
Save bhavik-kiri/58797d0dff1141eed29d3e6ba07248f2 to your computer and use it in GitHub Desktop.
<?php
add_action( 'woocommerce_process_product_meta', 'save_gift_card_options_field' );
function save_gift_card_options_field( $post_id ) {
$enable_gift_card = isset( $_POST['_enable_gift_card'] ) ? 'yes' : 'no';
update_post_meta( $post_id, '_enable_gift_card', $enable_gift_card );
if ( isset( $_POST['_gift_card_price'] ) ) :
update_post_meta( $post_id, '_gift_card_price', sanitize_text_field( $_POST['_gift_card_price'] ) );
endif;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment