VM3.2.12 language bug (thank you page in incorrect language)

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

VM3.2.12 language bug (thank you page in incorrect language)

Postby admin » Wed Jan 03, 2018 3:44 pm

hello, if you exprience your thank you page in an incorrect language you may want to update this file on vm3.2.12:

\administrator\components\com_virtuemart\models\orders.php

new code:
Code: Select all
/**
    * Notifies the customer that the Order Status has been changed
    *
    * @author Christopher Roussel, Valérie Isaksen, Max Milbers
    *
    */
   public function notifyCustomer($virtuemart_order_id, $newOrderData = 0 ) {

      if (isset($newOrderData['customer_notified']) && $newOrderData['customer_notified']==0) {
          return true;
      }
      if(!class_exists('shopFunctionsF')) require(VMPATH_SITE.DS.'helpers'.DS.'shopfunctionsf.php');
      
      $originalLanguage = VmConfig::$vmlangTag;  // NEW CODE
      
      //Important, the data of the order update mails, payments and invoice should
      //always be in the database, so using getOrder is the right method

      $vendorModel = VmModel::getModel('vendor');
      //Lets set the language to the Shop default

      shopFunctionsF::loadOrderLanguages(VmConfig::$jDefLangTag);
      $order = $this->getOrder($virtuemart_order_id);


      $vars['orderDetails']=$order;

      $payment_name = $shipment_name='';
      if (!class_exists('vmPSPlugin')) require(VMPATH_PLUGINLIBS . DS . 'vmpsplugin.php');

      JPluginHelper::importPlugin('vmshipment');
      JPluginHelper::importPlugin('vmpayment');
      $dispatcher = JDispatcher::getInstance();
      $returnValues = $dispatcher->trigger('plgVmOnShowOrderFEShipment',array(  $order['details']['BT']->virtuemart_order_id, $order['details']['BT']->virtuemart_shipmentmethod_id, &$shipment_name));
      $returnValues = $dispatcher->trigger('plgVmOnShowOrderFEPayment',array(  $order['details']['BT']->virtuemart_order_id, $order['details']['BT']->virtuemart_paymentmethod_id, &$payment_name));
      $order['shipmentName']=$shipment_name;
      $order['paymentName']=$payment_name;
      if($newOrderData!=0){   //We do not really need that
         $vars['newOrderData'] = (array)$newOrderData;
      }

      //$vars['includeComments'] = vRequest::getVar('customer_notified', array());
      //I think this is misleading, I think it should always ask for example $vars['newOrderData']['doVendor'] directly
      //Using this function garantue us that it is always there. If the vendor should be informed should be done by the plugins
      //We may add later something to the method, defining this better
      $vars['url'] = 'url';
      if(!isset($newOrderData['doVendor'])) $vars['doVendor'] = false; else $vars['doVendor'] = $newOrderData['doVendor'];

      $invoice = $this->createInvoiceByOrder($order);
      if($invoice){
         $vars['mediaToSend'][] = $invoice;
      }

      $virtuemart_vendor_id = $order['details']['BT']->virtuemart_vendor_id;

      $vendorEmail = array();
      $vendorEmail[] = $vars['vendorEmail'] = $vendorModel->getVendorEmail($virtuemart_vendor_id);
      $addVendorEmails = VmConfig::get('addVendorEmail','');
      if (!empty($addVendorEmails)) $vendorEmail = array_merge($vendorEmail,explode(';',$addVendorEmails));

      $vendor = $vendorModel->getVendor($virtuemart_vendor_id);
      $vars['vendor'] = $vendor;

      //Mail for vendor
      $orderstatusForVendorEmail = VmConfig::get('email_os_v',array('U','C','R','X'));
      if(!is_array($orderstatusForVendorEmail)) $orderstatusForVendorEmail = array($orderstatusForVendorEmail);

      if ( in_array((string)$order['details']['BT']->order_status,$orderstatusForVendorEmail)){
         //shopFunctionsF::loadOrderLanguages(VmConfig::$jDefLangTag);
         //VmConfig::setLanguageByTag(VmConfig::$jDefLangTag);
         $view = shopFunctionsF::prepareViewForMail('invoice', $vars);
         $res = shopFunctionsF::sendVmMail( $view, $vendorEmail, TRUE );
      }

      // Send the email
      //$res = shopFunctionsF::renderMail('invoice', $order['details']['BT']->email, $vars, null,$vars['doVendor'],$this->useDefaultEmailOrderStatus);
      $sendMail = false;
      if(!$this->useDefaultEmailOrderStatus and isset($vars['newOrderData']['customer_notified']) and $vars['newOrderData']['customer_notified']==1){
         $sendMail = true;
      } else {
         $orderstatusForShopperEmail = VmConfig::get('email_os_s',array('U','C','S','R','X'));
         if(!is_array($orderstatusForShopperEmail)) $orderstatusForShopperEmail = array($orderstatusForShopperEmail);
         if ( in_array((string) $vars['orderDetails']['details']['BT']->order_status,$orderstatusForShopperEmail) ){
            $sendMail = true;
            vmdebug('renderMail by default orderstati');
         }
      }

      shopFunctionsF::loadOrderLanguages(VmConfig::$vmlangTag);
      $res = true;
      if($sendMail){
         if(!empty($vars['orderDetails']['details']) and !empty($vars['orderDetails']['details']['BT']->order_language)) {
            $orderLang = $vars['orderDetails']['details']['BT']->order_language;
            shopFunctionsF::loadOrderLanguages($orderLang);
            $vendor = $vendorModel->getVendor($virtuemart_vendor_id);
            $vars['vendor'] = $vendor;
            $vars['orderDetails'] = $this->getOrder($virtuemart_order_id);
         }

         $shopperEmail = array();
         $shopperEmailFields = VmConfig::get('email_sf_s',array('email'));
         foreach ($shopperEmailFields as $field) {
            if (!empty($order['details']['BT']->$field)) $shopperEmail[] = $order['details']['BT']->$field;
         }
         if (count($shopperEmail) < 1) $shopperEmail[] = $order['details']['BT']->email;

         $view = shopFunctionsF::prepareViewForMail('invoice', $vars);
         $res = shopFunctionsF::sendVmMail( $view, $shopperEmail, false );

      }

      if(is_object($res) or !$res){
         $string = 'COM_VIRTUEMART_NOTIFY_CUSTOMER_ERR_SEND';
         vmdebug('notifyCustomer function shopFunctionsF::renderMail throws JException');
         $res = 0;
      } //We need this, to prevent that a false alert is thrown.
      else if ($res and $res!=-1) {
         $string = 'COM_VIRTUEMART_NOTIFY_CUSTOMER_SEND_MSG';
      }

      if($res!=-1){
         vmLanguage::setLanguageByTag(vmLanguage::$jSelLangTag);
         vmInfo( vmText::_($string,false).' '.$order['details']['BT']->first_name.' '.$order['details']['BT']->last_name. ', '.$order['details']['BT']->email);
      }

      //quicknDirty to prevent that an email is sent twice
      $app = JFactory::getApplication();
      if($app->isSite()){
         if (!class_exists('VirtueMartCart'))
            require(VMPATH_SITE . DS . 'helpers' . DS . 'cart.php');
         $cart = VirtueMartCart::getCart();
         $cart->customer_notified = true;
      }
      
      shopFunctionsF::loadOrderLanguages($originalLanguage);  //NEW CODE
      
      return true;
   }



see 2 new lines makred with "NEW CODE" to fix the problem.

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