');
}
function acceptTermsDelayed(postData, i) {
setTimeout(() => {
var postUrl = BBOX_host + '/bbox/acceptTerms';
// Configuring the fetch request
var requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json' // specify the content type as JSON
},
body: JSON.stringify(postData) // convert the JavaScript object to JSON string
};
fetch(postUrl, requestOptions)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json(); // Parse the JSON response
})
.then(data => { console.log(data); })
.catch(error => {
// Handle errors
console.error('There was a problem with your fetch operation:', error);
});
}, i * 170);
}
function get_token_id(productToGetSku) {
//alert(location.href + '/cart.json');
$.ajax({
type: 'GET',
url: location.origin + '/cart.json',
success: function (res) {
var cartContent = res.items;
var tokenId = '';
var sku = '';
for (i = 0; i < cartContent.length; i++) {
if (cartContent[i].name == productToGetSku) {
console.log('cartContent[i].name', cartContent[i].name);
console.log('productToGetSku', productToGetSku);
tokenId = cartContent[i].sku.split('-')[2];
sku = cartContent[i].sku;
}
}
get_infos_bbox(sku);
},
error: function (request, status, error) {
// alert(request.responseText);
}
});
}
function get_infos_bbox(sku) {
var postData = {
sku: sku,
shop_hash: shop_hash
};
// URL to send the POST request to
var postUrl = BBOX_host + '/bbox/getInfos';
// Configuring the fetch request
var requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json' // specify the content type as JSON
},
body: JSON.stringify(postData) // convert the JavaScript object to JSON string
};
fetch(postUrl, requestOptions)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json(); // Parse the JSON response
})
.then(data => { console.log(data); disablePayment(); showConfirmText(data); })
.catch(error => {
// Handle errors
console.error('There was a problem with your fetch operation:', error);
});
}
function disablePayment() {
$('#payment').append('');
}
function showConfirmText(data) {
var text = JSON.parse(data.confirmtext).confirm;
if ($('#bbox_confirm_checkbox_wrapper').length < 1) {
$('#checkout_confirmation_container').prepend('
A megrendelés véglegesítésével tudomásul veszem és magamra nézve kötelező érvényűnek tekintem, hogy a megrendelésben szereplő tételek tekintetében fizetési kötelezettségem keletkezik.
');
$('.summary-bottom-box-wrapper').prepend('
A termék megrendelésre vonatkozó, a távollévők között kötött szerződés szabályai alapján:
A szolgáltatás megrendelésre vonatkozó, a távollévők között kötött szerződés szabályai alapján:
');
}
}
function checkBBoxConfirm() {
if ($('#bbox_confirm_checkbox').is(':checked') && $('#bbox_more_checkbox').is(':checked')) {
$('#payment button').click();
} else {
alert('Kérem, valamennyi feltételt fogadja el!');
}
}
function init_bbox() {
var postData = {
// INIT
ip: ShopRenter.customer.userClientIP,
userAgent: navigator.userAgent,
shop_hash: shop_hash
};
// URL to send the POST request to
var postUrl = BBOX_host + '/bbox/init';
// Configuring the fetch request
var requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json' // specify the content type as JSON
},
body: JSON.stringify(postData) // convert the JavaScript object to JSON string
};
fetch(postUrl, requestOptions)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json(); // Parse the JSON response
})
.then(data => { console.log(data); bb_token_id = data.tokenId; tokens_bbox(); })
.catch(error => {
// Handle errors
console.error('There was a problem with your fetch operation:', error);
});
}
function tokens_bbox() {
var postData = {
// TOKENS
tokenId: bb_token_id,
shop_hash: shop_hash
};
// URL to send the POST request to
var postUrl = BBOX_host + '/bbox/tokens';
// Configuring the fetch request
var requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json' // specify the content type as JSON
},
body: JSON.stringify(postData) // convert the JavaScript object to JSON string
};
fetch(postUrl, requestOptions)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json(); // Parse the JSON response
})
.then(data => { console.log(data); bb_token_id_tokens = data.tokenId; remote_calculation_bbox(); })
.catch(error => {
// Handle errors
console.error('There was a problem with your fetch operation:', error);
});
}
function remote_calculation_bbox() {
var postData = {
productTypeReference: bbox_termek_parameterek.termek_tipusa,
productBrandReference: bbox_termek_parameterek.termek_markaja,
productPrice: Math.round(bbox_termek_parameterek.termek_ara) || Math.round(ShopRenter.product.price),
warrantyPeriod: bbox_termek_parameterek.termek_garancia,
productTypeNumber: bbox_termek_parameterek.termek_cikkszam,
tokenId: bb_token_id_tokens,
product_name: bbox_termek_parameterek.termek_neve,
product_sku: bbox_termek_parameterek.termek_cikkszam,
shop_hash: shop_hash
};
// URL to send the POST request to
var postUrl = BBOX_host + '/bbox/remoteCalculate';
// Configuring the fetch request
var requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json' // specify the content type as JSON
},
body: JSON.stringify(postData) // convert the JavaScript object to JSON string
};
fetch(postUrl, requestOptions)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json(); // Parse the JSON response
})
.then(data => { console.log(data); show_select_option_bbox(data) })
.catch(error => {
// Handle errors
console.error('There was a problem with your fetch operation:', error);
});
}
function show_select_option_bbox(data) {
var response = JSON.parse(data.data);
if (response.calculationItems) {
var maganszemely = '';
if (response.calculationItems) {
maganszemely += '';
}
var ceg = '';
if (response.calculationItemsCompany) {
ceg += '';
}
if (response.calculationItemsCompany.length == 0) {
ceg = '';
}
var BBOX_PARENT = $('.product-page-right .product_table_addtocartbtn');
var BBOX_SELECT_OPTION_TITLE = '