Ejemplo n.º 1
0
 function getGeneralCacheHash($name, &$cart, &$data = array())
 {
     // will create product hash (quantity, attributes, weight), order of products do not play role:
     OPCcache::createCartHash($cart);
     $carthash = OPCcache::$cartHash;
     // end of product hash
     // will create custom cache per fedex and similar:
     // zip and country are the basic cache dimensions, add more here:
     if (empty($cart->virtuemart_shipmentmethod_id)) {
         $returnValues = array();
     } else {
         if (isset(OPCcache::$cachedResult[$cart->virtuemart_shipmentmethod_id])) {
             // per request cache:
             $returnValues = OPCcache::$cachedResult[$cart->virtuemart_shipmentmethod_id];
         } else {
             JPluginHelper::importPlugin('shipment');
             $dispatcher = JDispatcher::getInstance();
             $returnValues = $dispatcher->trigger('plgVmGetSpecificCache', array($cart));
         }
     }
     $spec_cache = '';
     foreach ($returnValues as $val) {
         if (!empty($val)) {
             $spec_cache .= $val;
         }
     }
     if (!isset(OPCloader::$debugMsg)) {
         OPCloader::$debugMsg = array();
     }
     OPCloader::$debugMsg[] = $spec_cache;
     // end of custom
     // any extras:
     if (!empty($data)) {
         $datahash = md5(serialize($data));
     } else {
         $datahash = '';
     }
     // end of extras
     // basic address:
     $to_address = $cart->ST == 0 ? $cart->BT : $cart->ST;
     $zip = @$to_address['zip'];
     $country = @$to_address['virtuemart_country_id'];
     $country = @$to_address['virtuemart_state_id'];
     // end of basic address
     $alldimensions = $name . md5($carthash . $zip . $country . $datahash . $spec_cache);
     return $alldimensions;
 }