Example #1
0
 public static function getSTHtml(&$cart)
 {
     $html = '';
     $stId = JRequest::getVar('ship_to_info_id', 0);
     $stId = (int) $stId;
     if (!empty($stId)) {
         $user_id = JFactory::getUser()->get('id');
         if (!empty($user_id)) {
             $db = JFactory::getDBO();
             $q = 'select * from #__virtuemart_userinfos where virtuemart_userinfo_id = ' . $db->escape($stId) . ' limit 0,1';
             $db->setQuery($q);
             $adr1 = $db->loadObject();
             if (!empty($adr1)) {
                 if ($adr1->virtuemart_user_id == $user_id) {
                     /*
                     			   $new_adr1 = new stdClass(); 
                     			   foreach ($adr1 as $key=>$val)
                     			    {
                       $new_adr1->$key = $val; 
                     }
                     */
                     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
                     $umodel = OPCmini::getModel('user');
                     //new VirtuemartModelUser();
                     $virtuemart_userinfo_id = 0;
                     $currentUser = JFactory::getUser();
                     $uid = $currentUser->get('id');
                     $userDetails = $umodel->getUser();
                     $virtuemart_userinfo_id = $umodel->getBTuserinfo_id();
                     $userFields = $umodel->getUserInfoInUserFields('default', 'BT', $virtuemart_userinfo_id);
                     $userFields = $umodel->getUserInfoInUserFields('default', 'ST', $stId);
                     /*
                      */
                     if (method_exists($cart, 'prepareAddressDataInCart')) {
                         $cart->prepareAddressDataInCart('ST', 1);
                     }
                     if (method_exists($cart, 'prepareAddressFieldsInCart')) {
                         $cart->prepareAddressFieldsInCart();
                     }
                     if (isset($cart->STaddress['fields'])) {
                         $BTaddress = $cart->STaddress['fields'];
                     } else {
                         $BTaddress = $cart->BTaddress['fields'];
                     }
                     $new_address_link = '#" onclick="return Onepage.op_showEditST();';
                     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'loader.php';
                     $OPCloader = new OPCloader();
                     $BTaddressNamed = $OPCloader->setCountryAndState($BTaddress);
                     $html = self::renderNamed($BTaddressNamed, $adr1, $cart, $OPCloader, $virtuemart_userinfo_id, true);
                 }
             }
         }
     }
     return $html;
 }