Ejemplo n.º 1
0
 public function plgVmDisplayListFEShipmentOPC(&$cart, $selected = 0, &$htmlIn)
 {
     if (!isset($cart->vendorId)) {
         $cart->vendorId = 1;
     }
     if ($this->_type != 'vmshipment') {
         return;
     }
     $pluginmethod_id = $this->_idName;
     //virtuemart_shipmentmethod_id
     $pluginName = $this->_psType . '_name';
     // shipment_name
     $pluginName = $this->_name;
     $data = array($selected, $pluginmethod_id, $pluginName);
     $hash = OPCcache::getGeneralCacheHash('plgVmDisplayListFEShipment', $cart, $data);
     $val = OPCcache::getValue($hash);
     VmPlugin::$iCount++;
     if (!empty($val)) {
         if (empty($val[0])) {
             break;
             //return $val[0];
         } else {
             foreach ($val[1] as $vala) {
                 $htmlIn[] = $vala;
             }
             return true;
         }
     }
     $htmlIn2 = array();
     $val = $this->plgVmDisplayListFEShipmentOPCNocache($cart, $selected, $htmlIn2);
     $html = '';
     if (is_array($htmlIn2)) {
         foreach ($htmlIn2 as $h) {
             if (is_array($h)) {
                 foreach ($h as $h2) {
                     $html .= $h2;
                 }
             } else {
                 $html .= $h;
             }
         }
     } else {
         $html = $htmlIn2;
     }
     if (!empty($html) || stripos($html, 'virtuemart_shipmentmethod_id') !== false) {
         if (stripos($html, 'error') === false) {
             $val2 = OPCcache::setValue($hash, array($val, $htmlIn2));
         }
     }
     if (!empty($htmlIn2)) {
         $htmlIn = array_merge($htmlIn, $htmlIn2);
     }
     return $val;
 }
Ejemplo n.º 2
0
 function getCachedShipping(&$cart, &$prices, $shipping_id, &$calc, $data = array())
 {
     if (!isset(OPCloader::$totalIsZero)) {
         OPCloader::$totalIsZero = true;
     }
     // cache dimensions:
     // this is a product hash (quantity, attributes, weight, etc..)
     include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
     self::$count++;
     $savedcoupon = $cart->couponCode;
     $data[] = $shipping_id;
     if (!empty($opc_calc_cache)) {
         $hash = OPCcache::getGeneralCacheHash('calc', $cart, $data);
     }
     $saved_id = $cart->virtuemart_shipmentmethod_id;
     //opc_request_cache
     if (class_exists('calculationHelperOPC')) {
         calculationHelperOPC::$_forhash = $hash;
     }
     // overrided class with the above hash knows if to re-fetch the shipping
     if (!empty($opc_request_cache)) {
         OPCcache::$cachedResult['currentshipping'] = $shipping_id;
         if (!empty(OPCcache::$cachedResult['shippingcache'][$shipping_id])) {
             $cart->virtuemart_shipmentmethod_id = (int) $cart->virtuemart_shipmentmethod_id;
             $cart->virtuemart_shipmentmethod_id = abs($cart->virtuemart_shipmentmethod_id) * -1;
         }
     }
     $vm2015 = false;
     if (method_exists($calc, 'getCheckoutPricesOPC')) {
         $prices = $calc->getCheckoutPricesOPC($cart, false);
         if (method_exists($calculator, 'getCartData')) {
             $cart->OPCCartData = $calc->getCartData();
         }
     } else {
         $prices = OPCloader::getCheckoutPrices($cart, false, $vm2015, 'opc');
     }
     if (!empty($prices['billTotal'])) {
         // special case for zero value orders, do not charge payment fee:
         if ($prices['billTotal'] == $prices['paymentValue']) {
             $savedp = $cart->virtuemart_paymentmethod_id;
             $cart->virtuemart_paymentmethod_id = 0;
             if (method_exists($calc, 'getCheckoutPricesOPC')) {
                 $prices = $calc->getCheckoutPricesOPC($cart, false);
             } else {
                 $prices = OPCloader::getCheckoutPrices($cart, false, $vm2015, 'opc');
             }
         }
     }
     if (!empty($prices['billTotal'])) {
         OPCloader::$totalIsZero = false;
     }
     OPCloader::opcDebug('OPC: getCheckoutPrices from ajaxhelper.php');
     OPCloader::opcDebug($prices);
     if (isset($cart->OPCCartData)) {
         OPCloader::opcDebug($cart->OPCCartData);
     }
     if (!empty($opc_request_cache)) {
         if (!empty($saved_id)) {
             $sprice['shipmentValue'] = $prices['shipmentValue'];
             $sprice['shipmentTax'] = $prices['shipmentTax'];
             $sprice['salesPriceShipment'] = $prices['salesPriceShipment'];
             $sprice['shipment_calc_id'] = $prices['shipment_calc_id'];
             $sprice['shipmentName'] = @$prices['shipmentName'];
             OPCcache::storeShipingCalculation($cart, $sprice, $sprice['shipmentName'], $shipping_id);
         }
     }
     // in case calculation invalidates it:
     $cart->virtuemart_shipmentmethod_id = $saved_id;
     $cart->couponCode = $savedcoupon;
 }