我昨天就知道了。它採取了幾個步驟。這裏是代碼:
var DealerVar = $('.cart-block-item-title a').attr('href')
var cartTotal = $(".cart-block-summary-total > span").text().replace(',', '').replace('$', '');
var DealerVar2 = DealerVar.split('/');
var DealerVar3 = DealerVar2[1]
if (DealerVar3 == "dealers") {
if (cartTotal < 500.00)
{
$('.cart-block-checkout, #edit-checkout').click(function(){
alert ('In order to check out you need to have the minimum order amount in your cart for your pricing tier ($500). Please add more items to your cart.');
return false
});
}
}
var VolDealVar = $('.cart-block-item-title a').attr('href')
var cartTotal = $(".cart-block-summary-total > span").text().replace(',', '').replace('$', '');
var VolDealVar2 = VolDealVar.split('/');
var VolDealVar3 = VolDealVar2[1]
if (VolDealVar3 == "volume-dealers") {
if (cartTotal < 2000.00)
{
$('.cart-block-checkout, #edit-checkout').click(function(){
alert ('In order to check out you need to have the minimum order amount in your cart for your pricing tier ($2,000). Please add more items to your cart.');
return false
});
}
}
var DistributorVar = $('.cart-block-item-title a').attr('href')
var cartTotal = $(".cart-block-summary-total > span").text().replace(',', '').replace('$', '');
var DistributorVar2 = DistributorVar.split('/');
var DistributorVar3 = DistributorVar2[1]
if (DistributorVar3 == "distributors") {
if (cartTotal < 6000.00)
{
$('.cart-block-checkout, #edit-checkout').click(function(){
alert ('In order to check out you need to have the minimum order amount in your cart for your pricing tier ($6,000). Please add more items to your cart.');
return false
});
}
}
var VolDistributorVar = $('.cart-block-item-title a').attr('href')
var cartTotal = $(".cart-block-summary-total > span").text().replace(',', '').replace('$', '');
var VolDistributorVar2 = VolDistributorVar.split('/');
var VolDistributorVar3 = VolDistributorVar2[1]
if (VolDistributorVar3 == "volume-distributors") {
if (cartTotal < 10000.00)
{
$('.cart-block-checkout, #edit-checkout').click(function(){
alert ('In order to check out you need to have the minimum order amount in your cart for your pricing tier ($10,000). Please add more items to your cart.');
return false
});
}
}
你確定$('。uc-price).val返回一個正確的值嗎? – 2014-10-09 16:28:16
不,這是我需要幫助的一部分...我在三年內沒有像這樣做代碼,所以我很生鏽:( – abemonkey 2014-10-09 16:29:43
嘗試爲該標籤分配一個ID,然後訪問內部文本。 如果我在JS中是正確的,它應該像document.getElementByID(「yourID」)。innerHTML或Jquery $('#yourID')。html() – 2014-10-10 07:44:03