function confirmedOrder() { $cart =& self::$current_cart; $payment_id = $cart->virtuemart_paymentmethod_id; include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php'; //Just to prevent direct call if ($cart->_dataValidated && $cart->_confirmDone) { require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php'; $orderModel = OPCmini::getModel('Orders'); $this->getModifiedData($cart); if (!empty($delivery_date)) { $cart->delivery_date = $delivery_date; } $orderID = $orderModel->createOrderFromCart($cart); $this->getModifiedData($cart, true); $msgq1 = JFactory::getApplication()->get('messageQueue', array()); $msgq2 = JFactory::getApplication()->get('_messageQueue', array()); $op_disable_shipping = OPCloader::getShippingEnabled($cart); if ($op_disable_shipping) { //$q = 'update #__virtuemart_orders set } if (empty($orderID)) { $mainframe = JFactory::getApplication(); $this->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart&task=checkout', false, VmConfig::get('useSSL', false))); } $cart->virtuemart_order_id = $orderID; $order = $orderModel->getOrder($orderID); self::$new_order =& $order; $this->getModifiedOrder($order, $cart); // $GLOBALS['is_dup'] if (!empty($orderID)) { if (!empty($GLOBALS['is_dup']) && is_numeric($GLOBALS['is_dup'])) { $dbj = JFactory::getDBO(); $q = "update #__virtuemart_orders SET virtuemart_user_id = '" . $this->getEscaped($dbj, $GLOBALS['is_dup']) . "' where virtuemart_order_id = '" . $this->getEscaped($dbj, $orderID) . "' limit 1"; $dbj->setQuery($q); $dbj->query(); $dbj = JFactory::getDBO(); $q = "update #__virtuemart_order_userinfos SET virtuemart_user_id = '" . $this->getEscaped($dbj, $GLOBALS['is_dup']) . "' where virtuemart_order_id = '" . $this->getEscaped($dbj, $orderID) . "' limit 2"; $dbj->setQuery($q); $dbj->query(); $e = $dbj->getErrorMsg(); } else { if (!empty($GLOBALS['opc_new_user']) && is_numeric($GLOBALS['opc_new_user'])) { $dbj = JFactory::getDBO(); $q = "update #__virtuemart_orders SET virtuemart_user_id = '" . $this->getEscaped($dbj, $GLOBALS['opc_new_user']) . "' where virtuemart_order_id = '" . $this->getEscaped($dbj, $orderID) . "' limit 1"; $dbj->setQuery($q); $dbj->query(); $dbj = JFactory::getDBO(); $q = "update #__virtuemart_order_userinfos SET virtuemart_user_id = '" . $this->getEscaped($dbj, $GLOBALS['opc_new_user']) . "' where virtuemart_order_id = '" . $this->getEscaped($dbj, $orderID) . "' limit 2"; $dbj->setQuery($q); $dbj->query(); $e = $dbj->getErrorMsg(); } } } //opc_new_user if (empty($order['details']['ST']->email) && !empty($order['details']['BT']->email)) { $order['details']['ST']->email = $order['details']['BT']->email; } // $cart = $this->getCart(); if (isset($order['details']['BT'])) { $this->doCurl($order['details']['BT']); } $dispatcher = JDispatcher::getInstance(); // $html=""; if ($order['details']['BT']->order_total <= 0) { $no_payment = true; } else { $no_payment = false; } if (empty($op_disable_shipping)) { JPluginHelper::importPlugin('vmshipment'); } JPluginHelper::importPlugin('vmcustom'); if (empty($no_payment)) { JPluginHelper::importPlugin('vmpayment'); } JPluginHelper::importPlugin('vmcustom'); JPluginHelper::importPlugin('vmcalculation'); $session = JFactory::getSession(); $return_context = $session->getId(); //end OPC email mod ob_start(); $order = $orderModel->getOrder($orderID); if ($order['details']['BT']->order_status != $zero_total_status) { if ($order['details']['BT']->order_total <= 0) { require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php'; $modelOrder = OPCmini::getModel('orders'); $order['order_status'] = $zero_total_status; $order['customer_notified'] = 1; $order['comments'] = ''; $modelOrder->updateStatusForOneOrder($orderID, $order, true); //$order['paymentName']= $dbValues['payment_name']; //We delete the old stuff $cart->emptyCart(); } } $output = ob_get_clean(); //$returnValues = $dispatcher->trigger('plgVmConfirmedOrder', array($cart, $order)); // pairs the cookie with the database $returnValues = $dispatcher->trigger('plgOpcOrderCreated', array($cart, $order)); // runs shipping confirm as first and payment as last $returnValues = $dispatcher->trigger('plgVmConfirmedOrderOPC', array('shipment', $cart, $order)); $returnValues = $dispatcher->trigger('plgVmConfirmedOrderOPC', array('calculation', $cart, $order)); $returnValues = $dispatcher->trigger('plgVmConfirmedOrderOPC', array('custom', $cart, $order)); $except = array('shipment', 'custom', 'calculation'); $returnValues = $dispatcher->trigger('plgVmConfirmedOrderOPCExcept', array($except, $cart, $order)); //OPC: maybe we want to send emil before a redirect: if (!empty($send_pending_mail)) { if (!class_exists('shopFunctionsF')) { require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'; } //Important, the data of the order update mails, payments and invoice should //always be in the database, so using getOrder is the right method require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php'; $orderModel = OPCmini::getModel('orders'); //$order = $orderModel->getOrder($orderID); $payment_name = $shipment_name = ''; $op_disable_shipping = OPCloader::getShippingEnabled($cart); $msgqx1 = JFactory::getApplication()->get('messageQueue', array()); $msgqx2 = JFactory::getApplication()->get('_messageQueue', array()); $msgqx3 = JFactory::getApplication()->getMessageQueue(); if (!class_exists('vmPSPlugin')) { require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php'; } if (empty($op_disable_shipping)) { JPluginHelper::importPlugin('vmshipment'); } if (empty($no_payment)) { JPluginHelper::importPlugin('vmpayment'); } $dispatcher = JDispatcher::getInstance(); if (empty($op_disable_shipping)) { $returnValues = $dispatcher->trigger('plgVmonShowOrderPrintShipment', array($order['details']['BT']->virtuemart_order_id, $order['details']['BT']->virtuemart_shipmentmethod_id, &$shipment_name)); } if (empty($no_payment)) { $returnValues = $dispatcher->trigger('plgVmonShowOrderPrintPayment', array($order['details']['BT']->virtuemart_order_id, $order['details']['BT']->virtuemart_paymentmethod_id, &$payment_name)); } $order['shipmentName'] = $shipment_name; if (empty($no_payment)) { $order['paymentName'] = $payment_name; } else { $order['paymentName'] = ''; } $vars['orderDetails'] = $order; if (!isset($vars['newOrderData'])) { $vars['newOrderData'] = array(); } $vars['newOrderData']['customer_notified'] = 1; $vars['url'] = 'url'; $vars['doVendor'] = false; if (!empty($order['details']['BT']->virtuemart_vendor_id)) { $virtuemart_vendor_id = $order['details']['BT']->virtuemart_vendor_id; } else { $virtuemart_vendor_id = 1; } require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php'; $vendorModel = OPCmini::getModel('vendor'); $vendor = $vendorModel->getVendor($virtuemart_vendor_id); $vars['vendor'] = $vendor; $vendorEmail = $vendorModel->getVendorEmail($virtuemart_vendor_id); if (empty($vendorEmail)) { $db = JFactory::getDBO(); $query = 'SELECT * FROM `#__virtuemart_vmusers`'; $db->setQuery($query); $res = $db->loadAssocList(); $query = 'SELECT ju.email FROM `#__virtuemart_vmusers` as vmu, `#__users` as ju WHERE `virtuemart_vendor_id`=' . (int) $virtuemart_vendor_id . ' and ju.id = vmu.virtuemart_user_id and vmu.user_is_vendor = 1 limit 0,1'; $db->setQuery($query); $vendorEmail = $db->loadResult(); } $vars['vendorEmail'] = $vendorEmail; // Send the email if (file_exists(JPATH_VM_SITE . DS . 'views' . DS . 'invoice' . DS . 'view.html.php')) { if (OPCcheckout::renderMail('invoice', $vendorEmail, $vars, null, true, false)) { //ok } $x = JFactory::getApplication()->set('messageQueue', $msgqx1); $x = JFactory::getApplication()->set('_messageQueue', $msgqx2); if (OPCJ3) { if (class_exists('ReflectionClass')) { $a = JFactory::getApplication(); $reflectionClass = new ReflectionClass($a); $property = $reflectionClass->getProperty('_messageQueue'); $property->setAccessible(true); $property->setValue($a, $msgqx3); $x = JFactory::getApplication()->getMessageQueue(); } } } } /* jimport( 'joomla.plugin.helper' ); $plugin = JPluginHelper::getPlugin('vmpayment', 'opctracking'); if (!empty($plugin)) { $opctracking = true; } else { $opctracking = false; } */ //$html = JRequest::getVar('html', JText::_('COM_VIRTUEMART_ORDER_PROCESSED'), null, 'string', JREQUEST_ALLOWRAW); $html = JRequest::getVar('html', JText::_('COM_VIRTUEMART_ORDER_PROCESSED'), 'default', 'STRING', JREQUEST_ALLOWRAW); $app = JFactory::getApplication(); require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'config.php'; $utm_p_load = false; $default = array(); $utm_p = OPCConfig::getValue('opc_config', 'utm_payments', 0, $default, false, false); if (!empty($payment_id)) { if (in_array($payment_id, $utm_p)) { $utm_p_load = true; } } if (method_exists($app, 'input')) { $html2 = $app->input->get('html', JText::_('COM_VIRTUEMART_ORDER_PROCESSED'), 'RAW'); if ($utm_p_load) { $html2 = str_replace('&view=', '&utm_nooverride=1&view=', $html2); $html2 = str_replace('&view=', '&utm_nooverride=1&view=', $html2); $app->input->set('html', $html2); } } else { $html2 = JRequest::getVar('html', JText::_('COM_VIRTUEMART_ORDER_PROCESSED'), 'default', 'STRING', JREQUEST_ALLOWRAW); if ($utm_p_load) { $html2 = str_replace('&view=pluginresponse', '&utm_nooverride=1&view=pluginresponse', $html2); $html2 = str_replace('&view=pluginresponse', '&utm_nooverride=1&view=pluginresponse', $html2); JRequest::setVar('html', $html2); } } if ($html != $html2) { $output .= $html2; } $output .= $html; ob_start(); if ($order['details']['BT']->order_total <= 0) { $cart->emptyCart(); } $output .= ob_get_clean(); $x = JFactory::getApplication()->set('messageQueue', $msgq1); $x = JFactory::getApplication()->set('_messageQueue', $msgq2); if (!empty($output)) { return $output; } // may be redirect is done by the payment plugin (eg: paypal) // if payment plugin echos a form, false = nothing happen, true= echo form , // 1 = cart should be emptied, 0 cart should not be emptied } }
function checkout() { /* $savedGET = $_GET; $savedPOST = $_POST; $savedREQUEST = $_REQUEST; */ // before we do anything, let's check captcha: include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php'; if (!class_exists('OPCLang')) { require JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'language.php'; } OPCLang::loadLang(); //mobile handling: if (!defined('OPC_DETECTED_DEVICE')) { if (class_exists('OPCplugin')) { OPCplugin::detectMobile(); } } if (!isset($opc_memory)) { $opc_memory = '128M'; } ini_set('memory_limit', $opc_memory); ini_set('error_reporting', 0); // disable error reporting for ajax: error_reporting(0); $logged = false; if (JFactory::getUser()->guest) { } else { $logged = true; } include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php'; if (!empty($enable_captcha_logged) && $logged || !empty($enable_captcha_unlogged) && !$logged) { $this->checkOPCCaptcha(); } if (!class_exists('VmConfig')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php'; } VmConfig::loadConfig(); // since vm2.0.21a we need to load the language files here OPCLang::loadLang(); $this->prepareFields(); // fedex multibox fix: // register user first: $reg = JRequest::getVar('register_account'); if (empty($reg)) { $reg = false; } else { $reg = true; } // ENABLE ONLY BUSINESS REGISTRATION WHEN REGISTER_ACCOUNT IS SET AS BUSINESS FIELD require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php'; $is_business = JRequest::getVar('opc_is_business', 0); // we need to alter shopper group for business when set to: $is_business = JRequest::getVar('opc_is_business', 0); if (!empty($business_fields)) { if (!$is_business) { // manage required business fields when not business selected: foreach ($business_fields as $fn) { /* $x1 = JRequest::getVar($fn); if (empty($x1)) JRequest::setVar($fn, '_'); $x1 = JRequest::getVar('shipto_'.$fn); if (empty($x1)) JRequest::setVar('shipto_'.$fn, '_'); */ } } } if ($reg) { if (!empty($business_fields)) { if (in_array('register_account', $business_fields)) { if (empty($is_business)) { $reg = false; } } } } //if (!class_exists('VirtueMartControllerUser')) //require_once(JPATH_SITE.DS.'components'.DS.'com_virtuemart'.DS.'controllers'.DS.'user.php'); //$userC = new VirtueMartControllerUser(); $cart = VirtueMartCart::getCart(false); $mainframe = Jfactory::getApplication(); $virtuemart_currency_id = $mainframe->getUserStateFromRequest("virtuemart_currency_id", 'virtuemart_currency_id', JRequest::getInt('virtuemart_currency_id')); $cart->paymentCurrency = $virtuemart_currency_id; require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'shoppergroups.php'; OPCShopperGroups::setShopperGroupsController($cart); if (method_exists($cart, 'prepareCartData')) { $cart->prepareCartData(false); } if (!isset($cart->vendorId)) { $cart->vendorId = 1; } $payment_id = $cart->virtuemart_paymentmethod_id = JRequest::getInt('virtuemart_paymentmethod_id', ''); $cart->virtuemart_shipmentmethod_id = JRequest::getInt('virtuemart_shipmentmethod_id', ''); $coupon = JRequest::getVar('opc_coupon_code_returned', ''); if (!empty($coupon) && empty($cart->couponCode)) { $cart->couponCode = $coupon; } $this->runExt($cart); if (method_exists($cart, 'prepareCartProducts')) { $cart->prepareCartProducts(); } $this->setCartAddress($cart); $this->setExtAddress($cart, false); $order_language = JFactory::getLanguage()->getTag(); JRequest::setVar('order_language', $order_language); // k2 mod with recaptcha enabled $session = JFactory::getSession(); $orig = $session->get('socialConnectData'); $session->set('socialConnectData', true); // end p1 k2 mod with recaptcha enabled //$this->setShopperGroups($cart); $data = JRequest::get('post'); $data['quite'] = true; //suppress messages from thsi function $this->saveData($cart, $reg, false, $data); if (!empty($allow_sg_update)) { $this->storeShopperGroup($data, true); } $userModel = OPCmini::getModel('user'); if (method_exists($userModel, 'getCurrentUser')) { $user = $userModel->getCurrentUser(); self::$shopper_groups = $user->shopper_groups; } // k2 mod with recaptcha enabled if (empty($orig)) { $session->clear('socialConnectData'); } else { $session->set('socialConnectData', $orig); } // end p2 k2 mod with recaptcha enabled if (!class_exists('VirtueMartControllerCartOpc')) { require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'overrides' . DS . 'cartcontroller.php'; } $cartcontroller = new VirtueMartControllerCartOpc(); $po = JRequest::getVar('socialNumber', ''); if (method_exists($cartcontroller, 'setshipment')) { $cartcontroller->setshipment($cart); } // fix fedex multibox $saved_bt = $cart->BT; if (isset($_SESSION['load_fedex_prices_from_session'])) { unset($_SESSION['load_fedex_prices_from_session']); } if (method_exists($cartcontroller, 'setpayment')) { $cartcontroller->setpayment($cart); } if ($cart->BT != $saved_bt) { if (empty($cart->ST) || $cart->STsameAsBT) { $cart->STsameAsBT = 0; $cart->ST = $saved_bt; $text = JText::_('COM_ONEPAGE_USER_ENTERED_ADDRESS'); if ($text == 'COM_ONEPAGE_USER_ENTERED_ADDRESS') { $text = 'User Entered Address (Ship To)'; } $cart->ST['address_type_name'] = $text; $cart->BT['address_type_name'] = JText::_('COM_ONEPAGE_ADDRESS_HAD_CHANGED_NAME'); //$cart->BT = $saved_bt; } else { if ($cart->ST != $saved_bt) { $address_changed = JText::_('COM_ONEPAGE_ADDRESS_HAD_CHANGED'); $mainframe = JFactory::getApplication(); $mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart'), OPCLang::_('COM_ONEPAGE_ADDRESS_HAD_CHANGED')); return; } else { // $cart->BT = $saved_bt; } } } // security: JRequest::setVar('html', ''); $post = JRequest::get('post'); if (empty($cart->BT)) { } // fix the customer comment // $cart->customer_comment = JRequest::getVar('customer_comment', $cart->customer_comment); $cc = JRequest::getVar('customer_comment', ''); $cc2 = JRequest::getVar('customer_note', ''); if (empty($cart->customer_comment)) { $cart->customer_comment = $cc2 . $cc; } else { $cart->customer_comment = $cc2 . $cc; } JRequest::setVar('customer_comment', $cart->customer_comment); JRequest::setVar('customer_note', $cart->customer_comment); if (defined('VM_VERSION') && VM_VERSION >= 3) { $cart->BT['customer_note'] = $cart->customer_comment; } $OPCcheckout = new OPCcheckout($cart); $loader = new OPCloader(); OPCcheckout::$current_cart =& $cart; $OPCcheckout->checkoutData(false); if ($cart->_dataValidated) { $cart->_confirmDone = true; $order = null; $output = $OPCcheckout->confirmedOrder(); //$cart, $this, $order); /* jimport( 'joomla.plugin.helper' ); $plugin = JPluginHelper::getPlugin('vmpayment', 'opctracking'); if (!empty($plugin)) { $opctracking = true; } else { $opctracking = false; } */ require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'config.php'; $utm_p_load = false; $default = array(); $utm_p = OPCConfig::getValue('opc_config', 'utm_payments', 0, $default, false, false); if (!empty($payment_id)) { if (in_array($payment_id, $utm_p)) { $utm_p_load = true; } } if ($utm_p_load) { $output = str_replace('&view=pluginresponse', '&utm_nooverride=1&view=pluginresponse', $output); $output = str_replace('&view=pluginresponse', '&utm_nooverride=1&view=pluginresponse', $output); } require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'removemsgs.php'; OPCremoveMsgs::removeMsgs($cart); $order =& OPCcheckout::$new_order; $session = JFactory::getSession(); if (!empty($order)) { if ($order['details']['BT']->order_total <= 0) { $dispatcher = JDispatcher::getInstance(); $returnValues = $dispatcher->trigger('registerOrderAttempt', array(&$order)); $cart->emptyCart(); } } } else { $mainframe = JFactory::getApplication(); $mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart'), 'Captcha: ' . OPCLang::_('COM_VIRTUEMART_CART_CHECKOUT_DATA_NOT_VALID')); } // some extensions somehow reset the language, and we need to set it to the proper one: $lang = JFactory::getLanguage(); $tag = $lang->getTag(); $filename = 'com_virtuemart'; $lang->load($filename, JPATH_ADMINISTRATOR, $tag, true); $lang->load($filename, JPATH_SITE, $tag, true); //$post = JRequest::get('post'); $mainframe = JFactory::getApplication(); $pathway = $mainframe->getPathway(); $document = JFactory::getDocument(); // $html = JRequest::getVar('html', OPCLang::_('COM_VIRTUEMART_ORDER_PROCESSED'), 'post', 'STRING', JREQUEST_ALLOWRAW); $document->setTitle(OPCLang::_('COM_VIRTUEMART_CART_THANKYOU')); $cart->setCartIntoSession(); // now the plugins should have already loaded the redirect html // we can safely $virtuemart_order_id = $cart->virtuemart_order_id; JRequest::setVar('view', 'cart'); $_REQUEST['view'] = 'cart'; $_POST['view'] = 'cart'; $_GET['view'] = 'cart'; $view = $this->getView('cart', 'html'); $currencyDisplay = CurrencyDisplay::getInstance($cart->pricesCurrency); $view->currencyDisplay = $currencyDisplay; $view->addTemplatePath(JPATH_VM_SITE . DS . 'views' . DS . 'cart' . DS . 'tmpl' . DS); $view->cart = $cart; $display_title = JRequest::getVar('display_title', true); $view->display_title = $display_title; $view->setLayout('order_done'); $view->assignRef('html', $output); // commented for 2.0.22a //JRequest::setVar('html', $output); //$view->html = $output; // Display it all ob_start(); $view->display(); $html1 = ob_get_clean(); $items = $pathway->getPathwayNames(); $skipp = false; foreach ($items as $i) { if ($i == OPCLang::_('COM_VIRTUEMART_CART_THANKYOU')) { $skipp = true; } } if (!$skipp) { $pathway->addItem(OPCLang::_('COM_VIRTUEMART_CART_THANKYOU')); } if (empty($html1)) { $html1 = $output; } JRequest::setVar('view', 'opccart'); JRequest::setVar('contoller', 'opccart'); $html2 = ''; if (!empty($append_details)) { // ok, lets try to alter it with the order details JRequest::setVar('order_pass', $order['details']['BT']->order_pass); JRequest::setVar('order_number', $order['details']['BT']->order_number); JRequest::setVar('virtuemart_order_id', $order['details']['BT']->virtuemart_order_id); //JRequest::setVar('tmpl', 'component'); $html2 = $this->getVMView('orders', array(), 'orders', 'details', 'html'); } $allhtml = $html1 . $html2; $this->runExtAfter($allhtml); echo $allhtml; JRequest::setVar('html', ''); JRequest::setVar('html', $allhtml); JRequest::setVar('view', 'cart'); $_REQUEST['view'] = 'cart'; $_POST['view'] = 'cart'; $_GET['view'] = 'cart'; if (!empty($theme_fix1)) { JRequest::setVar('layout', 'order_done'); } /* $_GET = $savedGET; $_POST = $savedPOST; $_REQUEST = $savedREQUEST; */ return; }
<tr> <td class="key"> <label for="utm_payment" ><?php echo JText::_('COM_ONEPAGE_UTM_PAYMENT_LABEL'); ?> </label> </td> <td colspan="1" > <select id="utm_payment" name="utm_payment[]" class="vm-chzn-select" multiple="multiple" data-placeholder="<?php echo JText::_('COM_VIRTUEMART_PAYMENTMETHOD_S'); ?> " style="min-width: 150px; "> <?php $default = array(); $utm_p = OPCConfig::getValue('opc_config', 'utm_payments', 0, $default, false, false); foreach ($this->pms as $p) { ?> <option value=<?php echo '"' . $p['payment_method_id'] . '" '; if (in_array($p['payment_method_id'], $utm_p)) { echo 'selected="selected" '; } ?> ><?php echo $p['payment_method_name']; ?> </option> <?php } ?>