michaellevelup

Custom price HTML

Apr 19th, 2022 (edited)
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.44 KB | None | 0 0
  1. function king_custom_price() {
  2.     global $product;
  3.  
  4.     if ($product->is_on_sale() && is_shop()){
  5.  
  6.         $regular_price = get_post_meta( $product->get_id(), '_regular_price', true );
  7.         $sale_price = get_post_meta( $product->get_id(), '_sale_price', true );
  8.      
  9.         return '<del>from '.$regular_price.'</del><ins> '.$sale_price.'</ins>';
  10.     }
  11. }
  12.  
  13. add_filter( 'woocommerce_format_sale_price', 'king_custom_price', 10, 2 );
Add Comment
Please, Sign In to add comment