Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

No shipping on virtual items in mixed shopping cart


dougfal

Recommended Posts

We sell real things and charge shipping using only a simple table based on order total.

However we also sell a few virtual things (subscriptions, gift certificates). All is fine when someone buys only real (shipping charged) or only virtual things (free shipping) but when they mix them, shipping is charged on the virtual as well as the real.

I see this has been discussed before and some folks are using weight - this is impractical for us.

I think it should be possible to add some code that reduces $order_total just for the purposes of calculating shipping, if any of these items are in the basket. I've flagged them using the model field e.g. "subEG".

Should I be looking at includes/modules/shipping/table.php? I see the code controlling the table cost calculation at line 51:

 

     if (MODULE_SHIPPING_TABLE_MODE == 'price') {
       $order_total = $cart->show_total();
     } else {
       $order_total = $shipping_weight;
     }

     $table_cost = split("[:,]" , MODULE_SHIPPING_TABLE_COST);
     $size = sizeof($table_cost);
     for ($i=0, $n=$size; $i<$n; $i+=2) {
       if ($order_total <= $table_cost[$i]) {
         $shipping = $table_cost[$i+1];
         break;
       }
     }

 

How can I add ifs to amend $order_total for this calculation?

Thanks in advance...

Link to comment
Share on other sites

I've figured out a workaround for this all by myself (preen).

I've made the table rate shipping module use weight, made every item's weight the same as the price inc. tax except for the virtual items (weight = 0).

Kept the table itself the same except added 0.01:0.00, at the beginning.

You need to make the weight limit artificially high in Config/Shipping&Packaging, and make tare weight = 0, and have no percentage increase.

It seems to work. Apologies if this was the intent in other threads discussing this problem - it didn't strike me that it could work so easily.

Link to comment
Share on other sites

Oh, and one more thing. You can transfer the price to the weight column all in one go in phpMyAdmin using an SQL statement like:

UPDATE `database_name`.`products` SET `products_weight` = `products_price`;

Or if you need to add 10% tax to the raw price:

UPDATE `database_name`.`products` SET `products_weight` = `products_price`*1.1;

Then edit the items with free shipping back to weight = 0.

BACK UP YOUR DATABASE BEFORE DOING ANY SQL OPERATIONS!!!!!!!!!!!!!!!!!!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...