Post by boboxx » Fri May 02, 2008 3:52 am

Hello guys,

I built a new shipping module for Canada Post, everything is working but the problem I have is that checkout_confirm is really slow.... after looking a bit, I it looks like the shipping module is being executed about 14 time!! Why is that?

My problem is that this is executing the Canada post web service way to many times. I tried to see where these where being called, but can figure it out.

Thanks

Newbie

Posts

Joined
Fri May 02, 2008 3:40 am

Post by bruce » Fri May 02, 2008 7:50 am

It is impossible to even speculate on what is wrong.

You will need to post the shipping module code and any other changes you made to controller files or templates etc.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by boboxx » Fri May 02, 2008 9:20 am

heheh yes I'm sure that would help!

here it is:
http://www.charetx2.com/oc/canadapost.zip

Newbie

Posts

Joined
Fri May 02, 2008 3:40 am

Post by bruce » Fri May 02, 2008 9:32 am

I will have a look over the weekend.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by Luvz2drv » Mon May 05, 2008 4:35 pm

hey boboxx    instead of looping thru all the products in the cart  use this

$cart_weight = $this->cart->getWeight();

it returns the value of the weight in the stores default weight (with quantity taken into account)..  you will need to custom it form there ..  remember each product can have its own weight type... :)     

also in my lib folder in the cart for weight.php  i added 2 new functions there  to help me out...

Code: Select all

function getID($unit) {
  		$id = $this->getDefaultID();
    	
    	//lets check the database for that unit -- language doen't matter as they all share the same id 
    	$results = $this->database->getRows("select weight_class_id from weight_class where unit = '$unit'");
    	if (count($results) >= 1) {
    		//just take the first one
			$id = $results[0]['weight_class_id'];
			return $id;
		} else {
			//no rows in the data - return the stores default
			return $id;
		}
    	
  	}
  	function getDefaultID() {
  		$weight_id_db = $this->database->getRows("SELECT value FROM `setting` WHERE `group` = 'config' and `key` = 'config_weight_class_id'");
		$weight_id = $weight_id_db[0]['value'];
		return $weight_id;
	}
came in handy as my stores weight default is in kg  -- but i needed to for my USPS to give me lb and oz

ussage i used....

Code: Select all

$cart_weight = $this->cart->getWeight();

$cart_weight_total = $this->weight->convert($cart_weight, $this->weight->getDefaultID(), $this->weight->getID('lb'));
			
$cart_weight_lbs = floor($cart_weight_total);
			
$cart_weight_oz_as_lbs = ($cart_weight_total - $cart_weight_lbs);
			
$cart_weight_oz = $this->weight->convert($cart_weight_oz_as_lbs, $this->weight->getID('lb'), $this->weight->getID('oz') );
			
hope some of that helps..

Jonathon

Global Moderator

Posts

Joined
Fri Mar 21, 2008 10:58 am

Post by bruce » Mon May 05, 2008 9:29 pm

You are perfectly correct. The code is being called 14 times. In fact, it turns out that all shipping methods will have this problem but since yours involves going to another web site for info and takes some time, you are the first person to notice.

Have a look in the file library\cart\shipping.php and you will see that it makes no attempt to persist its data and that each of the utility functions call the quote function redundantly after checkout_shipping.

However, you can get around this by persisting the results of the quote function in your shipping extension in the session object. Hence, if the quote value exists AND the cart has not changed, then use the session value instead of calling canadapost again. To compare with the cart, your shipping extension also needs to persist it's own definition of the cart contents. eg: products, quantities, dimensions and weight.

You will also have to persist the shipping address geo zone that was used to calculate the quote and compare that with the current shipping address geo zone.
Last edited by bruce on Mon May 05, 2008 9:45 pm, edited 1 time in total.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by Bijou » Thu May 22, 2008 5:20 am

So, from what's being said here, I guess there's currently no Canada Post shipping module that works?

Newbie

Posts

Joined
Fri Apr 11, 2008 10:45 pm

Post by Luvz2drv » Thu May 22, 2008 7:32 am

i have one that is about 65% done and not having this issue

also working on USPS one too

Global Moderator

Posts

Joined
Fri Mar 21, 2008 10:58 am
Who is online

Users browsing this forum: No registered users and 1 guest