Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andykeith/c42e446c4222dec2b11109be1b2cc0f4 to your computer and use it in GitHub Desktop.
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
<?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