Virtuemart 3.6.8 and rules_shipping

If you are runnig Joomla 3.x and Virtuemart 3.x please post to this forum your questions or support tickets about One Page Checkout

Virtuemart 3.6.8 and rules_shipping

Postby admin » Wed Nov 20, 2019 6:28 pm

hello friends, we discovered an issue with VM3.6.X which does not account for automatic shipping selection settings which must be set to "disabled" when used with OPC (opc does this by default when you click Save in OPC config)

the problem can be seen when using rules_shipping and some other plugin (such as opc_currency) which can load shipping before the address is set. due to the way rules_shipping is written it remembers the first address that was used at the call (before OPC or VM can update it) and this leads to the problem where you get a list of shippings available for previously selected country, but not for the current country.

to fix this, we believe this is the best modification for VM core (i hope this gets included in 3.6.10 )

find function calculateMethodPrice in your \administrator\components\com_virtuemart\helpers\calculationh.php starting at line cca 1490

update with:

Code: Select all
function calculateMethodPrice($type){

      if($type=='shipment'){
         $this->_cart->cartData['shipmentName'] = vmText::_('COM_VIRTUEMART_CART_NO_SHIPMENT_SELECTED');
         $this->_cart->cartPrices['shipmentValue'] = 0; //could be automatically set to a default set in the globalconfig
         $this->_cart->cartPrices['shipmentTax'] = 0;
         $this->_cart->cartPrices['salesPriceShipment'] = 0;
         $this->_cart->cartPrices['shipment_calc_id'] = 0;
      } else {
         $this->_cart->cartData['paymentName'] = vmText::_('COM_VIRTUEMART_CART_NO_PAYMENT_SELECTED');
         $this->_cart->cartPrices['paymentValue'] = 0; //could be automatically set to a default set in the globalconfig
         $this->_cart->cartPrices['paymentTax'] = 0;
         $this->_cart->cartPrices['paymentTotal'] = 0;
         $this->_cart->cartPrices['salesPricePayment'] = 0;
         $this->_cart->cartPrices['payment_calc_id'] = 0;
      }

      $method_id_name = 'virtuemart_'.$type.'method_id';
      
         $automatic = VmConfig::get('set_automatic_'.$type, 0);
         if (($automatic >= 0) || (!empty($this->_cart->$method_id_name))) {
            JPluginHelper::importPlugin('vm'.$type);
            $this->_cart->checkAutomaticSelectedPlug($type);
         }
         if(empty($this->_cart->$method_id_name)) return;
      

      $dispatcher = JDispatcher::getInstance();
      $returnValues = $dispatcher->trigger('plgVmonSelectedCalculatePrice'.ucfirst($type),array( $this->_cart, &$this->_cart->cartPrices, &$this->_cart->cartData[$type.'Name']  ));

      // Plugin return true if payment plugin is  valid false if not  valid anymore only one value is returned
      $methodValid=0;
      foreach ($returnValues as $returnValue) {
         $methodValid += $returnValue;
      }

      if (!$methodValid) {
         vmdebug('calculate'.ucfirst($type).'Price Method INVALID set cart->'.$method_id_name.' = 0 ',$this->_cart->$method_id_name);
         $this->_cart->$method_id_name = 0;
         $this->_cart->checkAutomaticSelectedPlug($type);
         if(!empty($this->_cart->$method_id_name)){
            vmdebug('my firstRecalc'.$type,(int)$this->{'firstRecalc'.$type});
            if($this->{'firstRecalc'.$type} ){
               $this->{'firstRecalc'.$type} = false;
               return $this->getCheckoutPrices($this->_cart);
            } else {
               vmdebug('I will not recalculate twice');
            }
            return false;
         }
         //$this->_cart->setCartIntoSession(true,true);
      }

      return $this->_cart->cartPrices;
   }


the altered code is:
Code: Select all

         $automatic = VmConfig::get('set_automatic_'.$type, 0);
         if (($automatic >= 0) || (!empty($this->_cart->$method_id_name))) {
            JPluginHelper::importPlugin('vm'.$type);
            $this->_cart->checkAutomaticSelectedPlug($type);
         }


best regards, stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm

Return to One Page Checkout for Virtuemart 3 on Joomla 3.x

cron