Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@
* @link https://basecamp.com/1810084/projects/10966871/todos/346407847
* @link https://github.com/woocommerce/woocommerce/blob/3.5.3/includes/class-woocommerce.php#L381-L383
*/
if ( defined( 'WP_CLI' ) && WP_CLI ) {

Check failure on line 396 in src/Plugin.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan

Right side of && is always true.
return;
}

Expand Down Expand Up @@ -1147,6 +1147,9 @@
$payment->refunds[] = $refund;

$refunded_amount = $payment->get_refunded_amount();
if ( $refunded_amount->is_zero() && $refunded_amount->get_currency() !== $refund->get_amount()->get_currency() ) {
$refunded_amount->set_currency( $refund->get_amount()->get_currency() );
}

$refunded_amount = $refunded_amount->add( $refund->get_amount() );

Expand Down
8 changes: 8 additions & 0 deletions views/meta-box-payment-lines.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,20 @@ function ( PaymentLine $line ) {

$line_total = $refund_line->get_total_amount();

if ( $refunded_amount->is_zero() && $refunded_amount->get_currency() !== $line_total->get_currency() ) {
$refunded_amount->set_currency( $line_total->get_currency() );
}

$refunded_amount = $refunded_amount->add( $line_total );

if ( $line_total instanceof TaxedMoney ) {
$tax_amount = $line_total->get_tax_amount();

if ( null !== $tax_amount ) {
if ( $refunded_tax->is_zero() && $refunded_tax->get_currency() !== $tax_amount->get_currency() ) {
$refunded_tax->set_currency( $tax_amount->get_currency() );
}

$refunded_tax = $refunded_tax->add( $tax_amount );
}
}
Expand Down
Loading