function storeAddresses() { $this->cart = VirtueMartCart::getCart(); $addressST = $addressBT = array(); if ($this->response['SHIPTONAME'] == $this->response['FIRSTNAME'] . ' ' . $this->response['LASTNAME']) { $firstName = $this->response['FIRSTNAME']; $lastName = $this->response['LASTNAME']; } else { $shipToName = explode(' ', $this->response['SHIPTONAME']); $firstName = $shipToName[0]; $lastName = ''; if (count($shipToName) > 1) { $lastName = str_replace($firstName . ' ', '', $this->response['SHIPTONAME']); } } $usersModel = VmModel::getModel('user'); $validateUserData = $usersModel->validateUserData($this->cart->BT, 'BT'); if ($validateUserData !== true) { $addressBT['email'] = $this->response['EMAIL']; $addressBT['first_name'] = $firstName; $addressBT['last_name'] = $lastName; $addressBT['address_1'] = $this->response['SHIPTOSTREET']; $addressBT['city'] = $this->response['SHIPTOCITY']; $addressBT['zip'] = $this->response['SHIPTOZIP']; $addressBT['virtuemart_state_id'] = ShopFunctions::getStateIDByName($this->response['SHIPTOSTATE']); $addressBT['virtuemart_country_id'] = ShopFunctions::getCountryIDByName($this->response['SHIPTOCOUNTRYCODE']); $this->cart->saveAddressInCart($addressBT, 'BT', true); } $addressST['shipto_address_type_name'] = 'PayPal Account'; $addressST['shipto_first_name'] = $firstName; $addressST['shipto_last_name'] = $lastName; $addressST['shipto_address_1'] = $this->response['SHIPTOSTREET']; $addressST['shipto_city'] = $this->response['SHIPTOCITY']; $addressST['shipto_zip'] = $this->response['SHIPTOZIP']; $addressST['shipto_virtuemart_state_id'] = ShopFunctions::getStateIDByName($this->response['SHIPTOSTATE']); $addressST['shipto_virtuemart_country_id'] = ShopFunctions::getCountryIDByName($this->response['SHIPTOCOUNTRYCODE']); $this->cart->STsameAsBT = 0; $this->cart->setCartIntoSession(); $this->cart->saveAddressInCart($addressST, 'ST', true); }
public function display($tpl = null) { $app = JFactory::getApplication(); $input = JFactory::getApplication()->input; $this->prepareContinueLink(); if (VmConfig::get('use_as_catalog', 0)) { vmInfo('This is a catalogue, you cannot access the cart'); $app->redirect($this->continue_link); } $pathway = $app->getPathway(); $document = JFactory::getDocument(); $document->setMetaData('robots', 'NOINDEX, NOFOLLOW, NOARCHIVE, NOSNIPPET'); $this->addTemplatePath(dirname(__FILE__) . DS . 'tmpl' . DS); $path = JPATH_BASE . '/templates/' . $app->getTemplate() . '/html/plg_content_onepage_generic/'; $this->addTemplatePath($path); $layoutName = $this->getLayout(); if (!$layoutName) { $layoutName = vRequest::getCmd('layout', 'default'); } $this->assignRef('layoutName', $layoutName); $format = vRequest::getCmd('format'); if (!class_exists('VirtueMartCart')) { require VMPATH_SITE . DS . 'helpers' . DS . 'cart.php'; } $cart = VirtueMartCart::getCart(); $cart->prepareVendor(); $this->cart = $cart; //Why is this here, when we have view.raw.php if ($format == 'raw') { vRequest::setVar('layout', 'mini_cart'); $this->setLayout('mini_cart'); $this->prepareContinueLink(); } if ($layoutName == 'select_shipment') { $cart->prepareCartData(); $this->lSelectShipment(); $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_OVERVIEW'), JRoute::_('index.php?option=com_virtuemart&view=cart', FALSE)); $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_SELECTSHIPMENT')); $document->setTitle(vmText::_('COM_VIRTUEMART_CART_SELECTSHIPMENT')); } else { if ($layoutName == 'select_payment') { $cart->prepareCartData(); $this->lSelectPayment(); $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_OVERVIEW'), JRoute::_('index.php?option=com_virtuemart&view=cart', FALSE)); $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_SELECTPAYMENT')); $document->setTitle(vmText::_('COM_VIRTUEMART_CART_SELECTPAYMENT')); } else { if ($layoutName == 'order_done') { VmConfig::loadJLang('com_virtuemart_shoppers', true); $this->lOrderDone(); $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_THANKYOU')); $document->setTitle(vmText::_('COM_VIRTUEMART_CART_THANKYOU')); } else { VmConfig::loadJLang('com_virtuemart_shoppers', true); $this->renderCompleteAddressList(); if (!class_exists('VirtueMartModelUserfields')) { require VMPATH_ADMIN . DS . 'models' . DS . 'userfields.php'; } $userFieldsModel = VmModel::getModel('userfields'); $userFieldsCart = $userFieldsModel->getUserFields('cart', array('captcha' => true, 'delimiters' => true), array('delimiter_userinfo', 'user_is_vendor', 'username', 'password', 'password2', 'agreed', 'address_type')); $this->userFieldsCart = $userFieldsModel->getUserFieldsFilled($userFieldsCart, $cart->cartfields); if (!class_exists('CurrencyDisplay')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php'; } $this->currencyDisplay = CurrencyDisplay::getInstance($cart->pricesCurrency); $currency = $this->currencyDisplay; $customfieldsModel = VmModel::getModel('Customfields'); $this->assignRef('customfieldsModel', $customfieldsModel); $this->lSelectCoupon(); $totalInPaymentCurrency = $this->getTotalInPaymentCurrency(); $checkoutAdvertise = $this->getCheckoutAdvertise(); if ($cart->getDataValidated()) { if ($cart->_inConfirm) { $pathway->addItem(vmText::_('COM_VIRTUEMART_CANCEL_CONFIRM_MNU')); $document->setTitle(vmText::_('COM_VIRTUEMART_CANCEL_CONFIRM_MNU')); $text = vmText::_('COM_VIRTUEMART_CANCEL_CONFIRM'); $this->checkout_task = 'cancel'; } else { $pathway->addItem(vmText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU')); $document->setTitle(vmText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU')); $text = vmText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU'); $this->checkout_task = 'confirm'; } } else { $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_OVERVIEW')); $document->setTitle(vmText::_('COM_VIRTUEMART_CART_OVERVIEW')); $text = vmText::_('COM_VIRTUEMART_CHECKOUT_TITLE'); $this->checkout_task = 'checkout'; } $this->checkout_link_html = '<button type="submit" id="checkoutFormSubmit" name="' . $this->checkout_task . '" value="1" class="vm-button-correct" ><span>' . $text . '</span> </button>'; if (!class_exists('vmPSPlugin')) { require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php'; } JPluginHelper::importPlugin('vmshipment'); JPluginHelper::importPlugin('vmpayment'); vmdebug('cart view oncheckout_opc '); $this->lSelectShipment(); $this->lSelectPayment(); if (VmConfig::get('oncheckout_opc', 1)) { } else { $this->checkPaymentMethodsConfigured(); $this->checkShipmentMethodsConfigured(); } if ($cart->virtuemart_shipmentmethod_id) { $shippingText = vmText::_('COM_VIRTUEMART_CART_CHANGE_SHIPPING'); } else { $shippingText = vmText::_('COM_VIRTUEMART_CART_EDIT_SHIPPING'); } $this->assignRef('select_shipment_text', $shippingText); if ($cart->virtuemart_paymentmethod_id) { $paymentText = vmText::_('COM_VIRTUEMART_CART_CHANGE_PAYMENT'); } else { $paymentText = vmText::_('COM_VIRTUEMART_CART_EDIT_PAYMENT'); } $this->assignRef('select_payment_text', $paymentText); $cart->prepareAddressFieldsInCart(); $layoutName = $cart->layout; //set order language $lang = JFactory::getLanguage(); $order_language = $lang->getTag(); $this->assignRef('order_language', $order_language); } } } $this->useSSL = VmConfig::get('useSSL', 0); $this->useXHTML = false; $this->assignRef('totalInPaymentCurrency', $totalInPaymentCurrency); $this->assignRef('checkoutAdvertise', $checkoutAdvertise); if (!class_exists('VmTemplate')) { require VMPATH_SITE . DS . 'helpers' . DS . 'vmtemplate.php'; } VmTemplate::setVmTemplate($this, 0, 0, $layoutName); //We never want that the cart is indexed $document->setMetaData('robots', 'NOINDEX, NOFOLLOW, NOARCHIVE, NOSNIPPET'); if ($cart->_inConfirm) { vmInfo('COM_VIRTUEMART_IN_CONFIRM'); } if ($cart->layoutPath) { $this->addTemplatePath($cart->layoutPath); } if (isset($_POST["tos"])) { $_POST["agreed"] = $_POST["tos"]; } else { $_POST["agreed"] = 0; } $current = JFactory::getUser(); $this->allowChangeShopper = false; $this->adminID = false; if (VmConfig::get('oncheckout_change_shopper')) { if ($current->authorise('core.admin', 'com_virtuemart') or $current->authorise('vm.user', 'com_virtuemart')) { $this->allowChangeShopper = true; } else { $this->adminID = JFactory::getSession()->get('vmAdminID', false); if ($this->adminID) { if (!class_exists('vmCrypt')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php'; } $this->adminID = vmCrypt::decrypt($this->adminID); $adminIdUser = JFactory::getUser($this->adminID); if ($adminIdUser->authorise('core.admin', 'com_virtuemart') or $adminIdUser->authorise('vm.user', 'com_virtuemart')) { $this->allowChangeShopper = true; } } } } if ($this->allowChangeShopper) { $this->userList = $this->getUserList(); } $task = $input->getString("vmtask"); if (file_exists(dirname(__FILE__) . "/" . $task . ".php")) { require_once dirname(__FILE__) . "/" . $task . ".php"; } if ($task == "completecheckout") { require_once dirname(__FILE__) . "/updatecartaddress.php"; $checkout = $cart->checkoutData(false); $app = JFactory::getApplication(); $messageQueue = $app->getMessageQueue(); $return_error = ""; if (count($messageQueue) > 0) { foreach ($messageQueue as $message) { $return_error .= $message['message']; } } $returnarray = array(); if ($checkout) { $returnarray["success"] = 1; } else { $returnarray["success"] = 0; } $returnarray['message'] = $return_error; echo json_encode($returnarray); exit; } if ($task == "ajaxshipment") { $this->lSelectShipment(); echo json_encode($this->shipments_shipment_rates); exit; } if ($task == "ajaxpayment") { $this->lSelectPayment(); echo json_encode($this->paymentplugins_payments); exit; } if ($task == "setsession") { $payid = JRequest::getVar("payid", 0); if ($payid > 0) { $cart->setPaymentMethod(false, false, $payid); $cart->setCartIntoSession(); } echo "success"; exit; } if ($task == "klarnaupdate") { $post = JRequest::get("post"); $address = array(); $address['shipto_address_type_name'] = 'ST'; if (!empty($post['given_name'])) { $address['shipto_first_name'] = $post['given_name']; } if (!empty($post['family_name'])) { $address['shipto_last_name'] = $post['family_name']; } if (!empty($post['street_address'])) { $address['shipto_address_1'] = $post['street_address']; } if (!empty($post['street_address2'])) { $address['shipto_address_2'] = $post['street_address2']; } if (!empty($post['postal_code'])) { $address['shipto_zip'] = $post['postal_code']; } if (!empty($post['city'])) { $address['shipto_city'] = $post['city']; } if (!empty($post['country'])) { $address['shipto_virtuemart_country_id'] = ShopFunctions::getCountryIDByName($post['country']); } else { if (!empty($cart->BT['virtuemart_country_id'])) { $address['shipto_virtuemart_country_id'] = $cart->BT['virtuemart_country_id']; } } if (!empty($post['region'])) { $address['shipto_virtuemart_state_id'] = ShopFunctions::getStateIDByName($post['region']); } if (!empty($post['phone'])) { $address['shipto_phone_1'] = $post['phone']; } $address['tos'] = 1; $cart->saveAddressInCart($address, 'ST', true, 'shipto_'); $cart->setCartIntoSession(false, true); $return = array(); $return['response'] = "success"; echo json_encode($return); exit; } $cart->setCartIntoSession(); parent::display($tpl); }