Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure we avoid an infinite recursive call stack through any price format filter #8634

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fix
Comment: This supplements a previous fix


10 changes: 8 additions & 2 deletions includes/multi-currency/FrontendCurrencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,17 @@ public function init_order_currency( $arg ) {
return $arg;
}

// We remove the filter 'wc_get_price_decimal_separator' here because 'wc_get_order'
// can also trigger it, leading to an infinite recursive call.
// We remove thes filters here because 'wc_get_order'
// can also trigger them, leading to an infinite recursive call.
reykjalin marked this conversation as resolved.
Show resolved Hide resolved
remove_filter( 'woocommerce_price_format', [ $this, 'get_woocommerce_price_format' ], 900 );
remove_filter( 'wc_get_price_thousand_separator', [ $this, 'get_price_thousand_separator' ], 900 );
remove_filter( 'wc_get_price_decimal_separator', [ $this, 'get_price_decimal_separator' ], 900 );
remove_filter( 'wc_get_price_decimals', [ $this, 'get_price_decimals' ], 900 );
$order = ! $arg instanceof WC_Order ? wc_get_order( $arg ) : $arg;
add_filter( 'wc_get_price_decimals', [ $this, 'get_price_decimals' ], 900 );
add_filter( 'wc_get_price_decimal_separator', [ $this, 'get_price_decimal_separator' ], 900 );
add_filter( 'wc_get_price_thousand_separator', [ $this, 'get_price_thousand_separator' ], 900 );
add_filter( 'woocommerce_price_format', [ $this, 'get_woocommerce_price_format' ], 900 );

if ( $order ) {
$this->order_currency = $order->get_currency();
Expand Down
Loading