Post by bruce » Wed Sep 03, 2008 10:08 pm

Hi Qphoria,

A solution to session persistence is mentioned here.
Qphoria wrote: But I'm still hitting moments where it doesn't refresh because all those requirements are met, but there was something changed.
What was changed that was not recognised as a change?

But as a stab in the dark, try using the accessor functions $language->getCode() and $currency->getCode() instead of the class variables which don't always seem to contain the values you might expect. Also use strcmp() for the string comparisons. Its nit picky stuff but might help.  :)

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by Qphoria » Wed Sep 03, 2008 11:19 pm

bruce wrote:
Qphoria wrote: But I'm still hitting moments where it doesn't refresh because all those requirements are met, but there was something changed.
What was changed that was not recognised as a change?
Well for this last test, I started the checkout process. It gave me the quotes. Then I changed the address, and the quotes were the same. So that's another one that needs to be checked.

I will switch to the accessor functions, but even as they are, all of my checks are working when they hit, its just trying to catch all the ones I don't have yet.

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by ogun » Sun Sep 14, 2008 12:23 am

have you done any more on this Qphoria? just ran into the same issue while making a shipping module for European airmail.

Active Member

Posts

Joined
Tue Aug 14, 2007 6:04 am

Post by Qphoria » Sun Sep 14, 2008 12:31 am

ogun wrote: have you done any more on this Qphoria? just ran into the same issue while making a shipping module for European airmail.
For my USPS shipping module I finalized on the following session checks:

Code: Select all

function quote() {
    
    // Check session variables to see if new quote download is necessary  
    $ret = $this->session->get('usps_quotes');
    if (is_array($this->session->get('usps_quotes')) 
       && ($this->cart->getWeight() == $this->session->get('last_weight'))
       && (count($this->cart->products) == ($this->session->get('last_item_count')))
       && ($this->currency->code == ($this->session->get('last_currency')))
       && ($this->language->code == ($this->session->get('last_language')))
       && ($this->session->get('customer_id') == ($this->session->get('last_cust_id')))
       && ($this->session->get('shipping_address_id') == ($this->session->get('last_address_id'))) 
       && (count($ret['quote']))) {
       $ret['title'] = str_replace('*', '', $ret['title']); //remove asterisk if quotes are old
       return $ret;
    }//
at the start of my quote function, and at the end:

Code: Select all

// Session Persistence to prevent reprocessing of quotes unless one of these have changed.
      $this->session->set('usps_quotes', $method_data); // persist existing quotes to avoid multiple loops.
      $this->session->set('last_weight', $shipping_weight); //persist cart weight to check for changes in weight.
      $this->session->set('last_item_count', count($this->cart->products)); //persist product count to check for changes in qty.
      $this->session->set('last_currency', $this->currency->code); //persist currency to properly show money descriptor.
      $this->session->set('last_language', $this->language->code); //persist language to properly show matching language.
      $this->session->set('last_cust_id', $this->session->get('customer_id')); //persist customer_id to properly get new quotes.
      $this->session->set('last_address_id', $this->session->get('shipping_address_id')); //persist address_id to properly get new quotes.
      //
      
      return $method_data;
    }// if status
  } // EOF Quote
}
Needed all that to ensure proper quoting.. and I had no problems in a whole week of testing with those settings. Feel free to DL the USPS contrib from the download section to see other tricks.
Last edited by Qphoria on Sun Sep 14, 2008 12:35 am, edited 1 time in total.

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am
Who is online

Users browsing this forum: No registered users and 4 guests