Skip to content

Commit

Permalink
change installment render type and variable product has campaing message
Browse files Browse the repository at this point in the history
  • Loading branch information
fatihtoprak committed Mar 5, 2023
1 parent 5daf37a commit a9e7016
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
9 changes: 7 additions & 2 deletions core/library/Moka_Init.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exit;
}

define('OPTIMISTHUB_MOKA_PAY_VERSION', '3.7.0');
define('OPTIMISTHUB_MOKA_PAY_VERSION', '3.7.1');

global $mokaVersion;
$mokaVersion = OPTIMISTHUB_MOKA_PAY_VERSION;
Expand Down Expand Up @@ -189,8 +189,13 @@ public function renderMinInstallmentMessage($price)

$options = get_option( 'woocommerce_mokapay_settings' );
$isavaliable = data_get($options, 'installment_message');
$stock = $product->get_stock_quantity();

if($isavaliable == 'yes' && !is_shop() && $woocommerce_loop['name'] == '' && $product->is_type( 'simple' ))
if(

$stock>0 && $isavaliable == 'yes' && !is_shop() && $woocommerce_loop['name'] == '' && $product->is_type( 'simple' ) ||
$stock>0 && $isavaliable == 'yes' && !is_shop() && $woocommerce_loop['name'] == '' && $product->is_type( 'variable' )
)
{
$installments = get_option( 'woocommerce_mokapay-installments' );
$minRate = data_get(current($installments), 'rates.12.value');
Expand Down
29 changes: 24 additions & 5 deletions core/library/Optimisthub_Ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,17 +227,36 @@ private function renderedHtml( $params )
{
$formHtml .='<fieldset style="padding-bottom:30px"><p class="form-row form-row-wide">';
#$formHtml .= '<img class="aligncenter" src="'.data_get($params, 'card.CardTemplate').'" />';
$formHtml .= '<label for="mokapay-installment">'.__( "Installment Shopping", 'moka-woocommerce' ).'</label>';
$formHtml .= '<select name="mokapay-installment" class="input-select">';
foreach(range(1,$maxInstallment) as $perInstallmentKey)
$formHtml .= '<label>'.__( "Installment Shopping", 'moka-woocommerce' ).'</label>';

$formHtml .='
<style>
.custom-checkboxes {display:flex;}
.w-w-50 {width:49%;float:left;margin-right:1%;}
</style>
';

# $formHtml .= '<select name="mokapay-installment" class="input-select">';
foreach(range(1,$maxInstallment) as $kk=>$perInstallmentKey)
{
if($installmentRates[$perInstallmentKey]['active'] == 1)
{
$optionValue = $perInstallmentKey == 1 ? __( "Cash In Advence", 'moka-woocommerce' ) : $perInstallmentKey. ' '. __( "Installment", 'moka-woocommerce' );
$formHtml.='<option value="'.$perInstallmentKey.'">'.self::calculateComissionRate($total, $installmentRates[$perInstallmentKey]['value'],$perInstallmentKey) . ' ' .$this->currency.' x '.$optionValue.'</option>';
$checked = $kk==0 ? ' checked="checked" ' : '';

$formHtml .=' <p class="form-row w-w-50">
<input '.$checked.' id="installment-pick'.$kk.'" type="radio" class="input-radio w-w-50" name="mokapay-installment" value="'.$perInstallmentKey.'">
<label for="installment-pick'.$kk.'"> '.$optionValue .' x '. self::calculateComissionRate($total, $installmentRates[$perInstallmentKey]['value'],$perInstallmentKey) . ' ' .$this->currency.'</label>
</p>';

$formHtml .=' ';
#$formHtml .='<input type="radio" id="ins'.$kk.'" name="mokapay-installment" value="'.$perInstallmentKey.'">';
#$formHtml .='<div><label for="ins'.$kk.'">'.self::calculateComissionRate($total, $installmentRates[$perInstallmentKey]['value'],$perInstallmentKey) . ' ' .$this->currency.' x '.$optionValue.'</label></div><br>';

#$formHtml.='<option value="'.$perInstallmentKey.'">'.self::calculateComissionRate($total, $installmentRates[$perInstallmentKey]['value'],$perInstallmentKey) . ' ' .$this->currency.' x '.$optionValue.'</option>';
}
}
$formHtml .= '</select>';
#$formHtml .= '</select>';
$formHtml .= '</p></fieldset>';
}

Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Moka Payment Gateway for WooCommerce
* Plugin URI: https://github.com/optimisthub/moka-woocommerce
* Description: Moka Payment gateway for woocommerce
* Version: 3.7.0
* Version: 3.7.1
* Author: Optimist Hub
* Author URI: https://optimisthub.com?ref=mokaPayment
* Domain Path: /languages/
Expand Down

0 comments on commit a9e7016

Please sign in to comment.