If you are looking for the best way to add currency to WooCommerce this quick tutorial will guide you and help you add custom currency to your WooCommerce store.
WooCommerce has a filter that allows you to extend the currency options that are available in your store.
Using a simple code snippet added to your child theme’s functions.php
file or via a plugin you can add currency to WooCommerce.
It is important to remember that you should not add this custom code directly to the WooCommerce parent theme’s functions.php
file since this will be overwritten when an update is done.
Add Currency to WooCommerce
You can add currency to WooCommerce as well as add a currency symbol to WooCommerce using the code snippets below :
/** * Custom currency and the currency symbol */ add_filter( 'woocommerce_currencies', 'njengah_add_my_currency' ); function njengah_add_my_currency( $currencies ) { $currencies['ABC'] = __( 'Currency name', 'woocommerce' ); return $currencies; } add_filter('woocommerce_currency_symbol', 'njengah_add_my_currency_symbol', 10, 2); function njengah_add_my_currency_symbol( $currency_symbol, $currency ) { switch( $currency ) { case 'ABC': $currency_symbol = '$'; break; } return $currency_symbol; }
You should place the code at the end of your child theme functions.php file and ensure that there are no errors.
You should also replace the current name and the symbol in the code to reflect the custom currency that you want to add to WooCommerce.
Conclusion
In this post, we have looked at how you can use a code snippet to add currency to WooCommerce and also a custom currency symbol.
You should be careful when adding this code snippet to your theme to avoid breaking your site. It helps to begin by backing up your site so that you can restore it if something goes wrong.
Joe is an experienced full-stack web developer with a decade of industry experience in the LAMP & MERN stacks, WordPress, WooCommerce, and JavaScript – (diverse portfolio). He has a passion for creating elegant and user-friendly solutions and thrives in collaborative environments. In his spare time, he enjoys exploring new tech trends, tinkering with new tools, and contributing to open-source projects. You can hire me here for your next project.
Similar Articles
- How to Hide Any Tab My Account Page WooCommerce
- How to Simplify Checkout Free Items Storefront Theme
- How to Move Primary Menu Storefront WooCommerce
- 30 Best Download Plugins for WordPress File Sharing & More
- How to Add a Sidebar to WordPress » Ultimate Step-by-Step Guide
- How to Remove Has Been Added to Your Cart Message WooCommerce
- How to Create Checkbox Field in WooCommerce Checkout Page
- How to Add Social Media Icons to Footer Storefront Theme
- How to Redirect User If Not Logged in WordPress » Page Redirect
- How to Setup WooCommerce Storefront Mega Menu
- How to Add Product to Cart Programmatically in WooCommerce
- How to Create Custom Widget Area in WordPress Step by Step
- How to Clear Cart on Logout In WooCommerce
- How to Get Product ID on the Checkout Page Or Order Page In WooCommerce
- How to Get Checkout URL In WooCommerce
- How to Send to Mpesa WooCommerce Payment for Free
- 5+ Best WooCommerce Store Examples
- 40+ Best WordPress Contact Form Plugins for Easy Contact
- 35+ Best Free Form Plugin WordPress
- How to Edit Billing Details WooCommerce Checkout Page
- WooCommerce Redirect After Checkout: Redirect to Custom Thank You Page
- WooCommerce Redirect After Logout [Ultimate Guide]
- 100+ Tips, Tricks & Snippets Ultimate WooCommerce Hide Guide
- How to Change Checkout Endpoints WooCommerce
- WooCommerce Checkout Optimization Quick Guide
- How to Add Text Before the Price in WooCommerce » Add Text Before Price
- How to Hide Unavailable Variations In WooCommerce