The Importance of Customizing Currency Symbols
For some reason wanting to add custom currency symbols to your WooCommerce store might be:
1. Make e-commerce more diversified by offering multiple currency options to users.
2. Display product prices in the customer's local currency to increase intimacy and enhance the shopping experience.
3. Customers can easily choose their preferred currency, simplifying the shopping process.
4. Increased conversion rates.
5. Not having to worry about currency exchange, expanding store coverage and entering new markets.
![图片[1]-如何在 WooCommerce 中添加自定义货币符号和货币](https://www.361sale.com/wp-content/uploads/2024/12/20241225152949624-image.png)
Adding Custom Currencies in WooCommerce
You can add custom currencies and their symbols to your WooCommerce store by following these steps:
1. Go to the WordPress site WooCommerce Dashboard > AppearanceThe
![图片[2]-如何在 WooCommerce 中添加自定义货币符号和货币](https://www.361sale.com/wp-content/uploads/2024/12/20241225153242278-image.png)
2. Select "Theme File Editor".
![图片[3]-如何在 WooCommerce 中添加自定义货币符号和货币](https://www.361sale.com/wp-content/uploads/2024/12/20241225153247566-image.png)
3. Open the functions.php
fileThe
![图片[4]-如何在 WooCommerce 中添加自定义货币符号和货币](https://www.361sale.com/wp-content/uploads/2024/12/20241225153256817-image.png)
4. Add the following code snippet to the end of the file and save the file.
add_filter( 'woocommerce_currencies', 'add_cw_currency' );
function add_cw_currency( $cw_currency ) {
$cw_currency['CW'] = __( 'CW', 'woocommerce' ); }
return $cw_currency;
}
add_filter('woocommerce_currency_symbol', 'add_cw_currency_symbol', 10, 2);
function add_cw_currency_symbol( $custom_currency_symbol, $custom_currency ) {
switch( $custom_currency ) {
case 'CW': $custom_currency_symbol = 'CW$'; break;
}
return $custom_currency_symbol; }
}
take note of: See this section for an explanation of the code.
Go to the WordPress dashboard. Find the WooCommerce tab and click "Settings"The
![图片[5]-如何在 WooCommerce 中添加自定义货币符号和货币](https://www.361sale.com/wp-content/uploads/2024/12/20241225153310454-image.png)
In "Currency options"Under click on "currency" drop-down menu, you will see the newly added custom currency appear at the end of the drop-down menu.
![图片[6]-如何在 WooCommerce 中添加自定义货币符号和货币](https://www.361sale.com/wp-content/uploads/2024/12/20241225152841400-image.png)
From here, select the newly added currency and save the settings.
Validating Custom Code in WooCommerce
Here is a code breakdown of what we used in the above steps. The following function is used to add a custom currency:
add_filter( 'woocommerce_currencies', 'add_cw_currency' );
function add_cw_currency( $cw_currency ) {
$cw_currency['CY'] = __( 'CY CURRENCY', 'woocommerce' ); }
return $cw_currency;
}
I created a custom currency ofCW, which is shown on the back end.
The following function adds the currency symbol. I used theCW$as a currency symbol.
![图片[7]-如何在 WooCommerce 中添加自定义货币符号和货币](https://www.361sale.com/wp-content/uploads/2024/12/20241225153433476-image.png)
Go to the front end of the site and refresh the page.
You will be able to see the newly added custom currency displayed on the product page.
![图片[8]-如何在 WooCommerce 中添加自定义货币符号和货币](https://www.361sale.com/wp-content/uploads/2024/12/20241225153525432-image.png)
summarize
This tutorial lists the steps to add custom currencies and symbols to WooCommerce. The process is so simple that even newbies can follow the steps to add custom currencies and their symbols to their e-commerce site.
Link to this article:https://www.361sale.com/en/31831The article is copyrighted and must be reproduced with attribution.
No comments