Skip to content

Commit

Permalink
Fix getTotal
Browse files Browse the repository at this point in the history
  • Loading branch information
regdos committed Jun 18, 2024
1 parent 9e61c28 commit 5d949ae
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Payu/Gateways/WC_Payu_Gateways.php
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ protected function get_payu_pay_method_array( string $type, string $value, ?stri
*/
protected function check_min_max( $payMethod, $paytype = null ) {
if ( ( $paytype === null || $payMethod->value === $paytype ) && $payMethod->status === 'ENABLED' ) {
$total = $this->get_order_total() * 100;
$total = $this->getTotal() * 100;

if ( isset( $payMethod->minAmount ) && $total < $payMethod->minAmount ) {
return false;
Expand All @@ -1093,6 +1093,16 @@ protected function check_min_max( $payMethod, $paytype = null ) {
return false;
}

private function getTotal(): float {
if ( $this->order_total !== null ) {
return $this->order_total;
} elseif ( WC()->cart && 0 !== count( WC()->cart->get_cart_contents() ) ) {
return WC()->cart->get_cart_contents_total() + WC()->cart->get_cart_contents_tax() + WC()->cart->get_shipping_total() + WC()->cart->get_shipping_tax();
}

return 0;
}

/**
* @param string $notification
*
Expand Down

0 comments on commit 5d949ae

Please sign in to comment.