- Magento - Show simple product image and description
- Product.Config.prototype.reloadPrice = function() {
- var childProductId = this.getMatchingSimpleProduct();
- var childProducts = this.config.childProducts;
- var attribID = 158;
- var kleurproductDropdown = document.getElementById('attribute' + attribID);
- var kleurproductSelectedIndex = kleurproductDropdown.selectedIndex;
- var kleurproduct_value = kleurproductDropdown.options[kleurproductSelectedIndex].text;
- //if the price ranges option is checked in the backend then a colon and the price is added to the dropdown
- if (kleurproduct_value.indexOf(':') > -1) {
- kleurproduct_value = kleurproduct_value.substr(0,kleurproduct_value.indexOf(':'));
- }
- var usingZoomer = false;
- if(this.config.imageZoomer){
- usingZoomer = true;
- }
- if (childProductId){
- var price = childProducts[childProductId]["price"];
- var finalPrice = childProducts[childProductId]["finalPrice"];
- optionsPrice.productPrice = finalPrice;
- optionsPrice.productOldPrice = price;
- optionsPrice.reload();
- optionsPrice.reloadPriceLabels(true);
- optionsPrice.updateSpecialPriceDisplay(price, finalPrice);
- this.updateProductShortDescription(childProductId);
- this.updateProductDescription(childProductId);
- this.updateProductName(childProductId);
- this.updateProductAttributes(childProductId);
- this.updateFormProductId(childProductId);
- this.addParentProductIdToCartForm(this.config.productId);
- this.showCustomOptionsBlock(childProductId, this.config.productId);
- if (usingZoomer) {
- this.showFullImageDiv(childProductId, this.config.productId);
- }else{
- this.updateProductImage(childProductId);
- }
- }
- //added else if for when just a kleurproduct is selected
- else if (kleurproduct_value) {
- for (var product in childProducts) {
- //find the kleurproduct attribute in the childProduct html
- var colStartPos = childProducts[product].productAttributes.indexOf('<th class="label">kleurproduct</th>')
- colStartPos = childProducts[product].productAttributes.indexOf('>', colStartPos + 28)
- var colEndPos = childProducts[product].productAttributes.indexOf('</td>', colStartPos)
- //check each child product for matching kleurproduct
- if (childProducts[product].productAttributes.substr(colStartPos + 1, colEndPos - colStartPos - 1)==kleurproduct_value) {
- childProductId = product;
- var price = childProducts[childProductId]["price"];
- var finalPrice = childProducts[childProductId]["finalPrice"];
- optionsPrice.productPrice = finalPrice;
- optionsPrice.productOldPrice = price;
- optionsPrice.reload();
- optionsPrice.reloadPriceLabels(true);
- optionsPrice.updateSpecialPriceDisplay(price, finalPrice);
- this.updateProductShortDescription(childProductId);
- this.updateProductDescription(childProductId);
- this.updateProductName(childProductId);
- this.updateProductAttributes(childProductId);
- this.updateFormProductId(childProductId);
- this.addParentProductIdToCartForm(this.config.productId);
- this.showCustomOptionsBlock(childProductId, this.config.productId);
- if (usingZoomer) {
- this.showFullImageDiv(childProductId, this.config.productId);
- }else{
- this.updateProductImage(childProductId);
- }
- //one product was found, exit the loop
- break;
- }
- }
- }
- else {
- var cheapestPid = this.getProductIdOfCheapestProductInScope("finalPrice");
- //var mostExpensivePid = this.getProductIdOfMostExpensiveProductInScope("finalPrice");
- var price = childProducts[cheapestPid]["price"];
- var finalPrice = childProducts[cheapestPid]["finalPrice"];
- optionsPrice.productPrice = finalPrice;
- optionsPrice.productOldPrice = price;
- optionsPrice.reload();
- optionsPrice.reloadPriceLabels(false);
- optionsPrice.updateSpecialPriceDisplay(price, finalPrice);
- this.updateProductShortDescription(false);
- this.updateProductDescription(false);
- this.updateProductName(false);
- this.updateProductAttributes(false);
- this.showCustomOptionsBlock(false, false);
- if (usingZoomer) {
- this.showFullImageDiv(false, false);
- }else{
- this.updateProductImage(false);
- }
- }