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
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
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...
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....
hope some of that helps..
Jonathon
$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;
}
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') );
Jonathon
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.
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.
Who is online
Users browsing this forum: No registered users and 1 guest