Skip to content

Instantly share code, notes, and snippets.

@nayemDevs
Forked from tareq1988/wpuf-woo-price.php
Created January 6, 2016 13:23
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 nayemDevs/22541e4aeefb8f80e96a to your computer and use it in GitHub Desktop.
Save nayemDevs/22541e4aeefb8f80e96a 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