Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Make shipping modules available according to weight


pushlatency

Recommended Posts

I'm curious if anyone has altered or has any thoughts on altering this the shopping cart to select a certain module automaticly when the combined product weight is over a certain value (i.e. 50+ pounds).

 

This would help alot as i'm working on a store which sells some light items that we'd quote via UPS right away, but we also ship large machine items that will first need a quote put together before the customer can be charged.

 

I'm not great with PHP by any means, but I way thinking about a simple IF statement like this

 

if ($total_weight < 50) {
 $quotes = $shipping_modules->quote();
 }
 else {
 $quotes = $shipping_modules->quote(MODULE_SHIPPING_RFQ_TEXT_TITLE);
 }

 

However, i'm really not sure how to call just this module specificly, instead of all the installed shipping modules.

 

My other thought would be to have the array of installed/active shipping modules change according to the cart weight. I'm really not sure which method is more complicated.

 

Any help would be greatly appreciated.

Thanks,

Harris

Link to comment
Share on other sites

change the shipping modules themselves based on the $total_weight global. Set the variable as a global on the constructor of the shipping module then activate the module based on the variable's value.

 

for example at the end of the constructor of an active shipping module you have with your store you could do:

 

	   if ($total_weight>50) {
	  $this->enabled = false;
	}

 

and you can even enhance the shipping module to include an extra configuration parameter so you can control it via the admin for each shipping module.

Link to comment
Share on other sites

Mark explained it perfectly I'll just show you an example of a shipping module I only wanted to show if the weight was over a certain value (set in admin by a key)

 

.....
	if ($check_flag == false) {
	  $this->enabled = false;
	}
  }

		if (is_object($order)) {
// disable the module if the order weighs less than MODULE_SHIPPING_OVERSIZED_LIMIT
			if ($this->enabled == true) {
				global $cart;
				if ($cart->show_weight() <= MODULE_SHIPPING_OVERSIZED_LIMIT) {
					$this->enabled = false;
				}
			}
		}

HTH!

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...