Last active
February 4, 2019 16:47
-
-
Save andykeith/c42e446c4222dec2b11109be1b2cc0f4 to your computer and use it in GitHub Desktop.
WPT - replace sale price with regular price if no sale price set for product
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
<?php | |
// Assuming you have cf:_sale_price as a column in your table... | |
add_filter( 'wc_product_table_data_custom_field__sale_price, function( $price, $product ) { | |
if ( empty( $price ) ) { | |
$price = get_post_meta( $product->get_id(), '_regular_price', true ); | |
} | |
return $price; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment