About Club osCommerce

Showcasing osCommerce…the good, the bad and the ugly!

Follow osc_pro on Twitter

osCommerce Quiz?

Written By Gary on Dec 18 2009 · Comments (8) Follow osc_pro on Twitter

An osCommerce Quiz for you to think about;

PHP:
  1. switch (tep_get_zone_code($order->delivery['country']['id'], $order->delivery['zone_id'], '')) {         
  2.           case 'HI':
  3.           case 'AK':
  4.           $extra_cost = ($cart->show_total() * (13/100));
  5.           break;         
  6.           default:
  7.           $extra_cost = 0;
  8.           switch ($order->delivery['country']['iso_code_2']) {             
  9.               case 'US':
  10.               $extra_cost = 0;
  11.               break;             
  12.               default:
  13.               $extra_cost = ($cart->show_total() * (13/100));
  14.           }
  15.       }

And then an extra piece of code like this, elsewhere in the file...

PHP:
  1. + $extra_cost

I came up with proof of concept code (proof of concept is just that, it shows it work but might not be the most graceful codebase) to illustrate something. Thought it might be interesting for you guys to see some code with no explanation, and find out what the code is for.

So, questions;

1. In which file(s) could this code be placed?
2. Which country/countries add NO cost?
3. Which states add an extra cost?
4. What is the extra cost?


Buy Gary A Beer?
Buying me a "beer" helps me to keep my contributions updated and keep this blog alive - and you get a link from my homepage to your site. Cheers!


8 Comments

  1. Your code is much cleaner than mine for the same functionality. I used a series of if statements to determine if the zone should incur extra costs:

    if ($order->delivery[zone_id] == 21) $remote=1;

    I then use a model to determine the extra costs associated for the remote zones:

    if ($remote == 1) {
    $shipping += (13.00 + ($shipping_weight * 1.4));
    if ($shipping_num_boxes > 1) $shipping += ($shipping * $shipping_num_boxes);
    }

    You will see I charge a remote surcharge based on weight and an additional fee. I also increase the cost based on the number of boxes.

    I hate it when the first comment of a blog posts like this answers the question. So I did not answer your questions, but my comment will make it easier for someone to figure it the answers.

    jeff

    Comment by Jeff — December 19, 2009 @ 1:58 pm


  2. Hey Jeff – well, you & I know the answer, I guess no-one else does! Or no-one reads my blog other than you and I lol :D

    Comment by Gary — December 20, 2009 @ 12:52 pm


  3. others are shopowners and too busy with the holiday sales ?
    eeuh, second question answered … ?

    Comment by Carine — December 23, 2009 @ 8:49 pm


  4. Own a shop, but our peak season is in April/May. It is our slow time of the year.

    Comment by Wedding Favors — December 24, 2009 @ 5:14 am


  5. Any prizes?

    I am guessing its added in the shipping modules (includes/modules/shipping). For Hawaii and Alaska and anything outside of USA, an extra fee of 13% is added.

    Comment by Jackal — December 28, 2009 @ 5:24 pm


  6. Exactly correct Jackal :)

    Comment by Gary — December 28, 2009 @ 8:59 pm


  7. I forgot to add, that you might want to put case 'PR' too. Coz Puerto Rico is not in continental USA but considered country code USA.

    Comment by Jackal — December 29, 2009 @ 4:52 pm


  8. Thanks Jackal – I never knew that PR was considered a part of the USA.

    Comment by Gary — December 31, 2009 @ 10:21 am


Leave a comment

RSS feed for comments on this post · TrackBack URL

Hot 100 osCommerce Shops

View the osCommerce HOT 100These are the best looking, most exceptional osCommerce Stores as voted for by you.

New to osCommerce - get inspiration from these beautiful shops. Reckon your site has what it takes to become a member of the HOT 100? Submit it!