-
Notifications
You must be signed in to change notification settings - Fork 1
/
iute_credit
161 lines (153 loc) · 5.92 KB
/
iute_credit
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<?xml version="1.0" encoding="utf-8"?>
<modification>
<name>Iute_Credit_Hola</name>
<version>1.0</version>
<author>Iute_Credit</author>
<link></link>
<code>Iute_Credit_Hola</code>
<description>Iute Credit Hola</description>
<file path="catalog/view/theme/oct_ultrastore/template/common/header.twig">
<operation>
<search><![CDATA[
</head>
]]></search>
<add position="before"><![CDATA[
<script type="text/javascript" src="https://ecom.iutecredit.md/iutepay.js"></script>
<link href="https://ecom.iutecredit.md/iutepay.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
iute.configure('edccd71a-e651-4ee8-a8d8-f149a29c747c', 'ru');
</script>
]]></add>
</operation>
</file>
<file path="catalog/view/theme/oct_ultrastore/template/product/product.twig">
<operation>
<search><![CDATA[
<ul class="us-product-description-nav list-unstyled d-flex align-items-center">
]]></search>
<add position="before"><![CDATA[
<!--IuteBlock New Start-->
{% set priceFinal = not special ? price: special %}
<div class="iute-as-low-as us-product-action d-lg-flex justify-contentbetween order-2 order-md-3" style="margin-top:10px;margin-left:3px;" data-amount="{{
priceFinal|replace({' ': ''})|split(',')[0] }}" data-page-type="product" data-sku="{{ product_id }}"
data-learnmore-show="true"></div>
<!--END IuteBlock New End-->
]]></add>
</operation>
</file>
<file path="catalog/view/theme/oct_ultrastore/template/checkout/simplecheckout_payment.twig">
<operation>
<search><![CDATA[
<div class="simplecheckout-block" id="simplecheckout_payment" {{ hide ? 'data-hide="true"' : '' }} {{ display_error and has_error ? 'data-error="true"' : '' }}>
]]></search>
<add position="before"><![CDATA[
<script>
$(document).on("click","#iutecredit", function(){
var fullName = $("#customer_firstname").val()+" "+$("#customer_lastname").val();
var addressName = 'default address';//$("#shipping_address_address_1").val()+" "+$("#shipping_address_city").val();
var phoneNr = $("#customer_telephone").val();
var emailName = $("#customer_email").val();
var itemsProducts = [];
const dataTable = document.getElementsByClassName("simplecheckout-cart")[0];
const rows = dataTable.querySelectorAll("tr");
for (var i = 0; i < rows.length; i++) {
const cells = rows[i].querySelectorAll("td");
let item = getProductInfoRow(cells);
if(item.id !== ''){
itemsProducts.push(item);
}
}
console.log(itemsProducts);
const price1 = document.getElementsByClassName('simplecheckout-cart-total-value')[0].innerText.replace(" ","");
const totalPrice = price1.replace(".","");
const total = parseFloat(totalPrice).toFixed(0);
if(fullName !== "" && addressName !=="" && phoneNr!=="" && emailName !==""){
iute.configure('edccd71a-e651-4ee8-a8d8-f149a29c747c', 'ro');
iute.checkout({
"merchant": {"name": "hola.md"},
"shipping": {
"name": {"first": fullName,"last": fullName,"patronymic": "" },
"address": {"line1": addressName,"country": "mda"},
"phoneNumber": phoneNr,
"email": emailName
},
"billing": {
"name": {"first": fullName,"last": fullName,"patronymic": ""},
"address": {"line1": addressName,"country": "mda"},
"phoneNumber": phoneNr,
"email": emailName
},
"items": itemsProducts,
"discounts": {
"COMMON_DISCOUNT": {
"discount_amount": 0,
"discount_display_name": "WC discount"
}
},
"metadata": {
"mode": "modal"
},
"orderId": Date.now(),
"currency": "mdl",
"shippingAmount": 0,
"taxAmount": 0,
"subtotal": total,
"discount": 0,
"total": total
},
{
onSuccess: function(result) {
console.log("Success " + JSON.stringify(result));
//continue submitting
//e.currentTarget.submit();
},
onFailure: function(result) {
console.log("onFailure " + JSON.stringify(result));
// show error to customer
$("#checkout-error").text(result.error).show()
}
}
);
}
});
function getProductInfoRow(cells){
var image,name, model, quantity, price, total, url, id = '';
for(var j= 0; j< cells.length; j++){
if(cells[j].className == 'image'){
url = cells[j].getElementsByTagName('a')[0].href;
image = cells[j].getElementsByTagName('img')[0].src;
name = cells[j].getElementsByTagName('img')[0].alt;
}
// if(cells[j].className == 'name'){
//
// }
if(cells[j].className == 'model'){
model = cells[j].innerText;
}
if(cells[j].className == 'quantity'){
quantity = cells[j].getElementsByTagName('input')[0].value;
id = parseInt(cells[j].getElementsByTagName('input')[0].name.replace(/[^\d\,\-]/g, ""));
}
if(cells[j].className == 'total'){
const price1 = cells[j].innerText.replace(" ","");
price = parseFloat(price1.replace(".","")).toFixed(0);
}
// if(cells[j].className == 'total'){
//
// }
}
return {
'sku': model,
'id': id,
'displayName': name,
'unitPrice': price,
'qty': quantity,
"itemImageUrl": image,
"itemUrl": url
}
}
</script>
]]></add>
</operation>
</file>
</modification>