public static function populateCart(&$cart, $type = 'BT', $new = 1) { $savedBT = OPCloader::copyAddress($cart->BT); if ($type == 'BT') { unset($cart->BTaddress); } if (method_exists($cart, 'prepareAddressDataInCart')) { $cart->prepareAddressDataInCart($type, true); } // in 258 updated from: $cart->prepareAddressDataInCart($type, false); if (method_exists($cart, 'prepareAddressDataInCart')) { $cart->prepareAddressDataInCart($type, false); } // in 258 updated from: $cart->prepareAddressDataInCart($type, false); if (method_exists($cart, 'prepareAddressFieldsInCart')) { $cart->prepareAddressFieldsInCart(); } OPCloader::restoreDataInCart($cart->BT, $savedBT); }
public static function getUserFields($address_type = 'BT', &$cart = null) { 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'); $new = false; if ($uid != 0) { $userDetails = $umodel->getUser(); $virtuemart_userinfo_id = $umodel->getBTuserinfo_id(); } else { $virtuemart_userinfo_id = 0; } $layoutName = 'edit'; $task = JRequest::getVar('task'); $userFields = null; $view = JRequest::getVar('view', ''); if ((strpos($task, 'cart') || strpos($task, 'checkout') || $view == 'cart') && empty($virtuemart_userinfo_id)) { //New Address is filled here with the data of the cart (we are in the cart) if (empty($cart)) { if (!class_exists('VirtueMartCart')) { require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php'; } $cart = VirtueMartCart::getCart(); } $fieldtype = $address_type . 'address'; if (!empty($cart->{$address_type})) { if (is_array($cart->{$address_type})) { if (count($cart->{$address_type}) > 2) { $new = false; } } } $saved = OPCloader::copyAddress($cart->{$address_type}); require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'userfields.php'; OPCUserFields::populateCart($cart, $address_type, true); /* if (method_exists($cart, 'prepareAddressDataInCart')) $cart->prepareAddressDataInCart($address_type, $new); if (method_exists($cart, 'prepareAddressFieldsInCart')) $cart->prepareAddressFieldsInCart(); */ if (!empty($cart->{$address_type})) { OPCloader::restoreDataInCart($cart->{$address_type}, $saved); } $userFields = $cart->{$fieldtype}; $task = JRequest::getWord('task', ''); } else { $userFields = $umodel->getUserInfoInUserFields($layoutName, $address_type, $virtuemart_userinfo_id); $userFields = $userFields[$virtuemart_userinfo_id]; $task = 'editaddressST'; } return $userFields; }