diff --git a/amelie/personal_tab/static/js/personal_tab_pos.js b/amelie/personal_tab/static/js/personal_tab_pos.js index 44fcd87..64e7ef3 100644 --- a/amelie/personal_tab/static/js/personal_tab_pos.js +++ b/amelie/personal_tab/static/js/personal_tab_pos.js @@ -431,7 +431,13 @@ function setupCalculator(calculator) { if(!isNaN(inputValue) && inputValue > 0){ // Add to cart // We replace the potential ',' by a '.' for the parseFloat function. - addToCart(productId, productName, parseInt(inputfield.attr('value'), 10), parseFloat(productPrice.replace(",", ".")), productImage); + let price; + if (typeof productPrice === 'string' || productPrice instanceof String) { + price = parseFloat(productPrice.replace(",", ".")) + } else { + price = parseFloat(productPrice) + } + addToCart(productId, productName, parseInt(inputfield.attr('value'), 10), price, productImage); // Clear the input field inputfield.attr('value', ''); // Return to main tab @@ -471,7 +477,14 @@ function setupShopPage(){ resetCart(); var article_elem = $(event.currentTarget.parentElement); var article_id = article_elem.data('id'); - var article_price = parseFloat(article_elem.data('price').replace(",", ".")); // Replace the ',' by a '.' for the Dutch website. + // We replace the potential ',' by a '.' for the parseFloat function. + let price; + if (typeof productPrice === 'string' || productPrice instanceof String) { + price = parseFloat(productPrice.replace(",", ".")) + } else { + price = parseFloat(productPrice) + } + var article_price = price; // Replace the ',' by a '.' for the Dutch website. var article_name = article_elem.data('name'); var article_image = article_elem.data('image'); addToCartInstant(article_id, article_name, 1, article_price, article_image); @@ -481,7 +494,14 @@ function setupShopPage(){ resetCart(); var article_elem = $(event.currentTarget.parentElement); var article_id = article_elem.data('id'); - var article_price = parseFloat(article_elem.data('price').replace(",", ".")); // Replace the ',' by a '.' for the Dutch website. + // We replace the potential ',' by a '.' for the parseFloat function. + let price; + if (typeof productPrice === 'string' || productPrice instanceof String) { + price = parseFloat(productPrice.replace(",", ".")) + } else { + price = parseFloat(productPrice) + } + var article_price = price; // Replace the ',' by a '.' for the Dutch website. var article_name = article_elem.data('name'); var article_image = article_elem.data('image'); addToCartInstant(article_id, article_name, 1, article_price, article_image); @@ -490,7 +510,13 @@ function setupShopPage(){ $('.article-addtocart').click(function(event){ var article_elem = $(event.currentTarget.parentElement); var article_id = article_elem.data('id'); - var article_price = parseFloat(article_elem.data('price').replace(",", ".")); // Replace the ',' by a '.' for the Dutch website. + let price; + if (typeof productPrice === 'string' || productPrice instanceof String) { + price = parseFloat(productPrice.replace(",", ".")) + } else { + price = parseFloat(productPrice) + } + var article_price = price; // Replace the ',' by a '.' for the Dutch website. var article_name = article_elem.data('name'); var article_image = article_elem.data('image'); addToCart(article_id, article_name, 1, article_price, article_image);