Last active
November 12, 2025 13:30
-
-
Save sholex/4064fc2b656c0857a78228cf5324b370 to your computer and use it in GitHub Desktop.
Revisions
-
sholex renamed this gist
Jul 2, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
sholex created this gist
Jun 15, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ <?php /** * Single Product Sale Flash * * This template can be overridden by copying it to yourtheme/woocommerce/single-product/sale-flash.php. * * HOWEVER, on occasion WooCommerce will need to update template files and you * (the theme developer) will need to copy the new files to your theme to * maintain compatibility. We try to do this as little as possible, but it does * happen. When this occurs the version of the template file will be bumped and * the readme will list any important changes. * * @see https://docs.woocommerce.com/document/template-structure/ * @author WooThemes * @package WooCommerce/Templates * @version 1.6.4 */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } global $post, $product; ?> <?php if ( $product->is_on_sale() ) : ?> <?php if ($product->is_type( 'simple' )) { $sale_price = $product->get_sale_price(); $regular_price = $product->get_regular_price(); } elseif($product->is_type('variable')){ $sale_price = $product->get_variation_sale_price( 'min', true ); $regular_price = $product->get_variation_regular_price( 'max', true ); } $discount = round (($sale_price / $regular_price -1 ) * 100); ?> <?php echo apply_filters( 'woocommerce_sale_flash', '<span class="onsale-icon"> ' . $discount . ' %</span>', $post, $product ); ?> <?php endif; /* Omit closing PHP tag at the end of PHP files to avoid "headers already sent" issues. */