Skip to content

Commit

Permalink
fix currency check
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidsector9 committed Feb 27, 2024
1 parent c7c9967 commit ab4d4b4
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions includes/class-wc-gateway-payfast.php
Original file line number Diff line number Diff line change
Expand Up @@ -1819,20 +1819,18 @@ public function filter_currency( $currency ) {

// Check if the currency is set in the URL.
if ( isset( $_GET['currency'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$currency_code = array(
sanitize_text_field(
wp_unslash( $_GET['currency'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
),
$currency_code = sanitize_text_field(
wp_unslash( $_GET['currency'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
);
// Check if the currency is set in the session (for logged-out users).
} elseif ( 0 === $user_id && WC()->session ) {
$currency_code = WC()->session->get( \WCPay\MultiCurrency\MultiCurrency::CURRENCY_SESSION_KEY );
// Check if the currency is set in the user meta (for logged-in users).
} elseif ( $user_id ) {
$currency_code = get_user_meta( $user_id, \WCPay\MultiCurrency\MultiCurrency::CURRENCY_META_KEY );
$currency_code = get_user_meta( $user_id, \WCPay\MultiCurrency\MultiCurrency::CURRENCY_META_KEY, true );
}

if ( is_array( $currency_code ) && in_array( 'ZAR', $currency_code, true ) ) {
if ( is_string( $currency_code ) && 'ZAR' === $currency_code ) {
return 'ZAR';
}

Expand Down

0 comments on commit ab4d4b4

Please sign in to comment.