Last active
August 12, 2026 10:59
-
-
Save rajeshsingh520/4c9afd089154a70d7fbf1f5c0d24969c to your computer and use it in GitHub Desktop.
remvoe decimal
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
| if ( ! function_exists( 'pisol_strip_missing_amount_decimals_20260812' ) ) { | |
| function pisol_strip_missing_amount_decimals_20260812( $html ) { | |
| if ( empty( $html ) ) { | |
| return $html; | |
| } | |
| $result = preg_replace( | |
| '/(<span class="woocommerce-Price-amount amount"><bdi>.*?)\.\d{2}(<\/bdi><\/span>)/s', | |
| '$1$2', | |
| $html | |
| ); | |
| // preg_replace returns null on regex failure — don't let it wipe the message | |
| return $result !== null ? $result : $html; | |
| } | |
| } | |
| add_filter( 'pisol_fsnw_final_ajax_filter', function( $json ) { | |
| foreach ( array( 'message_product', 'message_bar' ) as $key ) { | |
| if ( ! empty( $json[ $key ] ) ) { | |
| $json[ $key ] = pisol_strip_missing_amount_decimals_20260812( $json[ $key ] ); | |
| } | |
| } | |
| return $json; | |
| } ); | |
| add_filter( 'pi_fsnw_cart_checkout_final_message', 'pisol_strip_missing_amount_decimals_20260812' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment