2012-03-02 227 views
-1

我需要购物车中的商品图片。现在我只有产品名称。这里是链接 - http://layot.prestatrend.com/ 这里是代码产品的名称在车:购物车中的商品图片

//if product is not in the displayed cart, add a new product's line 
        var domIdProduct = this.id + (this.idCombination ? '_' + this.idCombination : ''); 
       var domIdProductAttribute = this.id + '_' + (this.idCombination ? this.idCombination : '0'); 
       if($('#cart_block_top dt#cart_block_top_product_'+ domIdProduct).length == 0) 
       { 
        var productId = parseInt(this.id); 
        var productAttributeId = (this.hasAttributes ? parseInt(this.attributes) : 0); 
        var content = '<dt class="hidden" id="cart_block_top_product_' + domIdProduct + '">'; 
         content += '<span class="quantity-formated"><span class="quantity">' + this.quantity + '</span>x</span>'; 
         var name = (this.name.length > 12 ? this.name.substring(0, 10) + '...' : this.name); 
         content += '<a href="' + this.link + '" title="' + this.name + '">' + name + '</a>'; 
         content += '<span class="remove_link"><a rel="nofollow" class="ajax_cart_block_top_remove_link" href="' + baseDir + 'cart.php?delete&amp;id_product=' + productId + '&amp;token=' + static_token + (this.hasAttributes ? '&amp;ipa=' + parseInt(this.idCombination) : '') + '"> </a></span>'; 
         content += '<span class="price">' + this.priceByLine + '</span>'; 
         content += '</dt>'; 
        if (this.hasAttributes) 
         content += '<dd id="cart_block_top_combination_of_' + domIdProduct + '" class="hidden"><a href="' + this.link + '" title="' + this.name + '">' + this.attributes + '</a>'; 
        if (this.hasCustomizedDatas) 
         content += ajaxCart.displayNewCustomizedDatas(this); 
        if (this.hasAttributes) content += '</dd>'; 
        $('#cart_block_top dl.products').append(content); 
       } 

所以可能有人帮助在车来分析产品的形象?

+0

这是什么反对?! – 2012-03-02 17:59:39

回答

0

您需要在

$('#cart_block_top dt#cart_block_top_product_'+ domIdProduct)创建图像占位符。

然后你可以发送图像的源作为this.image源。事情是这样的:

content += '<img src="' + this.imageSource' />'; 

抓住imageSource因为你是将它们分配给.product_image

只需将此产品图片src发送至displayNewProducts功能。

+0

为什么你不附加内容而不是'content + ='? – 2012-03-02 17:57:03

相关问题