示例#1
0
    public static function getPayment(&$ref, &$OPCloader, &$num, $ajax = false, $isexpress = false)
    {
        if ($isexpress) {
            $reta = array();
            $reta['html'] = '<input type="hidden" name="virtuemart_paymentmethod_id" value="' . $ref->cart->virtuemart_paymentmethod_id . '" />';
            $reta['extra'] = '';
            return $reta;
        }
        include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
        $payment_not_found_text = '';
        $payments_payment_rates = array();
        if (!class_exists('OPCrenderer')) {
            require JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'renderer.php';
        }
        $renderer = OPCrenderer::getInstance();
        if (!$renderer->checkPaymentMethodsConfigured()) {
            if (method_exists($renderer, 'assignRef')) {
                $renderer->assignRef('paymentplugins_payments', $payments_payment_rates);
                $renderer->assignRef('found_payment_method', $found_payment_method);
            }
        }
        $p = JRequest::getVar('payment_method_id', $payment_default);
        if (empty($p)) {
            $selectedPayment = empty($ref->cart->virtuemart_paymentmethod_id) ? 0 : $ref->cart->virtuemart_paymentmethod_id;
        } else {
            $selectedPayment = $p;
        }
        // set missing fields for klarna
        OPCloader::prepareBT($ref->cart);
        $dpps = array();
        $shipping = JRequest::getVar('shipping_rate_id', '');
        //if ($ajax)
        if (!empty($shipping)) {
            if (!empty($disable_payment_per_shipping)) {
                $session = JFactory::getSession();
                $dpps = $session->get('dpps', null);
                if (empty($dpps)) {
                    $OPCloader->getShipping($ref, $ref->cart, true);
                }
                $dpps = $session->get('dpps', null);
                if (!empty($dpps)) {
                }
            }
        }
        //
        if (!empty($shipping)) {
            if (!empty($shipping)) {
                $ref->cart->virtuemart_shipmentmethod_id = $shipping;
            }
            $vm2015 = false;
            $ref->cart->prices = $ref->cart->pricesUnformatted = OPCloader::getCheckoutPrices($ref->cart, false, $vm2015, 'opc');
        }
        $paymentplugins_payments = array();
        if ($p === 'none') {
            $p = 0;
        }
        if ($payment_default === 'none') {
            $paymentplugins = array();
            $psel = '<input onclick="javascript: Onepage.runPay(\'\',\'\',op_textinclship, op_currency, 0)" type="radio" name="virtuemart_paymentmethod_id" id="payment_id_0"   value="0" not_a_valid_payment="not_a_valid_payment" ';
            if (empty($p) || $p === 'none') {
                $psel .= ' selected="selected" ';
                $payment_default = 0;
            }
            $psel .= ' />
<label for="payment_id_0"><span class="vmpayment"><span class="vmpayment_name">-' . OPCLang::_('COM_VIRTUEMART_CART_EDIT_PAYMENT') . '- </span></span></label>';
            $paymentplugins[] = $psel;
        }
        if (!class_exists('vmPSPlugin')) {
            require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php';
        }
        JPluginHelper::importPlugin('vmpayment');
        $dispatcher = JDispatcher::getInstance();
        require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'ajaxhelper.php';
        $bhelper = new basketHelper();
        //$bhelper->createDefaultAddress($ref, $ref->cart);
        //old: 2.0.208 and prior: $returnValues = $dispatcher->trigger('plgVmDisplayListFEPayment', array($ref->cart, $selectedPayment, &$paymentplugins_payments));
        //plgVmDisplayListFEPaymentOPCNocache
        $returnValues = $dispatcher->trigger('plgVmDisplayListFEPaymentOPCNocache', array(&$ref->cart, $selectedPayment, &$paymentplugins_payments));
        if (empty($returnValues)) {
            $returnValues = $dispatcher->trigger('plgVmDisplayListFEPayment', array($ref->cart, $selectedPayment, &$paymentplugins_payments));
        }
        // if no payment defined
        $found_payment_method = false;
        $n = 0;
        $debug = '';
        foreach ($paymentplugins_payments as $p1) {
            if (is_array($p1)) {
                $n += count($p1);
            }
        }
        if ($n > 0) {
            $found_payment_method = true;
        }
        $num = $n;
        if (!$found_payment_method) {
            $link = '';
            // todo
            $payment_not_found_text = OPCLang::sprintf('COM_VIRTUEMART_CART_NO_PAYMENT_METHOD_PUBLIC', '<a href="' . $link . '">' . $link . '</a>');
        }
        require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'ajaxhelper.php';
        $bhelper = new basketHelper();
        require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'transform.php';
        $ret = array();
        if ($found_payment_method) {
            if (!empty($payment_inside)) {
                $ret2 = OPCTransform::paymentToSelect($paymentplugins_payments, $shipping, $dpps);
                if (!empty($ret2)) {
                    $ret = array($ret2['select']);
                    $extra = $ret2['extra'];
                    /*
                    		  foreach ($ret['extra'] as $key=>$val)
                    {
                      $extra[$key] = $val; 
                    }
                    */
                }
            }
            if (empty($payment_inside) || empty($ret)) {
                $sorted = array();
                $unknown = array();
                foreach ($paymentplugins_payments as $paymentplugin_payments) {
                    if (is_array($paymentplugin_payments)) {
                        foreach ($paymentplugin_payments as $paymentplugin_payment) {
                            $id = OPCTransform::getFT($paymentplugin_payment, 'input', 'virtuemart_paymentmethod_id', 'name', 'virtuemart_paymentmethod_id', '>', 'value');
                            if (is_array($id)) {
                                $id = reset($id);
                            }
                            $paymentplugin_payment = str_replace('class="vmpayment_description"', 'class="vmpayment_description vmpayment_description_' . $id . '"', $paymentplugin_payment);
                            //vmpayment_cardinfo
                            $paymentplugin_payment = str_replace('class="vmpayment_cardinfo"', 'class="vmpayment_cardinfo vmpayment_cardinfo_' . $id . '"', $paymentplugin_payment);
                            //ccDetails
                            $paymentplugin_payment = str_replace('class="ccDetails"', 'class="ccDetails ccDetails_' . $id . '"', $paymentplugin_payment);
                            OPCloader::opcDebug('checking shipping ' . $shipping);
                            OPCloader::opcDebug('dpps:');
                            OPCloader::opcDebug($dpps);
                            OPCloader::opcDebug('dpps_disable:');
                            OPCloader::opcDebug($dpps_disable);
                            if (!empty($shipping)) {
                                if (!empty($dpps)) {
                                    if (!empty($disable_payment_per_shipping)) {
                                        foreach ($dpps_disable as $k => $v) {
                                            if (!empty($dpps[$k])) {
                                                foreach ($dpps[$k] as $y => $try) {
                                                    if ((int) $dpps[$k][$y] == (int) $shipping) {
                                                        if ($dpps_disable[$k] == $id) {
                                                            OPCloader::opcDebug('disabling payment id ' . $id . ' for shipping id ' . $shipping);
                                                            $paymentplugin_payment = '';
                                                            continue 3;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            // PPL Pro fix
                            $paymentplugin_payment = str_replace('<br/><a href="' . JRoute::_('index.php?option=com_virtuemart&view=cart&task=editpayment&Itemid=' . JRequest::getInt('Itemid'), false) . '">' . JText::_('VMPAYMENT_PAYPAL_CC_ENTER_INFO') . '</a>', '', $paymentplugin_payment);
                            $paymentplugin_payment = str_replace('name="virtuemart_paymentmethod_id"', 'name="virtuemart_paymentmethod_id" onclick="javascript: Onepage.runPay(\'\',\'\',op_textinclship, op_currency, 0)" ', $paymentplugin_payment);
                            $ret[] = $paymentplugin_payment;
                            if ($n === 1 && !empty($hide_payment_if_one)) {
                                $paymentplugin_payment = str_replace('type="radio"', 'type="hidden"', $paymentplugin_payment);
                            }
                            if (is_numeric($id)) {
                                $ind = (int) $id;
                                if (empty($sorted[$ind])) {
                                    $sorted[$ind] = $paymentplugin_payment;
                                } else {
                                    $unknown[] = $paymentplugin_payment;
                                }
                            } else {
                                if (is_numeric($id[0])) {
                                    $ind = (int) $id[0];
                                    if (empty($sorted[$ind])) {
                                        $sorted[$ind] = $paymentplugin_payment;
                                    } else {
                                        $unknown[] = $paymentplugin_payment;
                                    }
                                } else {
                                    $unknown[] = $paymentplugin_payment;
                                }
                            }
                        }
                    }
                }
                if (!empty($sorted)) {
                    $dbj = JFactory::getDBO();
                    $dbj->setQuery("select * from #__virtuemart_paymentmethods where published = '1' order by ordering asc limit 999");
                    $list = $dbj->loadAssocList();
                    $msg = $dbj->getErrorMsg();
                    if (!empty($msg)) {
                        echo $msg;
                    }
                    $sortedfinal = array();
                    if (!empty($list)) {
                        foreach ($list as $pme) {
                            if (!empty($sorted[$pme['virtuemart_paymentmethod_id']])) {
                                $sortedfinal[] = $sorted[$pme['virtuemart_paymentmethod_id']];
                            }
                        }
                        if (empty($unknown)) {
                            $unknown = array();
                        }
                        if (!empty($sortedfinal)) {
                            $ret = array_merge($sortedfinal, $unknown);
                        }
                    }
                }
            }
        } else {
            $ret[] = $payment_not_found_text . '<input type="hidden" name="virtuemart_paymentmethod_id" id="opc_missing_payment" value="0" />';
        }
        if (empty($payment_inside)) {
            if (!empty($ret)) {
                if (!empty($paymentplugins)) {
                    $ret = array_merge($paymentplugins, $ret);
                }
            }
        }
        $vars = array('payments' => $ret, 'cart' => $ref->cart);
        $html = $OPCloader->fetch($OPCloader, 'list_payment_methods.tpl', $vars);
        $pid = JRequest::getVar('payment_method_id', '');
        if (!empty($pid) && is_numeric($pid)) {
            if (strpos($html, 'value="' . $pid . '"') !== false) {
                $html = str_replace('checked="checked"', '', $html);
                $html = str_replace(' checked', ' ', $html);
                $html = str_replace('value="' . $pid . '"', 'value="' . $pid . '" checked="checked" ', $html);
            }
        } else {
            if (strpos($html, 'value="' . $payment_default . '"') !== false) {
                $html = str_replace('checked="checked"', '', $html);
                $html = str_replace(' checked', ' ', $html);
                $html = str_replace('value="' . $payment_default . '"', 'value="' . $payment_default . '" checked="checked" ', $html);
            }
        }
        $html = str_replace('"radio"', '"radio" autocomplete="off" ', $html);
        if (!$payment_inside) {
            if (strpos($html, 'checked') === false) {
                $x1 = strpos($html, 'name="virtuemart_paymentmethod_id"');
                if ($x1 !== false) {
                    $html = substr($html, 0, $x1) . ' checked="checked" ' . substr($html, $x1);
                } else {
                    // we've got no method here !
                }
            }
        }
        // klarna compatibility
        $count = 0;
        $html = str_replace('name="klarna_paymentmethod"', 'name="klarna_paymentmethod_opc"', $html, $count);
        $html .= '<input type="hidden" name="opc_payment_method_id" id="opc_payment_method_id" value="" />';
        if ($count > 0) {
            if (!defined('klarna_opc_id')) {
                $html .= '<input type="hidden" name="klarna_opc_method" id="klarna_opc_method" value="" />';
                define('klarna_opc_id', 1);
            }
        }
        $reta = array();
        $reta['html'] = $html;
        if (!empty($extra)) {
            $reta['extra'] = $extra;
        } else {
            $reta['extra'] = '';
        }
        return $reta;
    }
示例#2
0
 public static function fetchUrl($url, $XPost = '')
 {
     if (!function_exists('curl_init')) {
         return file_get_contents($url);
     }
     $ch = curl_init();
     //	 curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     curl_setopt($ch, CURLOPT_URL, $url);
     // set url to post to
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     // return into a variable
     curl_setopt($ch, CURLOPT_TIMEOUT, 4000);
     // times out after 4s
     curl_setopt($ch, CURLOPT_POSTFIELDS, $XPost);
     // add POST fields
     if (!empty($XPost)) {
         curl_setopt($ch, CURLOPT_POST, 1);
     } else {
         curl_setopt($ch, CURLOPT_POST, 0);
     }
     curl_setopt($ch, CURLOPT_ENCODING, "gzip");
     $result = curl_exec($ch);
     if (curl_errno($ch)) {
         OPCloader::opcDebug('ERROR -> ' . curl_errno($ch) . ': ' . curl_error($ch));
         @curl_close($ch);
         return false;
     } else {
         $returnCode = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
         OPCloader::opcDebug($url . ' -> ' . $returnCode);
         switch ($returnCode) {
             case 404:
                 @curl_close($ch);
                 return false;
                 break;
             case 200:
                 break;
             default:
                 @curl_close($ch);
                 return false;
                 break;
         }
     }
     @curl_close($ch);
     return $result;
 }
示例#3
0
 public static function setShopperGroups($id, $remove = array())
 {
     include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
     $user = JFactory::getUser();
     if (empty($allow_sg_update_logged)) {
         if ($user->id != 0 && empty($user->guest)) {
             return $id;
         }
     }
     if (!class_exists('VirtueMartModelShopperGroup')) {
         if (file_exists(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'shoppergroup.php')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'shoppergroup.php';
         } else {
             return 1;
         }
     }
     if (!method_exists('VirtueMartModelShopperGroup', 'appendShopperGroups')) {
         return 1;
     }
     OPCloader::opcDebug('OPC: setShopperGroup: ' . $id);
     $arr = array(1, 2);
     if (!empty($id) && $id > 0 && !in_array($id, $arr)) {
         //remove default and anonymous
         $remove[] = 1;
         $remove[] = 2;
     }
     if (!empty($id)) {
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
         $shoppergroupmodel = OPCmini::getModel('ShopperGroup');
         //new VirtueMartModelShopperGroup();
         if (method_exists($shoppergroupmodel, 'removeSessionSgrps')) {
             if (method_exists($shoppergroupmodel, 'appendShopperGroups')) {
                 $session = JFactory::getSession();
                 $shoppergroup_ids = $session->get('vm_shoppergroups_add', array(), 'vm');
                 //$shoppergroupmodel->removeSessionSgrps($shoppergroup_ids);
                 $new_shoppergroups = $shoppergroup_ids;
                 foreach ($remove as $rid) {
                     foreach ($new_shoppergroups as $key => $val) {
                         if ($rid == $val) {
                             unset($new_shoppergroups[$key]);
                         }
                     }
                 }
                 $session->set('vm_shoppergroups_remove', $remove, 'vm');
                 if ($id > 0) {
                     if (!in_array($id, $shoppergroup_ids)) {
                         $new_shoppergroups[] = $id;
                         JRequest::setVar('virtuemart_shoppergroup_id', $id, 'post');
                     }
                 }
                 $session = JFactory::getSession();
                 $shoppergroup_ids = $session->set('vm_shoppergroups_add', $new_shoppergroups, 'vm');
                 $user = JFactory::getUser();
                 $shoppergroupmodel->appendShopperGroups($new_shoppergroups, $user);
                 OPCloader::opcDebug('OPC: setShopperGroup changed: ' . $id);
                 if ($id > 0) {
                     return $id;
                 }
             }
         }
     }
     static $default_id;
     if (!empty($default_id)) {
         return $default_id;
     }
     // else
     // this is a VM default group:
     if (!class_exists('VirtueMartCart')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     $cart = VirtueMartCart::getCart();
     if (empty($cart->vendorId)) {
         $vid = 1;
     } else {
         $vid = (int) $cart->vendorId;
     }
     $user = JFactory::getDBO();
     $sid = $user->get('id');
     if (empty($id)) {
         if (empty($sid) || $user->guest) {
             //anonymous:
             $db = JFactory::getDBO();
             $q = "select virtuemart_shoppergroup_id from #__virtuemart_shoppergroups where default = '2' virtuemart_vendor_id = " . $vid . " limit 1";
             $db->setQuery($q);
             $id = $db->loadResult();
             $default_id = $id;
         } else {
             $db = JFactory::getDBO();
             $q = "select virtuemart_shoppergroup_id from #__virtuemart_shoppergroups where default = '1' virtuemart_vendor_id = " . $vid . " limit 1";
             $db->setQuery($q);
             $id = $db->loadResult();
             $default_id = $id;
         }
     }
     return $id;
 }
示例#4
0
 public static function paymentToSelect($htmla, $shipping, $dpps)
 {
     include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
     $pid = JRequest::getVar('payment_method_id', $payment_default);
     if ($payment_default === 'none') {
         $payment_default = 0;
         $adds = true;
     }
     $options = '';
     if (!empty($adds)) {
         $options .= '<option not_a_valid_payment="not_a_valid_payment" value="0" id="payment_id_0">' . OPCLang::_('COM_VIRTUEMART_LIST_EMPTY_OPTION') . '</option>';
     }
     $extra = array();
     foreach ($htmla as $paymentplugin_payments) {
         if (is_array($paymentplugin_payments)) {
             foreach ($paymentplugin_payments as $paymentplugin_payment) {
                 $id = self::getFT($paymentplugin_payment, 'input', 'virtuemart_paymentmethod_id', 'name', 'virtuemart_paymentmethod_id', '>', 'value');
                 OPCloader::opcDebug('checking shipping ' . $shipping);
                 OPCloader::opcDebug('dpps:');
                 OPCloader::opcDebug($dpps);
                 OPCloader::opcDebug('dpps_disable:');
                 OPCloader::opcDebug($dpps_disable);
                 if (!empty($shipping)) {
                     if (!empty($dpps)) {
                         if (!empty($disable_payment_per_shipping)) {
                             $idp = $id[0];
                             foreach ($dpps_disable as $k => $v) {
                                 if (!empty($dpps[$k])) {
                                     foreach ($dpps[$k] as $y => $try) {
                                         if ((int) $dpps[$k][$y] == (int) $shipping) {
                                             OPCloader::opcDebug('found shipping ' . $dpps[$k][$y] . ' testing payment id' . $idp);
                                             if ($dpps_disable[$k] == $idp) {
                                                 OPCloader::opcDebug('disabling payment id ' . $idp . ' for shipping id ' . $shipping);
                                                 $paymentplugin_payment = '';
                                                 continue 3;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 $html = self::getInnerTag('label', $paymentplugin_payment);
                 // remove description:
                 $xd = stripos($html, '<span class="vmpayment_description">');
                 if ($xd !== false) {
                     $s1 = stripos($html, '</span>', $xd);
                     $len = strlen('</span>');
                     $html = substr($html, 0, $xd) . substr($html, $s1 + $len);
                 }
                 $x = str_replace($html, '', $paymentplugin_payment);
                 $t1 = strip_tags($x);
                 $t2 = trim($t1);
                 $hasextra = false;
                 if (!empty($t2)) {
                     $x2 = self::getUnclosedTag('input', $x, 'virtuemart_paymentmethod_id');
                     // remove the payment input
                     $x = str_replace($x2, '', $x);
                     $extra[$id[0]] = '<div class="payment_extra" style="display: none;" id="extra_payment_' . $id[0] . '">' . $x . '</div>';
                     $hasextra = true;
                 } else {
                     $extra[$id[0]] = '';
                 }
                 $html = strip_tags($html);
                 $options .= '<option value="' . $id[0] . '"';
                 if ($id[0] == $pid) {
                     $options .= ' selected="selected" ';
                 }
                 if ($hasextra) {
                     $options .= ' rel="' . $id[0] . '" ';
                 }
                 $options .= '>' . $html . '</option>';
             }
         }
     }
     $select = '<select autocomplete="off" id="opcPaymentSelect" class="opcPaymentSelect" onchange="javascript: Onepage.runPaySelect(this);" name="virtuemart_paymentmethod_id">' . $options . '</select>';
     //$extra['-1'] = $select;
     $a2 = array();
     $a2['extra'] = '';
     $a2['select'] = $select;
     /*	
     foreach ($extra as $key=>$l)
     	$a2['extra'] .= $l; 
     */
     if (empty($extra)) {
         $extra = array();
     }
     $a2['extra'] = $extra;
     return $a2;
 }
示例#5
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;
 }