Advertisement
claudiosanches

WooCommerce - Show discount on single product page

Jun 25th, 2015
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.48 KB | None | 0 0
  1. // This code works fine for single products.
  2. function my_custom_wc_single_price_discount() {
  3.     global $product;
  4.  
  5.     $discount  = 10; // 10% off
  6.     $price     = $product->get_price();
  7.     $new_price = $price - ( $product->get_price() / 100 ) * $discount;
  8.  
  9.     echo '<p>' . sprintf( __( '<strong>%s</strong> (%s de desconto) no boleto bancário.' ), wc_price( $new_price ), $discount . '%' ) . '</p>';
  10. }
  11.  
  12. add_action( 'woocommerce_single_product_summary', 'my_custom_wc_single_price_discount', 11 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement