Guest topjones Posted July 20, 2005 Share Posted July 20, 2005 Here's a little thing I did to calculate shipping on the amount spent. Use the supplied Flat_Rate calc.php as your standard file and shipping method. Modify the calc.php file by adding these lines below the line that says $taxVal = taxRate($module['tax']); Add this : if ($subTotal <= 25.00) {$sum = 3.50;} elseif ($subTotal >= 25.01 && $subTotal <= 50.00) {$sum = 4.50;} elseif ($subTotal >= 50.01 && $subTotal <= 100.00) {$sum = 5.50;} elseif ($subTotal >= 100.01 && $subTotal <= 200.00) {$sum = 6.50;} elseif ($subTotal >= 200.01 && $subTotal <= 300.00) {$sum = 7.50;} elseif ($subTotal >= 300.01 && $subTotal <= 400.00) {$sum = 8.50;} elseif ($subTotal >= 400.01 && $subTotal <= 500.00) {$sum = 9.50;} elseif ($subTotal >= 500.01) {$sum = 11.00;} Comment out this line $sum = $module['cost']; so it looks like this //$sum = $module['cost']; Of course you would change the totals for whatever you needed. Leave the module name the same (Flat Rate), and don't mess with the admin. It will still appear as 'Flat Rate' which still works out to make sense. It's a flat rated based on the amount spent. I still would put a note / add a page about your shipping costs. Quote Link to comment Share on other sites More sharing options...
Guest Ian MacMillan Posted July 22, 2005 Share Posted July 22, 2005 Thanks, just the table rate shipping I was looking for! Now if we could just add a "simple" if statement for "if not US" shipping = $such and such. I should spend some time with this...Been so busy though! Quote Link to comment Share on other sites More sharing options...
Guest alyn Posted July 24, 2005 Share Posted July 24, 2005 Just what I've been looking for as none of my shipping modules would work with my install... grrr I modified the posted code to include a country code look up and return relevant shipping proices. With prelimenary testing it seems to work fine, though I am no PHP coder, so I am sure there is a more efficient way to achieve what I've coded. I am in Canada so I needed to work out Canadian, then US and then International orders (though I will most likely use this for UK orders). The code looks like this: // get the delivery ISO $countryISO = countryIso($basket['delInf']['country']); //work out Canada shipping fees if ($countryISO == "CA") { if ($subTotal <= 25.00) {$sum = 5.50;} elseif ($subTotal >= 25.01 && $subTotal <= 50.00) {$sum = 6.50;} elseif ($subTotal >= 50.01 && $subTotal <= 100.00) {$sum = 7.50;} elseif ($subTotal >= 100.01 && $subTotal <= 200.00) {$sum = 11.50;} elseif ($subTotal >= 200.01 && $subTotal <= 300.00) {$sum = 15.50;} elseif ($subTotal >= 300.01 && $subTotal <= 400.00) {$sum = 17.50;} elseif ($subTotal >= 400.01 && $subTotal <= 500.00) {$sum = 20.50;} elseif ($subTotal >= 500.01) {$sum = 30.50;} //work out US shipping fees } elseif ($countryISO == "US") { if ($subTotal <= 25.00) {$sum = 6.50;} elseif ($subTotal >= 25.01 && $subTotal <= 50.00) {$sum = 7.50;} elseif ($subTotal >= 50.01 && $subTotal <= 100.00) {$sum = 8.50;} elseif ($subTotal >= 100.01 && $subTotal <= 200.00) {$sum = 10.50;} elseif ($subTotal >= 200.01 && $subTotal <= 300.00) {$sum = 20.50;} elseif ($subTotal >= 300.01 && $subTotal <= 400.00) {$sum = 30.50;} elseif ($subTotal >= 400.01 && $subTotal <= 500.00) {$sum = 30.50;} elseif ($subTotal >= 500.01) {$sum = 40.00;} //work out Intl shipping fees } else { if ($subTotal <= 25.00) {$sum = 7.50;} elseif ($subTotal >= 25.01 && $subTotal <= 50.00) {$sum = 10.50;} elseif ($subTotal >= 50.01 && $subTotal <= 100.00) {$sum = 15.50;} elseif ($subTotal >= 100.01 && $subTotal <= 200.00) {$sum = 21.50;} elseif ($subTotal >= 200.01 && $subTotal <= 300.00) {$sum = 26.50;} elseif ($subTotal >= 300.01 && $subTotal <= 400.00) {$sum = 31.50;} elseif ($subTotal >= 400.01 && $subTotal <= 500.00) {$sum = 36.50;} elseif ($subTotal >= 500.01) {$sum = 42.50;} } Please post any refinements. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.