x
Dieser Artikel hat Variationen. Wählen Sie bitte die gewünschte Variation aus.
if (typeof(window.PPCcomponentInitializations) === ‚undefined‘) {
window.PPCcomponentInitializations = [];
}
(function () {
let cartButton = $(‚#add-to-cart button[name=“inWarenkorb“]‘),
isCartButtonVisible = cartButton.css(‚display‘) !== ’none‘,
isCartButtonEnabled = cartButton.length > 0 ? !cartButton[0].hasAttribute(‚disabled‘) : false;
let ppcConfig = {„shape“:“rect“,“color“:“blue“,“label“:“buynow“},
ppcECSUrl = ‚https://bay-kampfsport.de/paypal-express-zahlung‘,
errorMessage = ‚Error‘,
activeButtonLabel = ‚Zahlungsart wählen‘,
ppcNamespace = ‚productDetails‘,
wrapperID = ‚#ppc-paypal-button-custom-‚ + ppcNamespace + ‚-wrapper‘,
buttonID = ‚#ppc-paypal-button-‚ + ppcNamespace,
renderContainerID = ppcConfig.layout === ‚vertical‘
? ‚#paypal-button-‚ + ppcNamespace + ‚-container‘
: ‚#ppc-‚ + ppcNamespace + ‚-horizontal-container‘,
spinnerID = ‚#ppc-loading-spinner-express-‚ + ppcNamespace,
loadingPlaceholderID = ‚#ppc-loading-placeholder-‚ + ppcNamespace;
if (isCartButtonVisible && isCartButtonEnabled) {
loadProductDetails();
} else {
$(window).on(‚evo:priceChanged‘, function (e) {
loadProductDetails();
})
}
function loadProductDetails() {
window.PPCcomponentInitializations.push(initProductDetailsECSButtons);
$(window).on(‚ppc:getConsent‘,function(event, consent) {
if (consent === false) {
$(wrapperID).removeClass(‚d-none hidden‘);
$(buttonID).on(‚click‘, function () {
$(spinnerID).removeClass(‚d-none hidden‘);
$(this).addClass(‚disabled‘).prop(‚disabled‘, true).off(‚click‘);
$(window).trigger(‚ppc:componentInit‘,[initProductDetailsECSButtons, true]);
});
} else {
$(buttonID).addClass(‚disabled‘).prop(‚disabled‘, true).off(‚click‘);
if ($(renderContainerID + ‚ iframe‘).length {
return {
onInit: function (data, actions) {
if (parseFloat($(‚meta[itemprop=“price“]‘, $(‚#buy_form‘)).attr(‚content‘)) > 0.0) {
actions.enable();
} else {
actions.disable();
}
$(document).on(‚evo:changed.article.price‘, function (e, data) {
if (data.price > 0) {
actions.enable();
} else {
actions.disable();
}
});
},
onClick: function (data, actions) {
return $(‚#buy_form‘)[0].checkValidity()
? actions.resolve()
: actions.reject(‚Der Artikel kann nicht in den Warekorb gelegt werden‘);
},
createOrder: async function (data, actions) {
try {
let $form = $(‚#buy_form‘),
$basket = $.evo.basket(),
formData = $form.serializeObject(),
varId = typeof formData[‚VariKindArtikel‘] === ‚undefined‘ ? 0 : parseInt(formData[‚VariKindArtikel‘]),
productId = varId > 0 ? varId : parseInt(formData[$basket.options.input.id]),
quantity = parseFloat(formData[$basket.options.input.quantity].replace(‚,‘, ‚.‘));
$basket.toggleState($form, true);
if (productId > 0 && quantity > 0 && $form[0].checkValidity()) {
formData[$basket.options.input.id] = productId;
return await new Promise((resolve, reject) => {
$.evo.io().call(‚pushToBasket‘, [productId, quantity, formData], $basket, function (error, data) {
$basket.toggleState($form, false);
if (error) {
reject(error);
} else {
if (data.response) {
if (data.response.nType === 0) {
reject(data.response.cHints[0]);
return;
}
} else {
reject(‚response is empty‘);
}
}
let createOrder = {};
$.evo.io().call(‚jtl_paypal_commerce.createOrder‘, [fundingSource], createOrder, function (error, data) {
if (error) {
reject(data.error);
} else {
if (data.orderId) {
$basket.updateCart();
resolve(data.orderId);
} else {
if (data.createResultDetails) {
errorMessage = data.createResult;
reject(data.createResultDetails);
} else {
reject(data.createResult);
}
}
}
});
});
});
} else {
errorMessage = ‚Der Artikel kann nicht in den Warekorb gelegt werden‘;
throw ‚Bitte prüfen Sie alle Eingaben und versuchen Sie es erneut.‘;
}
} catch (e) {
console.log(e);
$.evo.basket().updateCart();
$.evo.extended().showNotify({title: errorMessage, text: e});
}
}
}
}
})()
Rezensionen
Es gibt noch keine Rezensionen.