diff --git a/assets/img/cards/banks/isbank.png b/assets/img/cards/banks/isbank.png new file mode 100644 index 0000000..fc43c90 Binary files /dev/null and b/assets/img/cards/banks/isbank.png differ diff --git a/assets/img/cards/banks/kuveyt-turk.png b/assets/img/cards/banks/kuveyt-turk.png new file mode 100644 index 0000000..f6574db Binary files /dev/null and b/assets/img/cards/banks/kuveyt-turk.png differ diff --git a/assets/img/cards/banks/saglam-kart.jpg b/assets/img/cards/banks/saglam-kart.jpg new file mode 100644 index 0000000..c211afb Binary files /dev/null and b/assets/img/cards/banks/saglam-kart.jpg differ diff --git a/assets/moka-installment.js b/assets/moka-installment.js new file mode 100644 index 0000000..ef58b33 --- /dev/null +++ b/assets/moka-installment.js @@ -0,0 +1,9 @@ +jQuery('.min--installment--price').click(function (e) { + jQuery('a[href="#tab-installment_tab"]').trigger('click'); + + var position = jQuery('#tab-installment_tab').offset().top; + + jQuery("body, html").animate({ + scrollTop: position + } ); +}); \ No newline at end of file diff --git a/assets/moka.css b/assets/moka.css index e97c089..522dd4f 100644 --- a/assets/moka.css +++ b/assets/moka.css @@ -52,4 +52,99 @@ .subscription-cancelManually { padding:4px 10px;border-radius: 4px;background:#b13f74;color:#fff;cursor: pointer;} .subscription-noActions { padding:4px 0;border-bottom:1px solid #6c6c6c;color:#6c6c6c;opacity: 0.8;cursor: help;} #subscription_ajax_response p {background-color: #b13f3f;color:#fff;text-align: center;padding: 10px;;} -#subscription_ajax_response p.message {background-color: #3f83b1;color:#fff;text-align: center;padding: 10px;;} \ No newline at end of file +#subscription_ajax_response p.message {background-color: #3f83b1;color:#fff;text-align: center;padding: 10px;;} + +.installment--table--container { + max-width: unset !important; + margin:unset !important; + padding:unset !important; + display: flex; + flex-wrap: wrap; + margin: 0px -12px; +} +.installment--table--column { + width: 24%; + margin: 0px 0.5% 20px 0.5%; + box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px; + +} +.installment--table--column .perrate { + display:flex; + justify-content: space-between !important; + align-items: center; + text-align: center; + font-size:14px; + line-height:40px; + border-bottom:1px solid rgb(245, 245, 245); + border-left:1px solid rgb(245, 245, 245); + border-right:1px solid rgb(245, 245, 245); + padding:0 4px; + background:#fff; +} +.installment--table--column .perrate div { + text-align: center; + border-right:1px solid rgb(245, 245, 245); + width:33.3%; +} +.installment--table--table-head div{ + text-align: center; + width:33.3%; + border-bottom:unset; +} +.installment--table--table-head div:last-child { + border-right: unset; + border-bottom: unset; +} +.installment--table--column .perrate div:last-child { + border-right: unset;; +} +.installment--table--column .perrate div.empty { + text-align: center; + border-left:1px solid rgb(245, 245, 245); + border-right:1px solid rgb(245, 245, 245); + width:100%; +} +.installment--table--column .perrate div.perUnitPrice { + font-weight: bold; +} +.installment--table--table-head { + display:flex; + justify-content: space-between; + align-items: center; + text-align: center; + font-size:14px; + font-weight:bold; + line-height:34px; + padding:4px; + background:#888 !important; + color:#fff; +} +.installment--table--head { + background-color: rgb(245, 245, 245); + height: 44px; + width: 100%; + display: flex; + justify-content: center; + align-items: center; + border-top-left-radius: 4px; + border-top-right-radius: 4px; +} +.installment--table--head img{ + height: 35px; + width: 65px; + object-fit: contain; +} + +.min--installment--price { + width: 100%; + align-items: center; + justify-content: space-between; + background: #e6f1f4; + border: 1px solid #bdd5dc; + border-radius: 8px; + padding: 8px; + font-size:17px; + margin:10px 0; + cursor: pointer; +} +.min--installment--price span {font-weight: bold;} \ No newline at end of file diff --git a/assets/moka.min.css b/assets/moka.min.css new file mode 100644 index 0000000..2481d78 --- /dev/null +++ b/assets/moka.min.css @@ -0,0 +1 @@ + #mokapay-card-number {background-size: 10% auto !important;background-position: right 10px bottom 5px !important;display: flex;justify-content: center;padding-right:10px !important;background-size:40px auto !important;}#mokapay-card-number.visa {background: url('img/cards/visa.png') center right no-repeat;}#mokapay-card-number.mastercard {background: url('img/cards/mastercard.png') center right no-repeat;}#mokapay-card-number.amex {background: url('img/cards/amex.png') center right no-repeat;}#mokapay-card-number.discover {background: url('img/cards/discover.png') center right no-repeat;}.wc_payment_method .payment_box.payment_method_mokapay fieldset {display:table;}.wc_payment_method .payment_box.payment_method_mokapay select{width:100% !important;}.woocommerce #payment .form-row select, .woocommerce-page #payment .form-row select {width:100% !important;}.mokapay-save-card-info-message {padding:2% 0;font-size:0.7rem;border-top:1px solid #333;margin-top:15px;display:flex;justify-content:flex-start;}.text-center {text-align:center !important}.active_subs {background:rgb(51, 121, 51) !important;cursor:pointer}.passive_subs {background:#b13f3f !important;cursor:pointer}.subscription-payManually {padding:4px 10px;border-radius: 4px;background:#3f83b1;color:#fff;cursor: pointer;}.subscription-cancelManually {padding:4px 10px;border-radius: 4px;background:#b13f74;color:#fff;cursor: pointer;}.subscription-noActions {padding:4px 0;border-bottom:1px solid #6c6c6c;color:#6c6c6c;opacity: 0.8;cursor: help;}#subscription_ajax_response p {background-color: #b13f3f;color:#fff;text-align: center;padding: 10px;;}#subscription_ajax_response p.message {background-color: #3f83b1;color:#fff;text-align: center;padding: 10px;;}.installment--table--container {max-width: unset !important;margin:unset !important;padding:unset !important;display: flex;flex-wrap: wrap;margin: 0px -12px;}.installment--table--column {width: 24%;margin: 0px 0.5% 20px 0.5%;box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;}.installment--table--column .perrate {display:flex;justify-content: space-between !important;align-items: center;text-align: center;font-size:14px;line-height:40px;border-bottom:1px solid rgb(245, 245, 245);border-left:1px solid rgb(245, 245, 245);border-right:1px solid rgb(245, 245, 245);padding:0 4px;background:#fff;}.installment--table--column .perrate div {text-align: center;border-right:1px solid rgb(245, 245, 245);width:33.3%;}.installment--table--table-head div{text-align: center;width:33.3%;border-bottom:unset;}.installment--table--table-head div:last-child {border-right: unset;border-bottom: unset;}.installment--table--column .perrate div:last-child {border-right: unset;;}.installment--table--column .perrate div.empty {text-align: center;border-left:1px solid rgb(245, 245, 245);border-right:1px solid rgb(245, 245, 245);width:100%;}.installment--table--column .perrate div.perUnitPrice {font-weight: bold;}.installment--table--table-head {display:flex;justify-content: space-between;align-items: center;text-align: center;font-size:14px;font-weight:bold;line-height:34px;padding:4px;background:#888 !important;color:#fff;}.installment--table--head {background-color: rgb(245, 245, 245);height: 44px;width: 100%;display: flex;justify-content: center;align-items: center;border-top-left-radius: 4px;border-top-right-radius: 4px;}.installment--table--head img{height: 35px;width: 65px;object-fit: contain;}.min--installment--price {width: 100%;align-items: center;justify-content: space-between;background: #e6f1f4;border: 1px solid #bdd5dc;border-radius: 8px;padding: 8px;font-size:17px;margin:10px 0;cursor: pointer;}.min--installment--price span {font-weight: bold;} \ No newline at end of file diff --git a/core/library/Moka_Gateway.php b/core/library/Moka_Gateway.php index 4a36703..c896432 100644 --- a/core/library/Moka_Gateway.php +++ b/core/library/Moka_Gateway.php @@ -57,8 +57,8 @@ public function __construct() $this->order_prefix = $this->get_option( 'order_prefix' ); $this->order_status = $this->get_option( 'order_status' ); $this->subscriptions = $this->get_option( 'subscriptions' ); - $this->isSubscriptionsEnabled = 'yes' == $this->subscriptions; - + $this->installment_message = $this->get_option( 'installment_message' ); + $this->isSubscriptionsEnabled = 'yes' == $this->subscriptions; $this->optimisthubMoka = new MokaPayment(); $this->maxInstallment = range(1,12); $this->userInformation = self::getUserInformationData(); @@ -70,7 +70,7 @@ public function __construct() add_filter( 'woocommerce_credit_card_form_fields' , [$this,'payment_form_fields'] , 10, 2 ); add_action( 'admin_head', [$this, 'admin_css']); add_action( 'woocommerce_receipt_'.$this->id, [$this, 'receipt_page']); - + self::__saveRates(); } @@ -121,6 +121,13 @@ public function init_form_fields() 'default' => 'no', 'desc_tip' => true, ], + 'installment_message' => [ + 'title' => __( 'Show Installment Message under the price_html ?', 'moka-woocommerce' ) .' - '. __( 'Enable/Disable', 'moka-woocommerce' ), + 'label' => __('Show Installment Message under the price_html ?', 'moka-woocommerce' ), + 'type' => 'checkbox', + 'default' => 'yes', + 'desc_tip' => true, + ], 'installment' => [ 'title' => __( 'Installement', 'moka-woocommerce' ), 'label' => __('Enable/Disable Installement ?', 'moka-woocommerce' ), @@ -363,8 +370,6 @@ public function payment_fields() public function payment_scripts() { wp_enqueue_script( 'moka-pay-corejs', $this->assets . 'moka.js' , false, OPTIMISTHUB_MOKA_PAY_VERSION ); - wp_register_style( 'moka-pay-card_css', $this->assets. 'moka.css' , false, OPTIMISTHUB_MOKA_PAY_VERSION ); - wp_enqueue_style ( 'moka-pay-card_css' ); wp_localize_script( 'moka-pay-corejs', 'moka_ajax', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) ); } diff --git a/core/library/Moka_Init.php b/core/library/Moka_Init.php index 8b3bad1..6d2ad99 100644 --- a/core/library/Moka_Init.php +++ b/core/library/Moka_Init.php @@ -3,7 +3,7 @@ exit; } -define('OPTIMISTHUB_MOKA_PAY_VERSION', '3.0.4'); +define('OPTIMISTHUB_MOKA_PAY_VERSION', '3.5'); global $mokaVersion; $mokaVersion = OPTIMISTHUB_MOKA_PAY_VERSION; @@ -16,11 +16,36 @@ class Moka_Init { public function __construct() { + $this->assets = $this->assetDir(); + + add_action( 'wp_enqueue_scripts', [$this, 'pluginStyles'] ); + add_filter( 'woocommerce_payment_gateways', [$this, 'addOptimisthubMokaGateway'] ); add_action( 'wp_dashboard_setup', [$this, 'optimisthubDashBoardWidgetInit']); add_shortcode( 'moka-taksit-tablosu', [$this, 'installmentShortcode'] ); add_shortcode( 'moka-installment-table', [$this, 'installmentShortcode'] ); + + add_filter( 'woocommerce_product_tabs', [$this, 'generateInstallmentProductTab'] ); + add_filter( 'woocommerce_get_price_html', [$this, 'renderMinInstallmentMessage'] ); + + + } + + public function pluginStyles() + { + + wp_register_style( 'moka-pay-card_css', $this->assets. 'moka.min.css' , false, OPTIMISTHUB_MOKA_PAY_VERSION ); + wp_enqueue_style ( 'moka-pay-card_css' ); + + wp_enqueue_script( + 'moka-installment', + $this->assets . 'moka-installment.js', + array( 'jquery' ), + OPTIMISTHUB_MOKA_PAY_VERSION, + true + ); + } /** @@ -69,9 +94,143 @@ public function recentNewsByOptimisthub() echo '

Ücretsiz Moka POS WooCommerce Eklentisi Optimist Hub Bünyesinde geliştirilmiştir. Açık kaynak kodlu eklentiye sizler de katkıda bulunabilirsiniz. >

'; } -} + public function generateInstallmentProductTab($tabs) + { + $tabs['installment_tab'] = array( + 'title' => __( 'Installment Options', 'moka-woocommerce' ), + 'priority' => 20, + 'callback' => [$this, 'generateInstallmentProductTabContent'] + ); + return $tabs; + } -new Moka_Init(); + public function generateInstallmentProductTabContent() + { + global $product, $woocommerce; + $installments = get_option( 'woocommerce_mokapay-installments' ); + if(!$installments) + { + return; + } + $productPrice = $product->get_price(); + + if(!$productPrice) + { + return; + } + + $return = '
'; + + unset($installments['0-genel']); + + foreach ($installments as $perKey => $perValue) { + + $return .= '
'; + $return .= '
'.$perKey.'
'; + $return .= '
Taksit
Taksit Tutarı
Toplam Tutar
'; + if(data_get($perValue, 'rates')) + { + $rates = data_get($perValue, 'rates'); + unset($rates[0]); + unset($rates[1]); + + foreach ($rates as $perRateKey => $perRateValue) + { + if($perRateValue['value']>0 && $perRateValue['active']==1) + { + $returnPrice = self::calculateComission($perRateKey,$perRateValue['value'],$productPrice); + + $return .= '
+ +
'.$perRateKey.'
+
'.$returnPrice['unit_price'].' '. get_woocommerce_currency_symbol().'
+
'.$returnPrice['total_price'].' '. get_woocommerce_currency_symbol().'
+ +
'; + + } else { + $return .= '
-
'; + } + } + } + $return .= '
'; + + } + + $return .= '
'; + + echo $return; + } + + public function renderMinInstallmentMessage($price) + { + if(is_singular('product')) + { + global $product; + global $woocommerce_loop; + + $productPrice = $product->get_price(); + + $options = get_option( 'woocommerce_mokapay_settings' ); + $isavaliable = data_get($options, 'installment_message'); + + if($isavaliable == 'yes' && !is_shop() && $woocommerce_loop['name'] == '') + { + $installments = get_option( 'woocommerce_mokapay-installments' ); + $minRate = data_get(current($installments), 'rates.12.value'); + $minRatePrice = self::calculateComission(12,$minRate,$productPrice); + + echo $price.' +
'.$minRatePrice['unit_price']. ' '.get_woocommerce_currency_symbol() .' \' '.__( 'With installments starting from', 'moka-woocommerce' ).' ...
'; + } + } + } + + + private function assetDir() + { + return str_replace('/core/library/', '/assets/' , plugin_dir_url( __FILE__ )); + } + + private function getCardName($string) + { + $images = [ + '133-kuveyt-turk-katilim-bankasi-a-s' => 'kuveyt-turk.png', + '101-imece-bank' => 'isbank.png', + '4-akbank-t-a-s' => 'axess.svg', + '78-deniz-bank-a-s' => 'bonus.svg', + '98-finansbank-a-s' => 'cardfinans.svg', + '004-hscb-a-s' => 'advantage.svg', + '217-ziraat-bankasi' => 'combo.svg', + '122-is-bankasi-a-s' => 'maximum.svg', + '108-halk-bankasi-a-s' => 'paraf.svg', + '174-vakiflar-bankasi-t-a-o' => 'world.svg', + + ]; + return $images[$string]; + } + + private function calculateComission($installment, $percent, $price) + { + $realPercent = ($price*$percent)/100; + $totalPrice = $price+($realPercent); + + $return = [ + 'percent' => $percent, + 'price' => $price, + 'installment' => $installment, + 'real_percent' => $realPercent, + 'total_price' => number_format($totalPrice,2), + 'unit_price' => number_format($totalPrice/$installment,2) + ]; + + return $return; + } + +} + +new Moka_Init(); + \ No newline at end of file diff --git a/index.php b/index.php index e9e0632..55e2978 100644 --- a/index.php +++ b/index.php @@ -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.0.4 + * Version: 3.5 * Author: Optimist Hub * Author URI: https://optimisthub.com?ref=mokaPayment * Domain Path: /languages/ diff --git a/languages/moka-woocommerce-en_US.mo b/languages/moka-woocommerce-en_US.mo index 5a06c1e..9a34200 100644 Binary files a/languages/moka-woocommerce-en_US.mo and b/languages/moka-woocommerce-en_US.mo differ diff --git a/languages/moka-woocommerce-en_US.po b/languages/moka-woocommerce-en_US.po index 88d70d6..89f65ce 100644 --- a/languages/moka-woocommerce-en_US.po +++ b/languages/moka-woocommerce-en_US.po @@ -3,7 +3,7 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-12-08T11:49:40+00:00\n" -"PO-Revision-Date: 2022-10-20 01:49+0300\n" +"PO-Revision-Date: 2022-11-11 16:58+0300\n" "Last-Translator: Fatih Toprak \n" "Language-Team: \n" "Language: en_US\n" @@ -205,3 +205,12 @@ msgstr "Actions" msgid "Your card information that you have added during the payment will be kept by Moka with the assurance of Moka. Your next subscription payment will be taken with this card." msgstr "Your card information that you have added during the payment will be kept by Moka with the assurance of Moka. Your next subscription payment will be taken with this card." + +msgid "Installment Options" +msgstr "Taksit Seçenekleri" + +msgid "With installments starting from" +msgstr "With installments starting from" + +msgid "Show Installment Message under the price_html ?" +msgstr "Show Installment Message under the price_html ?" diff --git a/languages/moka-woocommerce-tr_TR.mo b/languages/moka-woocommerce-tr_TR.mo index c230e5f..b6e34d4 100644 Binary files a/languages/moka-woocommerce-tr_TR.mo and b/languages/moka-woocommerce-tr_TR.mo differ diff --git a/languages/moka-woocommerce-tr_TR.po b/languages/moka-woocommerce-tr_TR.po index 7eaf5f3..84de7ce 100644 --- a/languages/moka-woocommerce-tr_TR.po +++ b/languages/moka-woocommerce-tr_TR.po @@ -3,7 +3,7 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-12-08T11:49:40+00:00\n" -"PO-Revision-Date: 2022-10-20 01:49+0300\n" +"PO-Revision-Date: 2022-11-11 16:58+0300\n" "Last-Translator: Fatih Toprak \n" "Language-Team: \n" "Language: tr_TR\n" @@ -206,3 +206,12 @@ msgstr "İşlemler" msgid "Your card information that you have added during the payment will be kept by Moka with the assurance of Moka. Your next subscription payment will be taken with this card." msgstr "Ödeme esnasında eklemiş olduğunuz kart bilgileriniz, Moka güvencesi ile Moka tarafından saklanacaktır. Sonraki abonelik ödemeniz bu kart ile alınacaktır." + +msgid "Installment Options" +msgstr "Taksit Seçenekleri" + +msgid "With installments starting from" +msgstr "den başlayan taksitlerle" + +msgid "Show Installment Message under the price_html ?" +msgstr "Fiyat altında minimum taksit mesajı ?"