-
-
Save nayemDevs/22541e4aeefb8f80e96a to your computer and use it in GitHub Desktop.
WooCommerce price adjustment for WPUF
This file contains hidden or 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
<?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