Post by thanaa » Wed May 06, 2009 11:52 pm

I've got a question regarding when and why a model is loaded (specifically the shipping models). I've been working on a custom shipping model that grabs a rate quote from a truckline carrier and returns the values for my shipping total. The rate part works fine, im getting my numbers and everything. However what i ran into was that after cart changes (specifically changing the quantity of an item) that the shipping page used the shipping quote that was stored in the session from the previous quote. After a while i realized that the model wasn't being called again bc of this line in catalog/controller/checkout/shipping.php.

Code: Select all

if (!isset($this->session->data['shipping_methods'])  {
Which was looking to see if shipping_methods had been stored in teh session and if so it wasn't loading the shipping models. Now, as a dirty hack bc i was coming up on 5pm and needed a visible solution to show the cart owner, i changed it to this.

Code: Select all

if (!isset($this->session->data['shipping_methods']) || isset($this->session->data['force_update'])) {
and in systems/library/cart.php i changed the add, update, and remove functions to contain this line after they completed their normal duties.

Code: Select all

$this->session->data['force_update'] = TRUE;
Then at the end of the If statement in shipping.php i just added

Code: Select all

unset($this->session->data['force_update']);
so that it wouldn't continually requery the quote API on our trucklines site every page refresh.

Ugh, after writing all that i just found where you unset($this->session->data['shipping_methods']) in the address controller. However, im still at a bit of a loss as how to eliminate my problem. Unsetting those 2 session variables on every add/remove/update cart call doesnt' seem like the cleanest way to fix my problem, but is that my only solution? I have to have it load the model if theres been changes, bc they change the weight, which in turn changes the quote. And, im going to run into the same issues when i start in on the UPS shipping model, so im hoping to find a better way to force the reloading of the models on any cart changes.

New member

Posts

Joined
Tue May 05, 2009 2:12 am

Post by Daniel » Fri May 08, 2009 4:27 am

trust me it was working fine before.

You have to update when you aadd a new product because the weight changes.

User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by thanaa » Fri May 08, 2009 5:58 am

Daniel wrote:trust me it was working fine before.

You have to update when you aadd a new product because the weight changes.
Ya i know it has to update , the weight was my issue. For whatever reason when i was updating my cart after choosing a shipping method my weight was returning as 1lb last night. However after reading your reply i restored the original files (cart.php in library, and the shipping controller) and its working properly. Yesterday anytime i was adding/removing something to the cart before i made the changes i listed above, getWeight() would return 1.

/shrug I am still curious just bc i've not found it yet, where the shipping method is unset when the cart is changed. I see it for address changes, but haven't found it for cart changes.

New member

Posts

Joined
Tue May 05, 2009 2:12 am

Post by Daniel » Fri May 08, 2009 6:00 am

shipping method is unset when ever you add, update, remove the cart.

When ever you change address, login or log out, checkout.

User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm
Who is online

Users browsing this forum: No registered users and 11 guests