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

Release branch for 6.7.0 #7576

Merged
merged 64 commits into from
Nov 1, 2023
Merged
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
0620455
Add shopper Tracks events (#7268)
malithsen Oct 9, 2023
1f62d42
Add Reporting Authorization API endpoint (#7066)
jessy-p Oct 10, 2023
c1ae189
Fix for issue during plugin update (#7447)
jessy-p Oct 10, 2023
cea60b3
Expose `is_account_partially_onboarded` to be used in WC Core (#7443)
ismaeldcom Oct 11, 2023
28df3ba
Add additional security checks (#7442)
oaratovskyi Oct 11, 2023
e115e39
Fixed the version check regex to allow major versions > 9 (#7352)
leonardola Oct 11, 2023
6333378
Now the setup intents ids are no more a link to the transaction page …
leonardola Oct 11, 2023
163b122
Disable WooPay first party auth when using adapted extensions (#7455)
bborman22 Oct 11, 2023
a4cded7
Merge trunk v6.6.0 into develop
botwoo Oct 11, 2023
8f59c78
Remove 'dispute' from possible value of ParentSegment in `details-lin…
shendy-a8c Oct 12, 2023
4888842
Rename dispute action from `acceptTransactionDetailsDispute()` to `ac…
shendy-a8c Oct 12, 2023
2a43c37
Temporarily use WC 7.7 in the E2E tests wcpay-subscriptions tests mat…
Oct 12, 2023
c8ad2ae
Added coding standard for ordering of methods (#7444)
jessy-p Oct 12, 2023
bc7831f
Skip two E2E tests related to Order Status change (#7467)
Oct 12, 2023
f1a2d7c
Update dispute challenge/accept e2e tests to match changes to transac…
Jinksi Oct 12, 2023
f26f20c
fix: WooPay 'Save my info' spacing (#7405)
frosso Oct 13, 2023
8c91c9d
Prevent access to settings for partially onboarded accounts (#7470)
ismaeldcom Oct 13, 2023
2510138
Fix Multi-Currency formatting on My Account > Orders page (#7454)
jessepearson Oct 13, 2023
35f172b
Show/hide WooPay checkout page tooltip on click (#7434)
LCmry Oct 13, 2023
edd225a
Unskip merchant e2e tests (#7334)
mgascam Oct 16, 2023
058036b
Skip merchant dispute e2e tests failing on WC 7.7 (#7486)
Jinksi Oct 16, 2023
8c50941
feat: WooPay button SSR (#7463)
frosso Oct 16, 2023
359ea90
Prevent deleting wrong order in the duplicate payment prevention serv…
gpressutto5 Oct 16, 2023
4ea6a98
Enables deferred intent UPE for existing legacy card stores (#7328)
timur27 Oct 16, 2023
2879907
Add WooPay button location option (#7431)
mdmoore Oct 17, 2023
cda96eb
Add feature flag check to early WooPay session request (#7459)
bborman22 Oct 18, 2023
1417f14
Adding Internal Logger (#7462)
jessy-p Oct 18, 2023
2893eb1
Fix Documents page loading on WooCommerce 8.2.0 (#7484)
jessepearson Oct 19, 2023
531df4e
Deprecate Sofort (#7480)
dmallory42 Oct 19, 2023
9b5108e
chore: php 8.1 compatibility (#7491)
frosso Oct 19, 2023
c7b5b93
Merge trunk v6.1.1 into develop
frosso Oct 19, 2023
a8b5c3c
Add IE, DK, FI, NO, and SE to Klarna (#7518)
KarlisJ Oct 20, 2023
cdb317b
Merge trunk v6.6.2 into develop
RadoslavGeorgiev Oct 20, 2023
a49b5ce
Gracefully handle absence of wc parameter when accessing configs (#7501)
malithsen Oct 20, 2023
dec5477
Multicurrency: Do not modify deposit percentage for display. (#7247)
peterwilsoncc Oct 23, 2023
dd30c93
Add AuthorizationRequired State (#7471)
zmaglica Oct 23, 2023
0e2fe50
Merge trunk PR 7532 into develop
htdat Oct 24, 2023
3c4b117
Fix - HPOS compatibility on Edit Order Screen (#7527)
jessy-p Oct 24, 2023
21505c2
Fix dispute e2e tests for WC 7.7 (#7493)
Jinksi Oct 25, 2023
ef6e551
Show a loading UI when accepting a dispute is in progress (#7476)
Jinksi Oct 25, 2023
6ba3d6d
misc: align deferred intent UPE checkout script with previous UPE ver…
timur27 Oct 25, 2023
76caedf
Fixed tooltip alignment in mobile settings view (#7515)
naman03malhotra Oct 25, 2023
98ed205
Add clear both to payment request button wrapper (#7550)
bborman22 Oct 25, 2023
d22c2ce
Fix PO Notice not appearing when adding APMs (#7552)
dmallory42 Oct 25, 2023
77b3acd
RPP: Add order meta upon the AuthenticationRequired state (#7540)
RadoslavGeorgiev Oct 25, 2023
ea53700
Fix Afterpay checkout error when shipping information is missing (#7541)
mgascam Oct 26, 2023
bb99f81
Fix date type in create payment intent response schema (#7534)
dpaun1985 Oct 26, 2023
a2c7b66
Added documentation for report API (#7320)
zmaglica Oct 26, 2023
641fb60
Add a Track event to the Pay For Order page (#7538)
malithsen Oct 26, 2023
34c0175
Remove redundant OTP events (#7542)
malithsen Oct 26, 2023
8e23b57
RPP - Connect the duplicate payment prevention service (Verification)…
htdat Oct 26, 2023
84bfd68
Use template type for StateFactory methods to assist IDEs better. (#7…
htdat Oct 26, 2023
92525c2
Activate fraud services pre WPCOM/Jetpack connection and account onbo…
vladolaru Oct 26, 2023
1dce102
Capital loans page broken on WooCommerce 8.2 (#7569)
brucealdridge Oct 27, 2023
5db6191
RPP - Add phone number check (#7547)
htdat Oct 27, 2023
48dee39
Update `subscriptions-core` to 6.4.0 (#7533)
mattallan Oct 27, 2023
9df23da
Fix display style of additional thank-you order-received text in Woo …
htdat Oct 27, 2023
a08754d
RPP / Add 100% unit test coverage requirement for src (#7510)
RadoslavGeorgiev Oct 27, 2023
2ab6eda
Unify payment method icon design (#7560)
KarlisJ Oct 27, 2023
0ca183e
Revert option renaming in settings controller (#7565)
mdmoore Oct 27, 2023
4343355
Update Checkout appearance section to display WooPay checkout preview…
lovo-h Oct 27, 2023
162bb1f
Update version and add changelog entries for release 6.7.0
github-actions[bot] Oct 29, 2023
070b912
Bump WC and WP tested up to versions to 8.2.0 and 6.3 (#7580)
malithsen Oct 30, 2023
a59400c
Amend changelog entries for release 6.7.0
botwoo Oct 30, 2023
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
Prev Previous commit
Next Next commit
Fix Multi-Currency formatting on My Account > Orders page (#7454)
  • Loading branch information
jessepearson authored Oct 13, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 2510138329dadaecc1f9a7ed78fa6d062150d28b
4 changes: 4 additions & 0 deletions changelog/fix-7409-fix-formatting-my-account-orders
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fix Multi-Currency formatting on My Account > Orders page.
53 changes: 52 additions & 1 deletion includes/multi-currency/FrontendCurrencies.php
Original file line number Diff line number Diff line change
@@ -115,6 +115,8 @@ public function init_hooks() {
add_filter( 'wc_get_price_thousand_separator', [ $this, 'get_price_thousand_separator' ], 900 );
add_filter( 'woocommerce_price_format', [ $this, 'get_woocommerce_price_format' ], 900 );
add_action( 'before_woocommerce_pay', [ $this, 'init_order_currency_from_query_vars' ] );
add_action( 'woocommerce_order_get_total', [ $this, 'maybe_init_order_currency_from_order_total_prop' ], 900, 2 );
add_action( 'woocommerce_get_formatted_order_total', [ $this, 'maybe_clear_order_currency_after_formatted_order_total' ], 900, 4 );
}

add_filter( 'woocommerce_thankyou_order_id', [ $this, 'init_order_currency' ] );
@@ -305,6 +307,55 @@ public function fix_price_decimals_for_shipping_rates( array $args, $method ): a
return $args;
}

/**
* Returns the current value of order_currency.
*
* @return ?string The currency code or null.
*/
public function get_order_currency() {
return $this->order_currency;
}

/**
* Maybe init the order_currency when the order total is queried if we should_use_order_currency.
*
* This works off of filtering during WC_Abstract_Order->get_total, which states it returns a float, however, in the instances of orders with negative
* amounts, such as refund orders, it will return a string.
*
* @param mixed $total The order total.
* @param WC_Order $order The order being worked on.
*
* @return mixed The unmodified total.
*/
public function maybe_init_order_currency_from_order_total_prop( $total, $order ) {
if ( $this->should_use_order_currency() ) {
$this->init_order_currency( $order );
}

return $total;
}

/**
* If the order_currency is set and we should be using the order currency, clear it.
*
* This should only be happening on the instances tested for in should_use_order_currency. We would need to clear the order currency once the total
* filter is run so that if another total comes up, like in the order list, we use the next order's currency.
*
* @param string $formatted_total Total to display.
* @param WC_Order $order Order data.
* @param string $tax_display Type of tax display.
* @param bool $display_refunded If should include refunded value.
*
* @return string The unmodified formatted total.
*/
public function maybe_clear_order_currency_after_formatted_order_total( $formatted_total, $order, $tax_display, $display_refunded ): string {
if ( null !== $this->order_currency && $this->should_use_order_currency() ) {
$this->order_currency = null;
}

return $formatted_total;
}

/**
* Gets the currency code for us to use.
*
@@ -339,7 +390,7 @@ private function get_selected_currency_code(): string {
*/
private function should_use_order_currency(): bool {
$pages = [ 'my-account', 'checkout' ];
$vars = [ 'order-received', 'order-pay', 'order-received', 'orders' ];
$vars = [ 'order-received', 'order-pay', 'order-received', 'orders', 'view-order' ];

if ( $this->utils->is_page_with_vars( $pages, $vars ) ) {
return $this->utils->is_call_in_backtrace(
92 changes: 92 additions & 0 deletions tests/unit/multi-currency/test-class-frontend-currencies.php
Original file line number Diff line number Diff line change
@@ -45,6 +45,13 @@ class WCPay_Multi_Currency_Frontend_Currencies_Tests extends WCPAY_UnitTestCase
*/
private $mock_utils;

/**
* WC_Order object.
*
* @var WC_Order
*/
private $mock_order;

/**
* FrontendCurrencies instance.
*
@@ -309,4 +316,89 @@ public function empty_order_number_provider() {
public function test_init_order_currency_returns_order_id() {
$this->assertSame( $this->mock_order->get_id(), $this->frontend_currencies->init_order_currency( $this->mock_order ) );
}

/**
* @dataProvider provider_maybe_init_order_currency_from_order_total_prop
*/
public function test_maybe_init_order_currency_from_order_total_prop( $vars, $backtrace, $expected ) {
// Arrange: Set the expected calls and/or returns for is_page_with_vars and is_call_in_backtrace within should_use_order_currency.
$this->mock_utils
->expects( $this->once() )
->method( 'is_page_with_vars' )
->willReturn( $vars );
if ( $vars ) {
$this->mock_utils
->expects( $this->once() )
->method( 'is_call_in_backtrace' )
->willReturn( $backtrace );
} else {
$this->mock_utils
->expects( $this->never() )
->method( 'is_call_in_backtrace' );
}

// Arrange: Set the currency for the mock order.
$this->mock_order->set_currency( 'EUR' );

// Act: Call our method we're testing.
$return = $this->frontend_currencies->maybe_init_order_currency_from_order_total_prop( 10.00, $this->mock_order );

// Assert: Confirm the return value has not changed and that the expected order_currency is set.
$this->assertEquals( 10.00, $return );
$this->assertEquals( $expected, $this->frontend_currencies->get_order_currency() );
}

public function provider_maybe_init_order_currency_from_order_total_prop() {
return [
'return EUR' => [ true, true, 'EUR' ],
'return null fail first backtrace' => [ false, true, null ],
'return null fail second backtrace' => [ true, false, null ],
];
}

public function test_maybe_clear_order_currency_after_formatted_order_total_takes_no_action() {
// Arrange: Set the expected calls and/or returns for is_page_with_vars and is_call_in_backtrace within should_use_order_currency.
$this->mock_utils
->expects( $this->never() )
->method( 'is_page_with_vars' );
$this->mock_utils
->expects( $this->never() )
->method( 'is_call_in_backtrace' );

// Act: Call our method we're testing.
$return = $this->frontend_currencies->maybe_clear_order_currency_after_formatted_order_total( 10.00, $this->mock_order, '', false );

// Assert: Confirm the return value has not changed and that the expected order_currency is set.
$this->assertEquals( 10.00, $return );
$this->assertEquals( null, $this->frontend_currencies->get_order_currency() );
}

public function test_maybe_clear_order_currency_after_formatted_order_total() {
// Arrange: Set the expected calls and/or returns for is_page_with_vars and is_call_in_backtrace within should_use_order_currency.
// Noting that the count is set to 2 due to maybe_init_order_currency_from_order_total_prop is called to set the order_currency.
$this->mock_utils
->expects( $this->exactly( 2 ) )
->method( 'is_page_with_vars' )
->willReturn( true );
$this->mock_utils
->expects( $this->exactly( 2 ) )
->method( 'is_call_in_backtrace' )
->willReturn( true );

// Arrange: Set the currency for the mock order.
$this->mock_order->set_currency( 'EUR' );

// Arrange: We call this to set order_currency since there is not a setter method for the property.
$this->frontend_currencies->maybe_init_order_currency_from_order_total_prop( 10.00, $this->mock_order );

// Assert: We want to make sure the order_currency is EUR before acting again.
$this->assertEquals( 'EUR', $this->frontend_currencies->get_order_currency() );

// Act: Call our method we're testing.
$return = $this->frontend_currencies->maybe_clear_order_currency_after_formatted_order_total( 10.00, $this->mock_order, '', false );

// Assert: Confirm the return value has not changed and that the order_currency is now null.
$this->assertEquals( 10.00, $return );
$this->assertEquals( null, $this->frontend_currencies->get_order_currency() );
}
}
Loading