MulticurrencyHooks.php
27 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WCML\Compatibility\GravityForms; |
| 4 | |
| 5 | class MulticurrencyHooks implements \IWPML_Action { |
| 6 | |
| 7 | public function add_hooks() { |
| 8 | add_filter( 'gform_formatted_money', [ $this, 'wcml_convert_price' ], 10, 2 ); |
| 9 | add_filter( 'wcml_multi_currency_ajax_actions', [ $this, 'add_ajax_action' ] ); |
| 10 | } |
| 11 | |
| 12 | public function wcml_convert_price( $formatted, $unformatted ) { |
| 13 | if ( ! is_admin() ) { |
| 14 | $currency = apply_filters( 'wcml_price_currency', wcml_get_woocommerce_currency_option() ); |
| 15 | $formatted = strip_tags( wc_price( apply_filters( 'wcml_raw_price_amount', $unformatted ), [ 'currency' => $currency ] ) ); |
| 16 | } |
| 17 | return $formatted; |
| 18 | } |
| 19 | |
| 20 | public function add_ajax_action( $actions ) { |
| 21 | $actions[] = 'get_updated_price'; |
| 22 | $actions[] = 'gforms_get_updated_price'; |
| 23 | return $actions; |
| 24 | } |
| 25 | |
| 26 | } |
| 27 |