* VirtueMart is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * */ if (!defined('_VALID_MOS') && !defined('_JEXEC')) { die('Direct Access to ' . basename(__FILE__) . ' is not allowed.'); } $document = JFactory::getDocument(); ob_start(); echo '<div id="vmMainPageOPC">'; include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php'; require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'config.php'; $newitemid = OPCconfig::getValue('opc_config', 'newitemid', 0, 0, true); if (OPCloader::checkOPCSecret()) { $selected_template .= '_preview'; } $currentUser = JFactory::getUser(); $uid = $currentUser->get('id'); if (!empty($uid)) { $no_login_in_template = true; } JHTMLOPC::stylesheet('onepage.css', 'components/com_onepage/themes/' . $selected_template . '/', array()); //JHTML::_('behavior.formvalidation'); JHTMLOPC::stylesheet('vmpanels.css', 'components/com_virtuemart/assets/css/', array()); if (!empty($load_min_bootstrap)) { JHTMLOPC::stylesheet('bootstrap.min.css', 'components/com_onepage/themes/extra/bootstrap/', array()); } if (VM_REGISTRATION_TYPE == 'NO_REGISTRATION') { $no_login_in_template = true;
function fetch(&$ref, $template, $vars, $new = '') { include JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php'; if (defined('OPC_DETECTED_DEVICE') && OPC_DETECTED_DEVICE != 'DESKTOP') { if (!empty($mobile_template)) { $selected_template = $mobile_template; } } OPCloader::setRegType(); if (VM_REGISTRATION_TYPE != 'OPTIONAL_REGISTRATION') { $op_create_account_unchecked = false; } if (!empty($ref->cart)) { $cart = $ref->cart; } else { $cart = VirtueMartCart::getCart(false); } $op_disable_shipping = OPCloader::getShippingEnabled(); $no_shipping = $op_disable_shipping; if (OPCloader::checkOPCSecret()) { $selected_template .= '_preview'; } $f = JPATH_OPC . DS . 'themes' . DS . $selected_template . DS . 'overrides' . DS . $template . '.php'; //var_dump($f); die(); if (file_exists($f)) { ob_start(); extract($vars); include $f; $ret = ob_get_clean(); return $ret; } else { if (!empty($new)) { $ly = $ref->layoutName; if (empty($ly)) { $ly = 'default'; } if (empty($new)) { $new = 'prices'; } if (file_exists(JPATH_SITE . DS . 'components' . DS . 'com_virtuemart' . DS . 'views' . DS . 'cart' . DS . 'tmpl' . DS . $ly . '_' . $new . '.php')) { ob_start(); include JPATH_SITE . DS . 'components' . DS . 'com_virtuemart' . DS . 'views' . DS . 'cart' . DS . 'tmpl' . DS . $ly . '_' . $new . '.php'; $ret = ob_get_clean(); return $ret; } } } }
public static function addtocartaslink(&$ref) { $c = get_class($ref->cart); if ($c != 'VirtuemartCart') { $ref->cart = VirtuemartCart::getCart(); } include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php'; $rememberhtml = ''; $rp = JRequest::getVar('randomproduct', 0); if (!empty($rp)) { if (OPCloader::checkOPCSecret()) { $opc_link_type = 1; $q = 'select virtuemart_product_id from #__virtuemart_products where published=1 limit 1'; $db = JFactory::getDBO(); $db->setQuery($q); $temp_id = $db->loadResult(); JRequest::setVar('add_id', $temp_id); } } if (empty($opc_link_type)) { return; } $p_id = JRequest::getVar('add_id', ''); if (empty($p_id)) { return; } if (!isset($ref->cart->order_number)) { $ref->cart->order_number = ''; } if (!empty($p_id)) { $qq = array(); if (is_array($p_id)) { foreach ($p_id as $i => $item) { if (!is_numeric($p_id[$i])) { break; } $q = JRequest::getVar('qadd_' . $p_id[$i], 1); if (!is_numeric($q)) { break; } $rememberhtml .= '<input type="hidden" name="qadd_' . $p_id[$i] . '" value="' . $q . '" />'; $rememberhtml .= '<input type="hidden" name="add_id[' . $i . ']" value="' . $p_id[$i] . '" />'; $q = (double) $q; $qq[$p_id[$i]] = $q; } } else { // you can use /index.php?option=com_virtuemart&page=shop.cart&add_id=10&quadd=1; // to add two products (ids: 10 and 11) of two quantity each (quadd_11=2 for product id 11 set quantity 2) // OR /index.php?option=com_virtuemart&page=shop.cart&add_id[]=10&quadd_10=2&add_id[]=11&qadd_11=2 $q = JRequest::getVar('qadd_' . $p_id, 1); $rememberhtml .= '<input type="hidden" name="qadd_' . $p_id . '" value="' . $q . '" />'; $rememberhtml .= '<input type="hidden" name="add_id" value="' . $p_id . '" />'; $q = (double) $q; $q2 = JRequest::getVar('qadd', 1); //$rememberhtml .= '<input type="hidden" name="qadd" value="'.$q2.'" />'; if (!is_numeric($p_id)) { return; } $qq[$p_id] = $q; $a = array(); $a[$p_id] = $p_id; $p_id = $a; } } else { return; } $post = JRequest::get('default'); /* if (!class_exists('VirtueMartModelProduct')) require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'product.php'); */ require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php'; $productClass = OPCmini::getModel('product'); //new VirtueMartModelProduct(); //$virtuemart_product_ids = JRequest::getVar('virtuemart_product_id', array(), 'default', 'array'); //is sanitized then $newp = array(); $rr2 = array(); foreach ($p_id as $pid) { $newp[$pid] = $pid; $product = $productClass->getProductSingle($pid, true, true, true); $rr = OPCAddToCartAsLink::getProductCustomsFieldCart($product); $rr2[] = $rr; } if ($opc_link_type == 2 || $opc_link_type == 1) { if (!empty($ref->cart->products)) { $p = $ref->cart->products; foreach ($p as $key => $pr) { $id = $pr->virtuemart_product_id; // delete cart content if ($opc_link_type == 1) { if (isset($ref->cart->products[$key])) { $ref->cart->removeProductCart($key); } else { if (isset($ref->cart->product[$id])) { $ref->cart->removeProductCart($id); } } continue; } // do not increment quantity: if ($opc_link_type == 2) { if (in_array($id, $newp)) { return; } } } } } $virtuemart_product_ids = JRequest::setVar('virtuemart_product_id', $newp); //is sanitized then $virtuemart_product_ids = JRequest::setVar('quantity', $qq); //is sanitized then if (!empty($rr2)) { foreach ($rr2 as $rr1) { foreach ($rr1 as $post) { $x = JRequest::getVar($post['name']); if (empty($x)) { $test = array(); if (strpos($post['name'], ']') !== false) { $post['name'] = parse_str($post['name'] . '=' . $post['value'], $test); $firstkey = 0; if (!empty($test)) { foreach ($test as $key => $val) { $firstkey = $key; break; } } $name = $firstkey; $value = $test[$name]; JRequest::setVar($name, $value); } else { JRequest::setVar($post['name'], $post['value']); } } } } } if (!empty($opc_auto_coupon)) { $ref->cart->couponCode = $opc_auto_coupon; } $ref->cart->add(); JRequest::setVar('virtuemart_product_id', ''); JRequest::setVar('add_id', ''); JRequest::setVar('opc_adc', 1); //$quantityPost = (int) $post['quantity'][$p_key]; return $rememberhtml; }