在 模板目录下 /catalog/product/viw/addtocart.phtml文件中添加如下代码,具体参考三笑的效果
<script> jQuery('.qty-btn-block > span').click(function(){ var qty=jQuery("#qty").val();
price=<?php echo $_product->getFinalprice()?>//total=qty*1total=parseInt(qty)*price;total=total.toFixed(2);jQuery("#b_price").html(total);})
</script> <div class="Total"><strong>Total: </strong><span id="allPrices"><span>US$ <b id="b_price"><?php echo $_product->getFinalprice();?></b><span></span>
</div> <div id="teroop"> <button type="button" title="<?php echo $buttonTitle ?>" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><span><?php echo $buttonTitle ?></span></span></button> </div> <div id="teroo" style="display:none;"> <button type="button" class="teroi" onclick="javascript:window.location.href='<?php echo Mage::getBaseUrl('web')?>checkout/cart'"><span><span></span></span></button> </div> <div id="loaddingtext" style="display:none"> <img src="<?php echo $this->getSkinUrl('images/terry/adding.gif'); ?>">Adding... </div> <div id="addsusess" style="color:#21A308;display:none"> <img src="<?php echo $this->getSkinUrl('images/terry/loading_comp.png'); ?>">Add to cart successfully </div> <?php echo $this->getChildHtml('', true, true) ?> </div>
php中获取价格可以通过 $_product->getFinalprice();