Created
September 17, 2025 04:43
-
-
Save shameemreza/a664a4c016e9bf0fabd89dfaaff9ce99 to your computer and use it in GitHub Desktop.
Forces the currency symbol to display before the price and applies CSS to ensure consistent left alignment across all price contexts (cart, checkout, product pages, mini cart).
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 characters
| /** | |
| * Add this code to your theme's functions.php file | |
| * or use a code snippets plugin | |
| * | |
| * This fixes the currency symbol positioning for WooCommerce on RTL sites | |
| */ | |
| // Fix WooCommerce currency position for RTL sites | |
| add_filter( 'woocommerce_price_format', function( $format, $currency_pos ) { | |
| // Only apply to RTL sites with ILS currency | |
| if ( is_rtl() && 'ILS' === get_woocommerce_currency() ) { | |
| // Force currency before price | |
| switch ( $currency_pos ) { | |
| case 'left': | |
| return '%1$s%2$s'; | |
| case 'right': | |
| return '%1$s%2$s'; // Force left even when set to right | |
| case 'left_space': | |
| return '%1$s %2$s'; | |
| case 'right_space': | |
| return '%1$s %2$s'; // Force left with space | |
| default: | |
| return '%1$s%2$s'; | |
| } | |
| } | |
| return $format; | |
| }, 999, 2 ); | |
| // Add CSS to fix display | |
| add_action( 'wp_head', function() { | |
| if ( is_rtl() ) { | |
| ?> | |
| <style> | |
| /* Fix WooCommerce price display for RTL */ | |
| .woocommerce-Price-amount, | |
| .woocommerce-Price-amount bdi, | |
| .amount, | |
| .price, | |
| .price bdi { | |
| direction: ltr !important; | |
| display: inline-block !important; | |
| unicode-bidi: embed !important; | |
| } | |
| /* Ensure currency symbol stays on the left */ | |
| .woocommerce-Price-currencySymbol { | |
| unicode-bidi: embed !important; | |
| margin-inline-end: 2px !important; | |
| margin-inline-start: 0 !important; | |
| } | |
| /* Fix for all price contexts */ | |
| .woocommerce ul.products li.product .price, | |
| .woocommerce div.product p.price, | |
| .woocommerce div.product span.price, | |
| .woocommerce-cart .product-price, | |
| .woocommerce-checkout .product-total, | |
| .woocommerce-mini-cart .amount, | |
| .price del, | |
| .price ins { | |
| direction: ltr !important; | |
| unicode-bidi: embed !important; | |
| } | |
| </style> | |
| <?php | |
| } | |
| }, 999 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment