Approached recently by a potential customer who needs to set up a system for charging postage on a per product basis, per geographic zone. This needs to work as a “extra cost” on top of the usual shipping cost. Think in terms of an awkward to send product where you might want to charge $10 extra on top of the usual shipping fee. I’ll illustrate this with an example…
Step 1: Set up a couple of zones (for shipping purposes)
Although this says “tax zones” they can be used for shipping geographically.
Step 2: Edit (or create) a product
On this page we have extra input box asking for the shipping price per zone.
This defaults to zero, in here you can insert different price per zone. In the example, I’ll make the fee 5 for UK and 10 for Europe. I press “Save” to update the details of the product.
Step 3: Set up your Shipping Method(s)
For this example I’ll use the easiest (to look at) shipping module which is “flat rate”. I’ve set the fee to 2.50 flat fee for all orders.
Making an Order
If I now place into my cart a product that has NO extra cost set up, the shipping module will return 2.50 as the shipping cost.
Now if I also add a product that I have placed an extra cost (Unreal Tournament in this example), the shipping should show a total of 7.50 (which is 2.50 flat fee + UK extra cost of 5).
Hopefully, you’ll have read between the lines and understand that I could just as easily have created a new shipping module to only read the value of the extra cost parameter (per zone). In this way, I can set shipping prices per product and not have to have it react as a “surcharge” on top of an existing shipping module (as shown in this example).
Hopefully you can see that osCommerce is fairly easy to modify if you work out what you need to do in advance, understand how osCommerce hangs together and then stick to the project at hand.
For this example, the main files modified are admin/categories.php and the order_class file. The rest is simple arithmetic.