-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
122 lines (93 loc) · 3.51 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
/*
Plugin Name: iyzico taksitlendirme
Plugin URI: https://wordpress.org/plugins/iyzi-taksit-new
Description: Ürün için Taksitlendirme tablosunu gösterir
Version: 1.0.0
Author: Feyzullah Demir
Author URI: https:feyzullahdemir.com.tr
License: GNU
*/
add_filter('woocommerce_product_tabs', 'woo_new_product_tab');
function woo_new_product_tab($tabs)
{
// Adds the new tab
$tabs['test_tab'] = array(
'title' => __('Taksit Seçenekleri', 'woocommerce'),
'priority' => 50,
'callback' => 'woo_new_product_tab_content'
);
return $tabs;
}
function woo_new_product_tab_content()
{
//Include external resources
require_once('config.php');
require_once ('style.css');
//Get product price
global $product;
$realPrice = ( $product->get_display_price() );
// The new tab content
echo '<h2>Taksit Seçenekleri</h2>';
if($realPrice && $realPrice != '0' && $realPrice != '0.0' && $realPrice != '0.00' && $realPrice != false){
# create request class
$request = new \Iyzipay\Request\RetrieveInstallmentInfoRequest();
$request->setLocale(\Iyzipay\Model\Locale::TR);
$request->setConversationId(uniqid());
$request->setPrice("$realPrice");
# make request
$installmentInfo = \Iyzipay\Model\InstallmentInfo::retrieve($request, Config::options());
# json decode
$result = $installmentInfo->getRawResult();
$result = json_decode($result);
$data['statusApi'] = $installmentInfo->getStatus();
if($data['statusApi'] != 'success')
exit('Error');
$result = $result->installmentDetails;
$data['result'] = $result;
# declaration
$data['installments'] = array();
$data['banks'] = array();
$data['totalPrices'] = array();
$data['installmentPrice'] = array();
# create table
echo ('<div class="cards">');
# data parsing
foreach ($result as $key => $dataParser) {
$data['banks'][$key] = esc_js($dataParser->cardFamilyName);
$div = '<div class="card card--';
$div2 = '">';
echo (($div . $data['banks'][$key] . $div2));
$divIn1 = '<div class="card__head">';
$divIn2 = '</div>';
$divIn3 = '<div class="card__content">';
echo(($divIn1 . $data['banks'][$key] . $divIn2 . $divIn3));
$div1 = '<div class="card__cell card__cell--value">';
$div2 = '</div>';
echo('<div class="card__col card__col--installment"><div class="card__cell card__cell--head">Taksit</div>');
foreach ($dataParser->installmentPrices as $key => $installment) {
$data['installments'][$key] = esc_js($installment->installmentNumber);
echo (($div1 . $data['installments'][$key] . $div2));
}
echo('</div>');
echo('<div class="card__col card__col--default"><div class="card__cell card__cell--head">Tutar</div>');
foreach ($dataParser->installmentPrices as $key => $installment) {
$data['installmentPrice'][$key] = esc_js($installment->installmentPrice);
echo (($div1 . $data['installmentPrice'][$key] . $div2));
}
echo('</div>');
echo('<div class="card__col card__col--default"><div class="card__cell card__cell--head">Toplam</div>');
foreach ($dataParser->installmentPrices as $key => $installment) {
$data['totalPrices'][$key] = esc_js($installment->totalPrice);
echo (($div1 . $data['totalPrices'][$key] . $div2));
}
echo('</div>');
echo ('</div></div>');
}
echo('</div>');
}
else {
exit;
}
}
?>