Skip to content

Commit

Permalink
Fix WC()->cart->total
Browse files Browse the repository at this point in the history
Aggiornamento proprietà WC()->cart->total
  • Loading branch information
salvatore-disavio committed Jul 20, 2022
1 parent f8c871f commit e42208f
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions src/soisy-woocommerce-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,23 @@ public function payment_gateway_disable_countries($available_gateways)
}

public function payment_gateway_disable_by_amount($available_gateways) {
if ( is_object( WC()->cart ) && ! empty( ( WC()->cart->get_total() ) ) ) {
$currentTotal = Helper::htmlPriceToNumber( WC()->cart->get_total() );
//if (isset($available_gateways['soisy']) && ($currentTotal < SoisyClient::MIN_AMOUNT || $currentTotal > SoisyClient::MAX_AMOUNT)) {
if ( isset( $available_gateways['soisy'] ) ) {
$currentTotal = 0;
if ( is_object( WC()->cart ) ) {
$cart = WC()->cart;
if ( isset( $cart->total ) && !empty( $cart->total ) ) {
$currentTotal = $cart->total;
}
else {
$currentTotal = Helper::htmlPriceToNumber( $cart->get_total() );
}
if ( isset( $available_gateways['soisy'] ) && !empty($currentTotal) ) {
if ( $currentTotal < $this->settings['min_amount'] || $currentTotal > $this->settings['max_amount'] ) {
unset( $available_gateways['soisy'] );
add_filter( 'check_soisy_usable', function ( $str ) {
$str = 'invalid';
return $str;
} );
unset( $available_gateways['soisy'] );
add_filter( 'check_soisy_usable', function ( $str ) {
$str = 'invalid';

return $str;
} );
}
}
}
Expand Down Expand Up @@ -382,16 +388,22 @@ public function showLoanQuoteWidgetForProduct($price): string
}

public function showLoanQuoteWidgetForCartAndCheckout(): string {
/*
if ( false == $this->showWidgetInTaxonomies() ) {

/*if ( false == $this->showWidgetInTaxonomies() ) {
return '';
}*/
do_action( 'qm/debug', __FUNCTION__ );

if ( is_object( WC()->cart ) && ! empty( ( WC()->cart->get_total() ) ) ) {
do_action( 'qm/debug', 'rendering_widget' );
print( '<!-- soisy rendering widget -->' );
return $this->renderLoanQuoteWidget( WC()->cart->get_total() );
} else {
return '';
}



return '';
}

public function renderLoanQuoteWidget($price): string {
Expand Down

0 comments on commit e42208f

Please sign in to comment.