Dupli Shades Magnetisch Frame Basic (2024)

30% korting

Dupli Shades Magnetisch Frame Basic (2)

'; $(errorHtml).insertAfter(rowIdClass || colIdClass); $(document).on('setValidSizes', function (event, validSizes) { if (validSizes) { $('#size-does-not-exist').hide(); } else { $('#size-does-not-exist').show(); } }); } /** * Bluebird Day custom, init measurements * Adds min/max values as text next to input fields */ if (rowOpId) { initMeasurement('#measurements', rowIdClass, minRow, maxRow); /** * Validate CSV pricing */ $.validator.addMethod('validate-csvpricing-rowid', function (value) { if (value < minRow || value > maxRow) { // Trigger setValidSizes with true, because you only want 1 error message $(document).trigger('setValidSizes', true); return false; } return true; }, "Vul een waarde in tussen %1 en %2.".replace('%1', minRow).replace('%2', maxRow)); } if (colOpId) { initMeasurement('#measurements', colIdClass, minCol, maxCol); /** * Validate CSV pricing */ $.validator.addMethod('validate-csvpricing-colid', function (value) { if (value < minCol || value > maxCol) { // Trigger setValidSizes with true, because you only want 1 error message $(document).trigger('setValidSizes', true); return false; } return true; }, "Vul een waarde in tussen %1 en %2.".replace('%1', minCol).replace('%2', maxCol)); } /** * End validation CSV pricing */ /** * On document ready */ $(document).ready(function () { if (rowOpId) { var dataRowId = $(rowId).data("validate"); if (!("validate-csvpricing-rowid" in dataRowId)) { var newObj = {"validate-csvpricing-rowid": true}; $.extend(dataRowId, newObj); var rowstringify = JSON.stringify(dataRowId) .replace(/"/g, '"'); $(rowId).attr("data-validate", rowstringify); } } if (colOpId) { // update col id input field var dataColId = $(colId).data("validate"); if (!("validate-csvpricing-colid" in dataColId)) { var newObj = {"validate-csvpricing-colid": true}; $.extend(dataColId, newObj); var colstringify = JSON.stringify(dataColId) .replace(/"/g, '"'); $(colId).attr("data-validate", colstringify); } } /** * Loop var rbnlPercentageOptions * This var contains only selectbox->option_values which have a price based on percentage */ if (!$.isEmptyObject(rbnlPercentageOptions)) { $.each(rbnlPercentageOptions, function (optionId, value) { if ($("#select_" + optionId)) { $("#select_" + optionId).change(function () { calculatePrice(); }); } }); } // Init calculate price calculatePrice() }); if (colId) { // On colId change colId.change(function () { var value = $(this).val(); if (value == '') { updatePriceOnChange(); return; } $.validator.addMethod('validate-csvpricing-price', function (value) { return true; }, $.mage.__('')); if ($.validator.validateElement(colId)) { calculatePrice(); } }); } if (rowId) { // On rowId change rowId.change(function () { var value = $(this).val(); if (value == '') { updatePriceOnChange(); return; } // to remove "price not exist" error for change value to allow validate $.validator.addMethod('validate-csvpricing-price', function (value) { return true; }, $.mage.__('')); if ($.validator.validateElement(rowId)) { calculatePrice(); } }); } const colorSelector = $(".color-selector select"); if (colorSelector) { colorSelector.change(function () { let priceGroupValue = $(this).find(":selected").data("pricegroup"); if (priceGroupValue) { if (typeof (priceGroupValue) === "string") { priceGroup = priceGroupValue.toLowerCase(); } else { priceGroup = priceGroupValue; } } }) } /** * Calculate price function */ function calculatePrice() { var rowValue = rowId ? parseInt(rowId.val().trim()) : minRow; var colValue = colId ? parseInt(colId.val().trim()) : minCol; if (rowValue && colValue) { var rowPriceOp = false; var colPriceOp = false; var finalPrice = false; if (rowValue && colValue) { var rowTier = getRowTier(rowValue); var colTier = getColTier(colValue); if (rowTier != false && colTier != false) { var additionalPriceObj = priceBox.cache.additionalPriceObject; if (rowOpId && additionalPriceObj) { rowOpKey = "options[" + rowOpId + "]"; rowPriceOp = additionalPriceObj[rowOpKey]; } if (colOpId && additionalPriceObj) { colOpKey = "options[" + colOpId + "]"; colPriceOp = additionalPriceObj[colOpKey]; } finalPrice = getPricegroupPrice(rbnlPriceMatrix[colTier][rowTier]); } } /** * Validate undefined or empty prices */ var validSizes = !(finalPrice === undefined || finalPrice === '' || isNaN(finalPrice)); /** * Trigger validation of sizes * This will eventually send data to product configurator * in app/code/RaambekledingNederland/ProductConfigurator/view/frontend/web/js/module.js */ $(document).trigger('setValidSizes', validSizes); if (finalPrice !== false) { if (rowId) { $.validator.validateElement(rowId); } if (colId) { $.validator.validateElement(colId); } var finalPriceOptionCalc = finalPrice; finalPrice -= productBasePrice; if (colPriceOp && !$.isEmptyObject(colPriceOp)) { if (colPriceOp.finalPrice.amount !== 0) { colPriceOp.basePrice.amount = finalPrice; colPriceOp.finalPrice.amount = finalPrice; } else { rowPriceOp.basePrice.amount = finalPrice; rowPriceOp.finalPrice.amount = finalPrice; } } else if (rowPriceOp && !$.isEmptyObject(rowPriceOp)) { rowPriceOp.basePrice.amount = finalPrice; rowPriceOp.finalPrice.amount = finalPrice; } /** * Bluebird Day * Handle all custom options based on percentage * Percentage is calculated with CSV price (js var rbnlPriceMatrix), * not on price from backend (php var $_product->getPrice()) */ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } if (!$.isEmptyObject(rbnlPercentageOptions)) { $.each(rbnlPercentageOptions, function (optionId, value) { var slbBox = $("#select_" + optionId); if (slbBox.val()) { var additionalPrice = 0; if (rbnlPercentageOptions[optionId][slbBox.val()] !== undefined) { var percentage = rbnlPercentageOptions[optionId][slbBox.val()]; additionalPrice = ((finalPriceOptionCalc / 100) * percentage).toFixed(2); } $("div.price-box .price-final_price").trigger("updatePrice", _defineProperty({}, "options[" + optionId + "]", { 'finalPrice': { 'amount': additionalPrice }, 'basePrice': { 'amount': additionalPrice } })); } }); } $("div.price-box .price-final_price").trigger("updatePrice"); /** * Bluebird Day add trigger for product configurator with finalPrice * Used trigger in app/code/RaambekledingNederland/ProductConfigurator/view/frontend/web/js/module.js * Note: finalPrice, does not seem to work well, so finalPrice is not used. */ $(document).trigger("syncPrices", finalPrice); } } } function getPricegroupPrice(rowColValue) { if (rowColValue.includes(";")) { const priceGroups = rowColValue.split(";"); var prices = new Map(); priceGroups.forEach(priceRow => { var key = priceRow.split(":")[0] key = key.replaceAll('”', '').replaceAll('“', '') const value = priceRow.split(":")[1] prices.set(key, value); }) // Return price group value or the cheapest price return prices.get(String(priceGroup)) ? prices.get(String(priceGroup)) : Array.from(prices)[0][1]; } else { return parseFloat(rowColValue); } } /** * Get row tier */ function getRowTier(value) { var result = false; if (value >= minRow && value <= maxRow) { for (i = 0; i < csvFirstRowArr.length; i++) { if (value === parseInt(csvFirstRowArr[i])) { result = csvFirstRowArr[i]; break; } if (value > parseInt(csvFirstRowArr[i]) && value <= parseInt(csvFirstRowArr[i + 1])) { result = csvFirstRowArr[i + 1]; break; } } } return result; } /** * Get col tier */ function getColTier(value) { var result = false; if (value >= minCol && value <= maxCol) { for (i = 0; i < csvFirstColArr.length; i++) { if (value === parseInt(csvFirstColArr[i])) { result = csvFirstColArr[i]; break; } if (value > parseInt(csvFirstColArr[i]) && value <= parseInt(csvFirstColArr[i + 1])) { result = csvFirstColArr[i + 1]; break; } } } return result; } /** * Update price on change */ function updatePriceOnChange(fp) { if (!fp) { fp = 0 } var additionalPriceObj = priceBox.cache.additionalPriceObject; var rowOpKey = false; var rowPriceOp = false; if (rowOpId) { rowOpKey = "options[" + rowOpId + "]"; rowPriceOp = additionalPriceObj[rowOpKey]; } var colPriceOp = false; var colOpKey = false; if (colOpId) { var colOpKey = "options[" + colOpId + "]"; var colPriceOp = additionalPriceObj[colOpKey]; } if (colPriceOp && !$.isEmptyObject(colPriceOp)) { colPriceOp.basePrice.amount = fp; colPriceOp.finalPrice.amount = fp; } if (rowPriceOp && !$.isEmptyObject(rowPriceOp)) { rowPriceOp.basePrice.amount = fp; rowPriceOp.finalPrice.amount = fp; } $("div.price-box .price-final_price").trigger("updatePrice"); /** * Bluebird Day add trigger for product configurator * Used trigger in app/code/RaambekledingNederland/ProductConfigurator/view/frontend/web/js/module.js */ $(document).trigger("syncPrices", fp); } });

Dupli Shades Magnetisch Frame Basic (2024)
Top Articles
Latest Posts
Article information

Author: Ms. Lucile Johns

Last Updated:

Views: 6392

Rating: 4 / 5 (61 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Ms. Lucile Johns

Birthday: 1999-11-16

Address: Suite 237 56046 Walsh Coves, West Enid, VT 46557

Phone: +59115435987187

Job: Education Supervisor

Hobby: Genealogy, Stone skipping, Skydiving, Nordic skating, Couponing, Coloring, Gardening

Introduction: My name is Ms. Lucile Johns, I am a successful, friendly, friendly, homely, adventurous, handsome, delightful person who loves writing and wants to share my knowledge and understanding with you.