Skip to content

Instantly share code, notes, and snippets.

@kloon
Last active December 23, 2015 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kloon/f09ceecfd96aaa0afcbc to your computer and use it in GitHub Desktop.
Save kloon/f09ceecfd96aaa0afcbc to your computer and use it in GitHub Desktop.
RRP Tutorial - Save Product Field
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' );
}
@rakesh-baikar
Copy link

in which page adding these code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment