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 = '