Presto-X Posted March 12, 2009 Share Posted March 12, 2009 Hello everyone, I'm working on a checkout module and I have the subtotals and totals working great but I need to add price based shipping so if the price is $0.00 to $225.00 the shipping would cost $10.00 ext. ext. This is my code I dont think I'm doing this right??? if (($subtotal <= "0.00") ||($subtotal >= "225.00")) {$shipping = "10.00";} elseif (($subtotal <= "226.00") ||($subtotal >= "550.00")) {$shipping = "20.00";} elseif (($subtotal <= "551.00") ||($subtotal >= "750.00")) {$shipping = "30.00";} elseif (($subtotal <= "751.00") ||($subtotal >= "1150.00")){$shipping = "40.00";} elseif (($subtotal <= "1151.00")||($subtotal >= "2250.00")){$shipping = "67.50";} elseif (($subtotal <= "2251.00")||($subtotal >= "3250.00")){$shipping = "97.50";} elseif (($subtotal <= "3251.00")||($subtotal >= "4250.00")){$shipping = "127.50";} elseif ($subtotal <= "4251.00") {$shipping = "150.00";} Link to comment https://forums.phpfreaks.com/topic/149171-solved-price-based-shipping/ Share on other sites More sharing options...
Maq Posted March 12, 2009 Share Posted March 12, 2009 No, that's wrong. And why don't you test it to see if it's right? You need to reverse all of your less than and greater signs. You also have to use && and not ||. A side note, you don't need to put quotes around doubles. Link to comment https://forums.phpfreaks.com/topic/149171-solved-price-based-shipping/#findComment-783274 Share on other sites More sharing options...
Presto-X Posted March 12, 2009 Author Share Posted March 12, 2009 I did test it and it did not work lol Thanks Maq, This is my working code in case others can use it in their project. if (($subtotal >= '0.00') &&($subtotal <= '225.00')) {$shipping = '10.00';} elseif (($subtotal >= '226.00') &&($subtotal <= '550.00')) {$shipping = '20.00';} elseif (($subtotal >= '551.00') &&($subtotal <= '750.00')) {$shipping = '30.00';} elseif (($subtotal >= '751.00') &&($subtotal <= '1150.00')){$shipping = '40.00';} elseif (($subtotal >= '1151.00')&&($subtotal <= '2250.00')){$shipping = '67.50';} elseif (($subtotal >= '2251.00')&&($subtotal <= '3250.00')){$shipping = '97.50';} elseif (($subtotal >= '3251.00')&&($subtotal <= '4250.00')){$shipping = '127.50';} elseif ($subtotal >= '4251.00') {$shipping = '150.00';} Link to comment https://forums.phpfreaks.com/topic/149171-solved-price-based-shipping/#findComment-783296 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.