我只是在放置用户点的行中添加一个 id,在 simpleCart_total 中添加一个 id,在总结果 Your Value Points 中添加一个 id:
<tr><td class='odd'>Total Items: </td><td class='even'><span id='simpleCart_quantity' class='simpleCart_quantity'></span></td></tr>
<tr><td class='odd'>SubTotal: </td><td class='even'><span id='simpleCart_total' class='simpleCart_total'>4</span></td></tr>
<tr>
<td class='odd'> </td>
<td class='even'> </td>
</tr>
<tr>
<td class='odd'>Total</td>
<td class='even' id="total"> </td>
</tr>
</tbody>
</table>
然后每次添加或删除项目时调用此函数:
<script>
function total(){
var points = parseFloat(document.getElementById('points').innerHTML);
var simpleCart_total = parseFloat(document.getElementById('simpleCart_total').innerHTML);
var total = document.getElementById('total');
total.innerHTML = points-simpleCart_total;
}
</script>
编辑
我不知道它是否会起作用,但你可以试试。备份您的文件 javascript/cart.js,然后找到并替换此代码:
for(var c=0;a.childNodes[c];c++){var d=a.childNodes[c];if(d.className&&d.className.match(/item_[^ ]+/)){var e=/item_[^ ]+/.exec(d.className)[0].split("_");if(e[1]=="add"||e[1]=="Add"){var f=[];f.push(d);var g=simpleCart.Shelf.addToCart(b.id);simpleCart.addEventToArray(f,g,"click");d.id=b.id}else{b[e[1]]=d}}
为了这:
for(var c=0;a.childNodes[c];c++){var d=a.childNodes[c];if(d.className&&d.className.match(/item_[^ ]+/)){var e=/item_[^ ]+/.exec(d.className)[0].split("_");if(e[1]=="add"||e[1]=="Add"){var f=[];f.push(d);var g=simpleCart.Shelf.addToCart(b.id);simpleCart.addEventToArray(f,g,"click");d.id=b.id}else{b[e[1]]=d}}var points=parseFloat(document.getElementById('points').innerHTML);var simpleCart_total = parseFloat(document.getElementById('simpleCart_total').innerHTML);var total=document.getElementById('total');total.innerHTML=points-simpleCart_total;
不要忘记将 id 'total' 添加到要显示结果的单元格中