Skip to content

Instantly share code, notes, and snippets.

@tareq1988
Created January 6, 2016 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tareq1988/580d47bc2412e43b755f to your computer and use it in GitHub Desktop.
Save tareq1988/580d47bc2412e43b755f to your computer and use it in GitHub Desktop.
WooCommerce price adjustment for WPUF
<?php
/**
* WooCommerce price adjustment for WPUF
*
* @param int $post_id
*
* @return void
*/
function wpufe_update_post_price( $post_id ) {
$regular_price = get_post_meta( $post_id, '_regular_price', true );
$sale_price = get_post_meta( $post_id, '_sale_price', true );
if ( ! empty( $sale_price ) ) {
update_post_meta( $post_id, '_price', $sale_price );
} else {
update_post_meta( $post_id, '_price', $regular_price );
}
}
add_action( 'wpuf_add_post_after_insert', 'wpufe_update_post_price' );
add_action( 'wpuf_edit_post_after_update', 'wpufe_update_post_price' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment