2013-07-01 172 views
0

我需要設置我的購物車,並至少需要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 "; 
} 
} 
+1

爲什麼你在PHP中使用'
'?如果你想使用它,你必須首先逃脫PHP,所以它將被視爲HTML – am05mhz

回答

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 "; 
} 
相關問題