-
-
Save kloon/f09ceecfd96aaa0afcbc to your computer and use it in GitHub Desktop.
RRP Tutorial - Save Product Field
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
add_action( 'save_post', 'wc_rrp_save_product' ); | |
function wc_rrp_save_product( $product_id ) { | |
// If this is a auto save do nothing, we only save when update button is clicked | |
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) | |
return; | |
if ( isset( $_POST['rrp_price'] ) ) { | |
if ( is_numeric( $_POST['rrp_price'] ) ) | |
update_post_meta( $product_id, 'rrp_price', $_POST['rrp_price'] ); | |
} else delete_post_meta( $product_id, 'rrp_price' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
in which page adding these code