WooCommerce Change Currency Symbol

Currency Symbol

Quite a lot country currency is $ (Dollar). When setup WooCommerce, some business owners will setup the currency which is $, it’s quite complicated when customer confuse about $ is belong to United States Dollar, Australian Dollar, Hong Kong Dollar, Singapore Dollar or others?

HTML Number

According ASCII-CODE website, HTML Number of $ is [ $ ]. So we need use $ for the symbol of dollar.
Dollar Symbol HTML Number

WooCommerce Change Currency Symbol

For example, we want change the currency symbol of Singapore Dollar $ to S$, what we need is add the coding below to functions.php

// Change Currency Symbol
add_filter( 'woocommerce_currency_symbol', 'change_currency_symbol', 10, 2 );
function change_currency_symbol( $symbols, $currency ) {
	if ( 'SGD' === $currency ) {
		return 'S$';
	}
        return $symbols;
}

Result:
Cart After Change Currency Symbol

WooCommerce Change Currency Symbol
Please do hesitate to contact me if you found out any mistake or typo.

WooCommerce Remove Sidebar

Remove Sidebar

This is a snippet to remove all WooCommerce page sidebar. By this snippet, it will only remove the sidebar. You still need to edit style.css to set the width of main to 100%. This is a method using hook instead of edit the template file.

Paste below coding at your theme’s function.php

//WooCommerce Remove Sidebar 
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );

Now, sidebar at all WooCommerce is been removed. You also need to add this coding to your child theme style.css. Some themes are not working. You need to find out the div class or id to set.

Paste below coding at your theme’s style.css

/* WooCommerce Remove Sidebar, Main Width 100% */
.tax-product_cat #main {
	width: 100%;
} 

For sure, you may leave a comment so that we could discuss about how to edit the css of your WordPress theme if you can’t set the main width successful.

WooCommerce Remove Sidebar
Please do hesitate to contact me if you found out any mistake or typo.

WooCommerce Show Product Total Quantity

Product Total Quantity

If customers add quite a lot products to cart, when they view the cart, they are difficult to find out total how many they added to cart.

Or, if there is a situation: Purchase any product, get 20% discount if more than 100 pieces. Customers need to know how many they have added to cart.

Here is the coding to show total how many products added to cart:

<?php global $woocommerce; ?>
<?php echo sprintf(_n('%d', '%d', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);?>

I added the coding before Cart Subtotal, you may add to any place you want.

<tr class="cart-subtotal">
	<th><?php _e( 'Product Quantity', 'woocommerce' ); ?></th>
	<td><?php global $woocommerce; ?><?php echo sprintf(_n('%d', '%d', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);?></td>
</tr>

Show in Cart Page

To show the total quantity in cart page, you need to copy /plugins/woocommerce/templates/cart/cart-totals.php to your child theme /woocommerce/cart/ to prevent any error.

Result:
WooCommerce Show Product Total Quantity

Show in Checkout Page

To show the total quantity in checkout page, you need to copy /plugins/woocommerce/templates/checkout/review-order.php to your child theme /woocommerce/checkout/ to prevent any error.

Result:
WooCommerce Show Product Total Quantity Checkout Page

External Link: WooCommerce – Show number of items in cart and total

WooCommerce Show Product Total Quantity
Please do hesitate to contact me if you found out any mistake or typo.

WooCommerce Show Save How Many Percentage

With WooCommerce Snippet

When using WooCommerce, some users would like to set the item with a sale price. Default WooCommerce just strikethrough the regular price and show only sale price. Customers don’t know how many actually they save. With this WooCommerce snippet, it will show how many percentage they sale from a regular price.

Paste below coding at your theme’s function.php

<?php
add_filter( 'woocommerce_sale_price_html', 'woocommerce_sales_price_percentage', 10, 2 );
function woocommerce_sales_price_percentage( $price, $product ) {
	$percentage = round( ( ( $product->regular_price - $product->sale_price ) / $product->regular_price ) * 100 );
	return $price . sprintf( __(' - Save %s', 'woocommerce' ), $percentage . '%' );
}
?>

Result:
WooCommerce Show Save How Many Percentage

Show Percentage Is More Attractive

Now, the percentage of discount is displayed next to sale price. Customers able to know how many actually they save from a regular price. With percentage of discount, it’s more attractive!

External Link: WooCommerce Percentage Saved Sale Price

WooCommerce Show Save How Many Percentage
Please do hesitate to contact me if you found out any mistake or typo.