Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
salvatore-disavio committed Jul 19, 2022
1 parent 76fba79 commit f8c871f
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/soisy-woocommerce-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,17 @@ 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'] ) ) {
switch ( true ) {
case $currentTotal < $this->settings['min_amount']:
case $currentTotal > $this->settings['max_amount']:
unset( $available_gateways['soisy'] );
if ( $currentTotal < $this->settings['min_amount'] || $currentTotal > $this->settings['max_amount'] ) {
unset( $available_gateways['soisy'] );
add_filter( 'check_soisy_usable', function ( $str ) {
return 'invalid';
$str = 'invalid';

return $str;
} );
break;
}
}
}
Expand Down Expand Up @@ -257,7 +255,7 @@ public function showWidgetInTaxonomies () {
if ( is_archive() ) {
$bool = false;
}
return apply_filters( 'soisy_show_in_taxonomies', $bool );
}

Expand Down Expand Up @@ -288,7 +286,7 @@ public function process_payment($order_id)
'callbackUrl' => plugin_dir_url( __FILE__ ) . 'soisy-listener.php?action=order_status'
];

$zero = $this->zeroInterest($amount);
$zero = false;//$this->zeroInterest($amount);

if ( $this->forceInstalments() ) {
$instalments = $this->instalments( $amount/100, $zero );
Expand Down Expand Up @@ -368,6 +366,10 @@ public function showLoanQuoteWidgetForProduct($price): string
if ( false == $this->showWidgetInTaxonomies() ) {
return '';
}
global $woocommerce_loop;
if ( is_product() && $woocommerce_loop['name'] == 'related' ) {
return '';
}
if (is_null($price)) {
return '';
}
Expand Down Expand Up @@ -426,7 +428,7 @@ public function renderLoanQuoteWidget($price): string {
$zero = $this->zeroInterest( $price );
$instalments = $this->instalments( $price, $zero );
$check = $this->check_soisy( $page );
do_action( 'qm/debug', $check );

if ( $check == 'invalid' ) {
$res = sprintf( '<script>document.getElementById("payment_method_soisy").disabled=true; </script>' );
}
Expand Down

0 comments on commit f8c871f

Please sign in to comment.