Alexander.X Posted November 25, 2017 Share Posted November 25, 2017 Cart.php @2587 public function getDeliveryOption($default_country = null, $dontAutoSelectOptions = false, $use_cache = true) { static $cache = array(); $cache_id = (int)(is_object($default_country) ? $default_country->id : 0).'-'.(int)$dontAutoSelectOptions; if (isset($cache[$cache_id]) && $use_cache) { return $cache[$cache_id]; } $delivery_option_list = $this->getDeliveryOptionList($default_country); this 'static $cache' cache is never cleared during script lifetime. Somehow it doesnt cause problems for standart theme, but I faced this problem while develop a custom checkout page - changing delivery method didnt work from time to time. Problem was fixed by using my own cache, that is CLEARED by setDeliveryOption and avoiding using this cache. Below is my override-based solution: // get/set DeliveryOption - fix caching issue (we SHOULD drop internal cache on setDeliveryOption) protected static $_deliveryOptionsCache = []; public function getDeliveryOption($default_country = null, $dontAutoSelectOptions = false, $use_cache = true) { $cache_id = (int)(is_object($default_country) ? $default_country->id : 0).'-'.(int)$dontAutoSelectOptions; if (isset(self::$_deliveryOptionsCache[$cache_id]) && $use_cache) { return self::$_deliveryOptionsCache[$cache_id]; } self::$_deliveryOptionsCache[$cache_id] = parent::getDeliveryOption($default_country, $dontAutoSelectOptions, false); // disable builtin cache return self::$_deliveryOptionsCache[$cache_id]; } public function setDeliveryOption($delivery_option = null) { self::$_deliveryOptionsCache = []; parent::setDeliveryOption($delivery_option); } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now