Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 20th, 2012  |  syntax: None  |  size: 4.28 KB  |  hits: 6  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Magento - Show simple product image and description
  2. Product.Config.prototype.reloadPrice = function() {
  3. var childProductId = this.getMatchingSimpleProduct();
  4. var childProducts = this.config.childProducts;
  5. var attribID = 158;
  6. var kleurproductDropdown = document.getElementById('attribute' + attribID);
  7. var kleurproductSelectedIndex = kleurproductDropdown.selectedIndex;
  8. var kleurproduct_value  = kleurproductDropdown.options[kleurproductSelectedIndex].text;
  9. //if the price ranges option is checked in the backend then a colon and the price is added to the dropdown
  10. if (kleurproduct_value.indexOf(':') > -1) {
  11.     kleurproduct_value = kleurproduct_value.substr(0,kleurproduct_value.indexOf(':'));
  12. }
  13. var usingZoomer = false;
  14. if(this.config.imageZoomer){
  15.     usingZoomer = true;
  16. }
  17.  
  18. if (childProductId){
  19.     var price = childProducts[childProductId]["price"];
  20.     var finalPrice = childProducts[childProductId]["finalPrice"];
  21.     optionsPrice.productPrice = finalPrice;
  22.     optionsPrice.productOldPrice = price;
  23.     optionsPrice.reload();
  24.     optionsPrice.reloadPriceLabels(true);
  25.     optionsPrice.updateSpecialPriceDisplay(price, finalPrice);
  26.     this.updateProductShortDescription(childProductId);
  27.     this.updateProductDescription(childProductId);
  28.     this.updateProductName(childProductId);
  29.     this.updateProductAttributes(childProductId);
  30.     this.updateFormProductId(childProductId);
  31.     this.addParentProductIdToCartForm(this.config.productId);
  32.     this.showCustomOptionsBlock(childProductId, this.config.productId);
  33.     if (usingZoomer) {
  34.         this.showFullImageDiv(childProductId, this.config.productId);
  35.     }else{
  36.         this.updateProductImage(childProductId);
  37.     }
  38.  
  39. }
  40. //added else if for when just a kleurproduct is selected
  41. else if (kleurproduct_value) {
  42.     for (var product in childProducts) {
  43.         //find the kleurproduct attribute in the childProduct html
  44.         var colStartPos = childProducts[product].productAttributes.indexOf('<th class="label">kleurproduct</th>')
  45.         colStartPos = childProducts[product].productAttributes.indexOf('>', colStartPos + 28)
  46.         var colEndPos = childProducts[product].productAttributes.indexOf('</td>', colStartPos)
  47.         //check each child product for matching kleurproduct
  48.         if (childProducts[product].productAttributes.substr(colStartPos + 1, colEndPos - colStartPos - 1)==kleurproduct_value) {
  49.             childProductId = product;
  50.             var price = childProducts[childProductId]["price"];
  51.             var finalPrice = childProducts[childProductId]["finalPrice"];
  52.             optionsPrice.productPrice = finalPrice;
  53.             optionsPrice.productOldPrice = price;
  54.             optionsPrice.reload();
  55.             optionsPrice.reloadPriceLabels(true);
  56.             optionsPrice.updateSpecialPriceDisplay(price, finalPrice);
  57.             this.updateProductShortDescription(childProductId);
  58.             this.updateProductDescription(childProductId);
  59.             this.updateProductName(childProductId);
  60.             this.updateProductAttributes(childProductId);
  61.             this.updateFormProductId(childProductId);
  62.             this.addParentProductIdToCartForm(this.config.productId);
  63.             this.showCustomOptionsBlock(childProductId, this.config.productId);
  64.             if (usingZoomer) {
  65.                 this.showFullImageDiv(childProductId, this.config.productId);
  66.             }else{
  67.                 this.updateProductImage(childProductId);
  68.              }
  69.             //one product was found, exit the loop
  70.             break;
  71.          }
  72.     }
  73. }
  74. else {
  75.     var cheapestPid = this.getProductIdOfCheapestProductInScope("finalPrice");
  76.     //var mostExpensivePid = this.getProductIdOfMostExpensiveProductInScope("finalPrice");
  77.     var price = childProducts[cheapestPid]["price"];
  78.     var finalPrice = childProducts[cheapestPid]["finalPrice"];
  79.     optionsPrice.productPrice = finalPrice;
  80.     optionsPrice.productOldPrice = price;
  81.     optionsPrice.reload();
  82.     optionsPrice.reloadPriceLabels(false);
  83.     optionsPrice.updateSpecialPriceDisplay(price, finalPrice);
  84.     this.updateProductShortDescription(false);
  85.     this.updateProductDescription(false);
  86.     this.updateProductName(false);
  87.     this.updateProductAttributes(false);
  88.     this.showCustomOptionsBlock(false, false);
  89.     if (usingZoomer) {
  90.         this.showFullImageDiv(false, false);
  91.     }else{
  92.         this.updateProductImage(false);
  93.     }
  94. }