Hi
I have added a function to show “You Save XX %” below sale price of the product.
function ts_you_save() {
global $product;
if( $product->is_type('simple') || $product->is_type('external') || $product->is_type('grouped') ) {
$regular_price = get_post_meta( $product->get_id(), '_regular_price', true );
$sale_price = get_post_meta( $product->get_id(), '_sale_price', true );
if( !empty($sale_price) ) {
$amount_saved = $regular_price - $sale_price;
$currency_symbol = get_woocommerce_currency_symbol();
$percentage = round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
?>
<p style="font-size:16px;color:red;"><b>Extra <?php echo number_format($percentage,0, '', '').'% Off'; ?></b></p>
<?php
}
}
}
add_action( 'woocommerce_single_product_summary', 'ts_you_save', 11 );
But it shows only on single product page.
Can you please tell me how can I show it on product archive (shop) page on grid and list view also. I have used code snippets plugin to add the function.
Also as you can see in the screenshot, the “add to cart” and “buy now” buttons have different width. Can you please give me a code to make width of 300 px for both buttons.