购物车最低金额

时间:2013-07-01 19:35:00

标签: php cart minimum shopping

我需要设置我的购物车,最低金额为20美元才能继续结帐。 这是我的代码请帮助

$cartOutput = "";<br />
$cartTotal = "";<br />
$minim = "20";<br />
$pp_checkout_btn = '';<br />
$product_id_array = '';<br />

setlocale(LC_MONETARY, "en_US");<br />
$cartTotal = money_format("%10.2n", $cartTotal);<br />
$minim = money_format("%10.2n", $minim);<br />


// Finish the  Checkout Btn

if ($cartTotal > $minim )<br />{<br />
     $pp_checkout_btn .=<br />'<form>
    <input type="hidden" name="custom" value="' . $product_id_array . '" accept-charset="UTF-8">
    <input type="hidden" name="notify_url" value="https://www.com//.php">
    <input type="hidden" name="return" value="https://www.gogrocerycart.com/checkout_complete.php">
    <input type="hidden" name="rm" value="2">
    <input type="hidden" name="cbt" value="Return to The Store">
    <input type="hidden" name="cancel_return" value="https://www.gogrocerycart.com/paypal_cancel.php">
    <input type="hidden" name="lc" value="US" accept-charset="UTF-8">
    <input type="hidden" name="currency_code" value="USD">
    <input type="image" align="right" src="http://www.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with  - its fast, free and secure!">
    </form>';
}else{<br />
     $pp_checkout_btn .= "A minimum of ". $minim ." is required ";
}
}

2 个答案:

答案 0 :(得分:0)

您正在比较两个字符串。您需要在检查money_format之后转换字符串($cartTotal > $minimum)还是再声明两个字符串(“格式化”值)

$cartOutput = "";
$cartTotal = 0;
$minim = 20.00;
$pp_checkout_btn = '';
$product_id_array = '';

setlocale(LC_MONETARY, "en_US");
$cartTotalFormatted = money_format("%10.2n", $cartTotal);
$minimFormatted = money_format("%10.2n", $minim);

// Finish the Checkout Btn
if ($cartTotal > $minim )
{
  $pp_checkout_btn .= ' ';
} else {
  $pp_checkout_btn .= "A minimum of ". $minimFormatted ." is required "; 
}

答案 1 :(得分:0)

对我来说有点专业。我只是使用zencart打开我的网站http://www.hvgbuilding.com/