Exemple #1
0
 function getExtraPluginNameInfo()
 {
     if (!class_exists('VirtueMartCart')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     $cart = VirtueMartCart::getCart();
     //if (!isset($cart->cartPrices)) {
     $cart->getCartPrices();
     //}
     $pbxTotalVendorCurrency = $this->getPbxAmount($cart->cartPrices['salesPrice']);
     $subscribe = $this->getSubscribeProducts($cart, $pbxTotalVendorCurrency);
     $extraInfo = false;
     if (!empty($subscribe)) {
         $extraInfo['subscribe'] = true;
         $amount2montInCurrency = vmPSPlugin::getAmountInCurrency($subscribe['PBX_2MONT'] * 0.01, $this->_method->payment_currency);
         $amount1montInCurrency = vmPSPlugin::getAmountInCurrency($subscribe['PBX_TOTAL'] * 0.01, $this->_method->payment_currency);
         $extraInfo['subscribe_2mont'] = $amount2montInCurrency['display'];
         $extraInfo['subscribe_1mont'] = $amount1montInCurrency['display'];
         $extraInfo['subscribe_nbpaie'] = $subscribe['PBX_NBPAIE'];
         $extraInfo['subscribe_freq'] = $subscribe['PBX_FREQ'];
         $extraInfo['subscribe_quand'] = $this->_method->subscribe_quand;
         $extraInfo['subscribe_delais'] = $this->_method->subscribe_delais;
     }
     return $extraInfo;
 }
Exemple #2
0
 function __construct()
 {
     if (!class_exists('VmConfig')) {
         require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php';
     }
     $this->cart = VirtueMartCart::getCart(false);
     JFactory::getLanguage()->load('com_virtuemart');
 }
Exemple #3
0
 public function withKeepAlive()
 {
     if (!class_exists('VirtueMartCart')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     $cart = VirtueMartCart::getCart();
     if (!empty($cart->cartProductsData)) {
         vmJsApi::keepAlive(1, 4);
     }
 }
 public function display($tpl = null)
 {
     $document = JFactory::getDocument();
     $layoutName = $this->getLayout();
     if (!$layoutName) {
         $layoutName = JRequest::getWord('layout', 'default');
     }
     $this->assignRef('layoutName', $layoutName);
     $format = JRequest::getWord('format');
     JLoader::register('VirtueMartCart', JPATH_VM_SITE . '/helpers/cart.php');
     $cart = VirtueMartCart::getCart();
     $this->assignRef('cart', $cart);
     $this->prepareContinueLink();
     shopFunctionsF::setVmTemplate($this, 0, 0, $layoutName);
     parent::display($tpl);
 }
 public function display($tpl = null)
 {
     $document = JFactory::getDocument();
     $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();
     $this->assignRef('cart', $cart);
     $this->prepareContinueLink();
     shopFunctionsF::setVmTemplate($this, 0, 0, $layoutName);
     parent::display($tpl);
 }
Exemple #6
0
 public function display($tpl = null)
 {
     $layoutName = $this->getLayout();
     if (!$layoutName) {
         $layoutName = vRequest::getCmd('layout', 'default');
     }
     $this->assignRef('layoutName', $layoutName);
     if (!class_exists('VirtueMartCart')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     $this->cart = VirtueMartCart::getCart();
     $this->prepareContinueLink();
     if (!class_exists('VmTemplate')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'vmtemplate.php';
     }
     VmTemplate::setVmTemplate($this, 0, 0, $layoutName);
     parent::display($tpl);
 }
Exemple #7
0
 public static function getList($params)
 {
     if (class_exists('VirtueMartCart')) {
         $productModel = VmModel::getModel('product');
         $calculator = calculationHelper::getInstance();
         $customfields = VmModel::getModel('Customfields');
         $cart = VirtueMartCart::getCart(false);
         $cart->pricesUnformatted = $calculator->getCheckoutPrices($cart, true);
         $viewName = vRequest::getString('view', 0);
         if ($viewName == 'cart') {
             $checkAutomaticPS = true;
         } else {
             $checkAutomaticPS = false;
         }
         $cart->prepareAjaxData($checkAutomaticPS);
         $productModel->addImages($cart->products);
         ini_set('xdebug.var_display_max_depth', 10);
         return $cart;
     }
 }
 /**
  * Do something onAfterDispatch 
  */
 function onAfterDispatch()
 {
     global $mainframe, $Itemid, $page, $option, $cart, $_SESSION, $_POST, $_REQUEST, $VM_CHECKOUT_MODULES, $ship_to_info_id, $vars, $auth, $sess;
     // if Admin side, just exit
     $application = JFactory::getApplication();
     if ($application->isAdmin()) {
         return;
     }
     $option = JRequest::getCmd('option');
     if ($option != 'com_virtuemart') {
         return;
     }
     $plugin =& JPluginHelper::getPlugin('system', 'vmskipcart');
     if (JFile::exists(JPATH_SITE . '/components/com_virtuemart/virtuemart_parser.php')) {
         //Virtuemart 1.1.x
         $currentPage = $page;
         $cart = $_SESSION['cart'];
         if ($currentPage == 'shop.cart' && $cart["idx"]) {
             $href = $sess->url($_SERVER['PHP_SELF'] . '?page=checkout.index&ssl_redirect=1', true);
             $application->redirect($href);
         }
     } else {
         if (JFile::exists(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php') && class_exists('VirtueMartCart')) {
             //Virtuemart 2.0
             $view = JRequest::getWord('view');
             if ($view == 'cart') {
                 $session = JFactory::getSession();
                 $redirected = $session->get('vmcart_redirect', false, 'vmcart_redirect');
                 if (!$redirected) {
                     $cart = VirtueMartCart::getCart();
                     $session->set('vmcart_redirect', true, 'vmcart_redirect');
                     $cart->setDataValidation(true);
                     $cart->checkout();
                 } else {
                     $session->set('vmcart_redirect', false, 'vmcart_redirect');
                 }
             }
         }
     }
 }
Exemple #9
0
 /**
  * @param $html
  * @return bool|null|string
  */
 function plgVmOnPaymentResponseReceived(&$html)
 {
     if (!class_exists('VirtueMartCart')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     if (!class_exists('shopFunctionsF')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
     }
     if (!class_exists('VirtueMartModelOrders')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php';
     }
     //vmdebug('PAYPAL plgVmOnPaymentResponseReceived', $paypal_data);
     // the payment itself should send the parameter needed.
     $virtuemart_paymentmethod_id = JRequest::getInt('pm', 0);
     $order_number = JRequest::getString('on', 0);
     if (!($method = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) {
         return NULL;
         // Another method was selected, do nothing
     }
     if (!$this->selectedThisElement($method->payment_element)) {
         return NULL;
     }
     if (!($virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($order_number))) {
         return NULL;
     }
     if (!($paymentTable = $this->getDataByOrderId($virtuemart_order_id))) {
         // JError::raiseWarning(500, $db->getErrorMsg());
         return '';
     }
     $payment_name = $this->renderPluginName($method);
     $html = $this->_getPaymentResponseHtml($paymentTable, $payment_name);
     //We delete the old stuff
     // get the correct cart / session
     $cart = VirtueMartCart::getCart();
     $cart->emptyCart();
     return TRUE;
 }
 function updateCartWithKlarnacheckoutAddress()
 {
     if (!class_exists('VirtueMartCart')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     $cart = VirtueMartCart::getCart();
     $updated = false;
     $zip = vRequest::getWord('zip', '');
     $email = vRequest::getEmail('email', '');
     $first_name = vRequest::getWord('given_name', '');
     $last_name = vRequest::getWord('family_name', '');
     if ($zip) {
         $cart->BT['zip'] = $zip;
         $updated = true;
     }
     if ($email) {
         $cart->BT['email'] = $email;
         $updated = true;
     }
     if ($first_name) {
         $cart->BT['first_name'] = $first_name;
         $updated = true;
     }
     if ($last_name) {
         $cart->BT['last_name'] = $last_name;
         $updated = true;
     }
     if (!$updated) {
         return $updated;
     }
     $cart->setCartIntoSession();
     return $updated;
 }
Exemple #11
0
 */
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
// Implement Joomla's form validation
JHtml::_('behavior.formvalidation');
JHtml::stylesheet('vmpanels.css', JURI::root() . 'components/com_virtuemart/assets/css/');
?>
<h1><?php 
echo $this->page_title;
?>
</h1>
<?php 
if (!class_exists('VirtueMartCart')) {
    require VMPATH_SITE . DS . 'helpers' . DS . 'cart.php';
}
$this->cart = VirtueMartCart::getCart();
$url = 0;
if ($this->cart->_fromCart or $this->cart->getInCheckOut()) {
    $rview = 'cart';
} else {
    $rview = 'user';
}
$task = '';
if ($this->cart->getInCheckOut()) {
    //$task = '&task=checkout';
}
$url = JRoute::_('index.php?option=com_virtuemart&view=' . $rview . $task, $this->useXHTML, $this->useSSL);
echo shopFunctionsF::getLoginForm(TRUE, FALSE, $url);
$this->vmValidator();
?>
Exemple #12
0
	/**
	 * For Express Checkout
	 * @param $type
	 * @param $name
	 * @param $render
	 * @return bool|null
	 */

	function plgVmOnSelfCallFE($type, $name, &$render) {
		if ($name != $this->_name || $type != 'vmpayment') {
			return FALSE;
		}
		$action = jRequest::getWord('action');
		$virtuemart_paymentmethod_id = JRequest::getInt('virtuemart_paymentmethod_id');
		//Load the method
		if (!($this->_currentMethod = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) {
			return NULL; // Another method was selected, do nothing
		}
		if ($action != 'SetExpressCheckout') {
			return false;
		}
		if (!class_exists('VirtueMartCart')) {
			require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php');
		}
		$cart = VirtueMartCart::getCart();
		$cart->virtuemart_paymentmethod_id = $virtuemart_paymentmethod_id;
		$cart->setCartIntoSession();

		$paypalInterface = $this->_loadPayPalInterface();
		$paypalInterface->setCart($cart);
		$paypalInterface->setTotal($cart->pricesUnformatted['billTotal']);
		$paypalInterface->loadCustomerData();
		$paypalInterface->getExtraPluginInfo($this->_currentMethod);

		if (!$paypalInterface->validate()) {
			VmInfo('VMPAYMENT_PAYPAL_PAYMENT_NOT_VALID');
			return false;
		} else {
			$app = JFactory::getApplication();
			$app->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart&Itemid=' . JRequest::getInt('Itemid'), false));
		}
	}
Exemple #13
0
 /**
  * generate BillSafe informations from basket
  * @return array criterion for billSafe
  */
 private function getBasketDetails()
 {
     $user = JFactory::getUser();
     $cart = VirtueMartCart::getCart(false);
     $items = $cart->products;
     $prices = $cart->cartPrices;
     $params = array();
     if ($items) {
         $i = 0;
         //	ITEMS
         foreach ($items as $key => $item) {
             $i++;
             $prefix = 'CRITERION.POS_' . sprintf('%02d', $i);
             $params[$prefix . '.POSITION'] = $i;
             $params[$prefix . '.QUANTITY'] = (int) $item->quantity;
             if (empty($item->product_unit)) {
                 $item->product_unit = 'Stk.';
             }
             $params[$prefix . '.UNIT'] = $item->product_unit;
             #price in cents
             $params[$prefix . '.AMOUNT_UNIT_GROSS'] = $prices[$key]['basePriceWithTax'] * 100;
             $params[$prefix . '.AMOUNT_GROSS'] = $prices[$key]['subtotal_with_tax'] * 100;
             $item->product_name = preg_replace('/%/', 'Proz.', $item->product_name);
             $item->product_name = preg_replace('/("|\'|!|$|=)/', ' ', $item->product_name);
             $params[$prefix . '.TEXT'] = strlen($item->product_name) > 100 ? substr($item->product_name, 0, 90) . '...' : $item->product_name;
             $params[$prefix . '.ARTICLE_NUMBER'] = $item->product_sku;
             $params[$prefix . '.PERCENT_VAT'] = sprintf('%1.2f', $prices[$key]['VatTax'][$item->product_tax_id]['1']);
             $params[$prefix . '.ARTICLE_TYPE'] = 'goods';
         }
         //	SHIPPING
         require VMPATH_ADMIN . DS . 'models' . DS . 'shipmentmethod.php';
         $vmms = new VirtueMartModelShipmentmethod();
         $shipmentInfo = $vmms->getShipments();
         foreach ($shipmentInfo as $skey => $svalue) {
             if ($svalue->virtuemart_shipmentmethod_id == $cart->virtuemart_shipmentmethod_id) {
                 $shipmentData = array();
                 foreach (explode("|", $svalue->shipment_params) as $line) {
                     list($key, $value) = explode('=', $line, 2);
                     $shipmentData[$key] = str_replace('"', '', $value);
                 }
                 $shipmentTaxId = $shipmentData['tax_id'];
                 $shipmentTax = sprintf('%1.2f', $cart->cartData['VatTax'][$shipmentTaxId]['calc_value']);
             }
         }
         $i++;
         $prefix = 'CRITERION.POS_' . sprintf('%02d', $i);
         $params[$prefix . '.POSITION'] = $i;
         $params[$prefix . '.QUANTITY'] = '1';
         $params[$prefix . '.UNIT'] = 'Stk.';
         $params[$prefix . '.AMOUNT_UNIT_GROSS'] = $prices['salesPriceShipment'] * 100;
         $params[$prefix . '.AMOUNT_GROSS'] = $prices['salesPriceShipment'] * 100;
         $params[$prefix . '.TEXT'] = 'Shipping';
         $params[$prefix . '.ARTICLE_NUMBER'] = 'Shipping';
         $params[$prefix . '.PERCENT_VAT'] = $shipmentTax;
         $params[$prefix . '.ARTICLE_TYPE'] = 'shipment';
         //	COUPON
         if (isset($prices['couponValue']) && $prices['couponValue'] != '') {
             $i++;
             $prefix = 'CRITERION.POS_' . sprintf('%02d', $i);
             $params[$prefix . '.POSITION'] = $i;
             $params[$prefix . '.QUANTITY'] = '1';
             $params[$prefix . '.UNIT'] = 'Stk.';
             $params[$prefix . '.AMOUNT_UNIT_GROSS'] = $prices['couponValue'] * 100;
             $params[$prefix . '.AMOUNT_GROSS'] = $prices['couponValue'] * 100;
             $params[$prefix . '.TEXT'] = 'Coupon';
             $params[$prefix . '.ARTICLE_NUMBER'] = 'Coupon';
             $params[$prefix . '.PERCENT_VAT'] = $prices['couponTax'];
             $params[$prefix . '.ARTICLE_TYPE'] = 'voucher';
         }
     }
     return $params;
 }
 /**
  * @param $method
  * @param $order
  * @return string
  */
 function _getPaymentResponseHtml($method, $order, $payments)
 {
     VmConfig::loadJLang('com_virtuemart_orders', TRUE);
     if (!class_exists('CurrencyDisplay')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php';
     }
     if (!class_exists('VirtueMartCart')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     VmConfig::loadJLang('com_virtuemart_orders', TRUE);
     $totalInPaymentCurrency = vmPSPlugin::getAmountInCurrency($order['details']['BT']->order_total, $order['details']['BT']->order_currency);
     $cart = VirtueMartCart::getCart();
     $currencyDisplay = CurrencyDisplay::getInstance($cart->pricesCurrency);
     $payment = end($payments);
     $pluginName = $this->renderPluginName($method, $where = 'post_payment');
     $html = $this->renderByLayout('post_payment', array('order' => $order, 'paymentInfos' => $payment, 'pluginName' => $pluginName, 'displayTotalInPaymentCurrency' => $totalInPaymentCurrency['display']));
     //vmdebug('_getPaymentResponseHtml', $html,$pluginName,$paypalTable );
     return $html;
 }
 /**
  * Executes the confirmDone task,
  * cart object checks itself, if the data is valid
  *
  * @author Max Milbers
  *
  *
  */
 public function confirm()
 {
     //Use false to prevent valid boolean to get deleted
     $cart = VirtueMartCart::getCart();
     if ($cart) {
         $cart->confirmDone();
         $view = $this->getView('cart', 'html');
         $view->setLayout('order_done');
         // Display it all
         $view->display();
     } else {
         $mainframe = JFactory::getApplication();
         $mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart'), JText::_('COM_VIRTUEMART_CART_DATA_NOT_VALID'));
     }
 }
Exemple #16
0
 public function display($tpl = null)
 {
     $mainframe = JFactory::getApplication();
     $pathway = $mainframe->getPathway();
     $document = JFactory::getDocument();
     $layoutName = $this->getLayout();
     if (!$layoutName) {
         $layoutName = JRequest::getWord('layout', 'default');
     }
     $this->assignRef('layoutName', $layoutName);
     $format = JRequest::getWord('format');
     if (!class_exists('VirtueMartCart')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     $cart = VirtueMartCart::getCart();
     $this->assignRef('cart', $cart);
     //Why is this here, when we have view.raw.php
     if ($format == 'raw') {
         $cart->prepareCartViewData();
         JRequest::setVar('layout', 'mini_cart');
         $this->setLayout('mini_cart');
         $this->prepareContinueLink();
     }
     /*
     	  if($layoutName=='edit_coupon'){
     
     		$cart->prepareCartViewData();
     		$this->lSelectCoupon();
     		$pathway->addItem(JText::_('COM_VIRTUEMART_CART_OVERVIEW'),JRoute::_('index.php?option=com_virtuemart&view=cart'));
     		$pathway->addItem(JText::_('COM_VIRTUEMART_CART_SELECTCOUPON'));
     		$document->setTitle(JText::_('COM_VIRTUEMART_CART_SELECTCOUPON'));
     
     		} else */
     if ($layoutName == 'select_shipment') {
         if (!class_exists('vmPSPlugin')) {
             require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php';
         }
         JPluginHelper::importPlugin('vmshipment');
         $this->lSelectShipment();
         $pathway->addItem(JText::_('COM_VIRTUEMART_CART_OVERVIEW'), JRoute::_('index.php?option=com_virtuemart&view=cart'));
         $pathway->addItem(JText::_('COM_VIRTUEMART_CART_SELECTSHIPMENT'));
         $document->setTitle(JText::_('COM_VIRTUEMART_CART_SELECTSHIPMENT'));
     } else {
         if ($layoutName == 'select_payment') {
             /* Load the cart helper */
             //			$cartModel = VmModel::getModel('cart');
             $this->lSelectPayment();
             $pathway->addItem(JText::_('COM_VIRTUEMART_CART_OVERVIEW'), JRoute::_('index.php?option=com_virtuemart&view=cart'));
             $pathway->addItem(JText::_('COM_VIRTUEMART_CART_SELECTPAYMENT'));
             $document->setTitle(JText::_('COM_VIRTUEMART_CART_SELECTPAYMENT'));
         } else {
             if ($layoutName == 'order_done') {
                 $this->lOrderDone();
                 $pathway->addItem(JText::_('COM_VIRTUEMART_CART_THANKYOU'));
                 $document->setTitle(JText::_('COM_VIRTUEMART_CART_THANKYOU'));
             } else {
                 if ($layoutName == 'default') {
                     $cart->prepareCartViewData();
                     $cart->prepareAddressRadioSelection();
                     $this->prepareContinueLink();
                     $this->lSelectCoupon();
                     $currencyDisplay = CurrencyDisplay::getInstance($this->cart->pricesCurrency);
                     $this->assignRef('currencyDisplay', $currencyDisplay);
                     $totalInPaymentCurrency = $this->getTotalInPaymentCurrency();
                     $checkoutAdvertise = $this->getCheckoutAdvertise();
                     if ($cart && !VmConfig::get('use_as_catalog', 0)) {
                         $cart->checkout(false);
                     }
                     if ($cart->getDataValidated()) {
                         $pathway->addItem(JText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU'));
                         $document->setTitle(JText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU'));
                         $text = JText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU');
                         $checkout_task = 'confirm';
                     } else {
                         $pathway->addItem(JText::_('COM_VIRTUEMART_CART_OVERVIEW'));
                         $document->setTitle(JText::_('COM_VIRTUEMART_CART_OVERVIEW'));
                         $text = JText::_('COM_VIRTUEMART_CHECKOUT_TITLE');
                         $checkout_task = 'checkout';
                     }
                     $this->assignRef('checkout_task', $checkout_task);
                     $this->checkPaymentMethodsConfigured();
                     $this->checkShipmentMethodsConfigured();
                     if ($cart->virtuemart_shipmentmethod_id) {
                         $shippingText = JText::_('COM_VIRTUEMART_CART_CHANGE_SHIPPING');
                     } else {
                         $shippingText = JText::_('COM_VIRTUEMART_CART_EDIT_SHIPPING');
                     }
                     $this->assignRef('select_shipment_text', $shippingText);
                     if ($cart->virtuemart_paymentmethod_id) {
                         $paymentText = JText::_('COM_VIRTUEMART_CART_CHANGE_PAYMENT');
                     } else {
                         $paymentText = JText::_('COM_VIRTUEMART_CART_EDIT_PAYMENT');
                     }
                     $this->assignRef('select_payment_text', $paymentText);
                     if (!VmConfig::get('use_as_catalog')) {
                         $checkout_link_html = '<a class="vm-button-correct" href="javascript:document.checkoutForm.submit();" ><span>' . $text . '</span></a>';
                     } else {
                         $checkout_link_html = '';
                     }
                     $this->assignRef('checkout_link_html', $checkout_link_html);
                 }
             }
         }
     }
     //dump ($cart,'cart');
     $useSSL = VmConfig::get('useSSL', 0);
     $useXHTML = true;
     $this->assignRef('useSSL', $useSSL);
     $this->assignRef('useXHTML', $useXHTML);
     $this->assignRef('totalInPaymentCurrency', $totalInPaymentCurrency);
     $this->assignRef('checkoutAdvertise', $checkoutAdvertise);
     // @max: quicknirty
     $cart->setCartIntoSession();
     shopFunctionsF::setVmTemplate($this, 0, 0, $layoutName);
     // 		vmdebug('my cart ',$cart);
     parent::display($tpl);
 }
Exemple #17
0
 function plgVmOnPaymentResponseReceived(&$html)
 {
     if (!class_exists('VirtueMartCart')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     if (!class_exists('shopFunctionsF')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
     }
     if (!class_exists('VirtueMartModelOrders')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php';
     }
     $virtuemart_paymentmethod_id = JRequest::getInt('pm', 0);
     $order_number = JRequest::getString('on', 0);
     if (!($method = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) {
         return null;
     }
     if (!$this->selectedThisElement($method->payment_element)) {
         return null;
     }
     if (!($virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($order_number))) {
         return null;
     }
     if (!($paymentTable = $this->getDataByOrderId($virtuemart_order_id))) {
         return '';
     }
     $payment_name = $this->renderPluginName($method);
     $html = $this->_getPaymentResponseHtml($paymentTable, $payment_name);
     $cart = VirtueMartCart::getCart();
     $cart->emptyCart();
     return true;
 }
Exemple #18
0
 function getKlarnaPaymentCurrency(&$method)
 {
     if (!class_exists('VirtueMartCart')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     $cart = VirtueMartCart::getCart();
     $this->_getCartAddressCountryCode($cart, $country, $countrId);
     $cData = KlarnaHandler::countryData($method, $country);
     return shopFunctions::getCurrencyIDByName($cData['currency_code']);
 }
 /**
  * Get the cart from the session
  *
  * @author Max Milbers
  * @access public
  * @param array $cart the cart to store in the session
  */
 public static function getCart($setCart = true, $options = array())
 {
     if (empty(self::$_cart)) {
         $session = JFactory::getSession($options);
         $cartSession = $session->get('vmcart', 0, 'vm');
         self::$_cart = new VirtueMartCart();
         if (!empty($cartSession)) {
             $sessionCart = unserialize($cartSession);
             foreach (self::$sessionKeys as $k) {
                 self::$_cart->{$k} = $sessionCart->{$k};
             }
             self::$_cart->customer_comment = base64_decode($sessionCart->customer_comment);
         }
     }
     if ($setCart == true) {
         self::$_cart->setPreferred();
         self::$_cart->setCartIntoSession();
     }
     return self::$_cart;
 }
Exemple #20
0
 protected function setCountryState($cart = 0)
 {
     if ($this->_app->isAdmin()) {
         return;
     }
     if (empty($cart)) {
         if (!class_exists('VirtueMartCart')) {
             require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
         }
         $cart = VirtueMartCart::getCart();
     }
     $this->_cart = $cart;
     $stBased = VmConfig::get('taxSTbased', TRUE);
     if ($stBased and !empty($this->_cart->ST['virtuemart_country_id'])) {
         $this->_deliveryCountry = (int) $this->_cart->ST['virtuemart_country_id'];
     } else {
         if (!empty($this->_cart->BT['virtuemart_country_id'])) {
             $this->_deliveryCountry = (int) $this->_cart->BT['virtuemart_country_id'];
         }
     }
     if ($stBased and !empty($this->_cart->ST['virtuemart_state_id'])) {
         $this->_deliveryState = (int) $this->_cart->ST['virtuemart_state_id'];
     } else {
         if (!empty($cart->BT['virtuemart_state_id'])) {
             $this->_deliveryState = (int) $this->_cart->BT['virtuemart_state_id'];
         }
     }
     //vmdebug('setCountryState state '.$this->_deliveryState,$this->_cart->BT);
 }
Exemple #21
0
 /**
  *
  * @author Max Milbers
  * @param bool  $setCart: set the Cart into Session
  * @param array $options : options for getSession
  * @param null  $cartData: if not empty, do no get the cart data from session
  * @return null|VirtueMartCart
  */
 public static function getCart($setCart = true, $options = array())
 {
     //What does this here? for json stuff?
     if (!class_exists('JTable')) {
         require JPATH_VM_LIBRARIES . DS . 'joomla' . DS . 'database' . DS . 'table.php';
     }
     // 		JTable::addIncludePath(JPATH_VM_ADMINISTRATOR . DS . 'tables');
     if (empty(self::$_cart)) {
         $session = JFactory::getSession($options);
         $cartSession = $session->get('vmcart', 0, 'vm');
         if (!empty($cartSession)) {
             $sessionCart = unserialize($cartSession);
             self::$_cart = new VirtueMartCart();
             self::$_cart->products = $sessionCart->products;
             self::$_cart->vendorId = $sessionCart->vendorId;
             self::$_cart->lastVisitedCategoryId = $sessionCart->lastVisitedCategoryId;
             self::$_cart->virtuemart_shipmentmethod_id = $sessionCart->virtuemart_shipmentmethod_id;
             self::$_cart->virtuemart_paymentmethod_id = $sessionCart->virtuemart_paymentmethod_id;
             self::$_cart->automaticSelectedShipment = $sessionCart->automaticSelectedShipment;
             self::$_cart->automaticSelectedPayment = $sessionCart->automaticSelectedPayment;
             self::$_cart->BT = $sessionCart->BT;
             self::$_cart->ST = $sessionCart->ST;
             self::$_cart->tosAccepted = $sessionCart->tosAccepted;
             self::$_cart->customer_comment = base64_decode($sessionCart->customer_comment);
             self::$_cart->couponCode = $sessionCart->couponCode;
             self::$_cart->_triesValidateCoupon = $sessionCart->_triesValidateCoupon;
             self::$_cart->order_language = $sessionCart->order_language;
             self::$_cart->cartData = $sessionCart->cartData;
             self::$_cart->order_number = $sessionCart->order_number;
             self::$_cart->lists = $sessionCart->lists;
             //self::$_cart->pricesUnformatted					= $sessionCart->pricesUnformatted;
             self::$_cart->pricesCurrency = $sessionCart->pricesCurrency;
             self::$_cart->paymentCurrency = $sessionCart->paymentCurrency;
             self::$_cart->_inCheckOut = $sessionCart->_inCheckOut;
             self::$_cart->_dataValidated = $sessionCart->_dataValidated;
             self::$_cart->_confirmDone = $sessionCart->_confirmDone;
             self::$_cart->STsameAsBT = $sessionCart->STsameAsBT;
             self::$_cart->customer_number = $sessionCart->customer_number;
         }
     }
     if (empty(self::$_cart)) {
         self::$_cart = new VirtueMartCart();
     }
     if ($setCart == true) {
         self::$_cart->setPreferred();
         self::$_cart->setCartIntoSession();
     }
     return self::$_cart;
 }
 public static function getRegistrationHhtml(&$obj, &$OPCloader)
 {
     // if (!empty($no_login_in_template)) return "";
     include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
     if (!class_exists('VirtueMartCart')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     if (!empty($obj->cart)) {
         $cart =& $obj->cart;
     } else {
         $cart = VirtueMartCart::getCart();
     }
     $type = 'BT';
     // for unlogged
     $virtuemart_userinfo_id = 0;
     $new = 1;
     $fieldtype = $type . 'address';
     /*
     if (method_exists($cart, 'prepareAddressDataInCart'))
     $cart->prepareAddressDataInCart($type, $new);
     */
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'userfields.php';
     OPCUserFields::populateCart($cart, $type, true);
     /*
     if (method_exists($cart, 'prepareAddressFieldsInCart'))
     $cart->prepareAddressFieldsInCart();
     */
     OPCloader::setRegType();
     if (!class_exists('VirtuemartModelUserfields')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'userfields.php';
     }
     $corefields = VirtueMartModelUserfields::getCoreFields();
     $userFields = $cart->{$fieldtype};
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
     $layout = 'default';
     foreach ($userFields['fields'] as $key => $uf) {
         if (!in_array($key, $corefields) || $key == 'agreed') {
             unset($userFields['fields'][$key]);
             continue;
         }
         if (!empty($opc_email_in_bt) || $OPCloader->isNoLogin() || $OPCloader->isNoLogin()) {
             if ($userFields['fields'][$key]['name'] == 'email') {
                 unset($userFields['fields'][$key]);
                 continue;
             }
         }
         if ($key == 'email') {
             $user = JFactory::getUser();
             $uid = $user->get('id');
             // user is logged, but does not have a VM account
             if (!OPCloader::logged($cart) && !empty($uid)) {
                 // the user is logged in only in joomla, but does not have an account with virtuemart
                 $userFields['fields'][$key]['formcode'] = str_replace('/>', ' readonly="readonly" />', $userFields['fields'][$key]['formcode']);
             }
         }
     }
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'userfields.php';
     OPCUserFields::getUserFields($userFields, $OPCloader, $cart);
     // lets move email to the top
     $copy = array();
     // we will reorder the fields, so the email is first when used as username
     $u = OPCLang::_('COM_VIRTUEMART_REGISTER_UNAME');
     //$e = OPCLang::_('COM_VIRTUEMART_USER_FORM_EMAIL');
     // disable when used for logged in
     if (!empty($userFields['fields'])) {
         /*
              if (empty($opc_email_in_bt) && (!empty($double_email)))
         {
           // email is in BT, let's check for double mail
         		
         		$email2 = $userFields['fields']['email'];
         		$email2['name'] = 'email2'; 
         		$title = OPCLang::_('COM_ONEPAGE_EMAIL2'); 
         		if ($title != 'COM_ONEPAGE_EMAIL2')
         		$email2['title'] = $title;
         		$email2['formcode'] = str_replace('"email', '"email2', $email2['formcode']); 
         		$email2['formcode'] = str_replace('id=', ' onblur="javascript: doublemail_checkMail();" id=', $email2['formcode']);
         		
         		$h = '<span style="display: none; position: relative; color: red; font-size: 10px; background: none; border: none; padding: 0; margin: 0;" id="email2_info" class="email2_class">';
         		$emailerr = OPCLang::_('COM_ONEPAGE_EMAIL_DONT_MATCH');
         		if ($emailerr != 'COM_ONEPAGE_EMAIL_DONT_MATCH')
         		$h .= $emailerr;
         		else $h .= "Emails don't match!";
         		$h .= '</span>';
         		$email2['formcode'] .= $h;
         }
         */
         /*
         	 if (!empty($opc_check_username))
         	 if ((!OPCloader::logged($cart)) && (empty($uid)))
         	 if (!empty($userFields['fields']['username']))
         {
          
            $un = $userFields['fields']['username']['formcode']; 
         		 $un = str_replace('id=', ' onblur="javascript: Onepage.username_check(this);" id=', $un);
         		 $un .=  '<span class="username_already_exist" style="display: none; position: relative; color: red; font-size: 10px; background: none; border: none; padding: 0; margin: 0;" id="username_already_exists">';
         		 $un .= OPCLang::sprintf('COM_VIRTUEMART_STRING_ERROR_NOT_UNIQUE_NAME', $u); 
         		 $un .= '</span>'; 
         		 $userFields['fields']['username']['formcode'] = $un; 
         }
         */
         /*
         if (!empty($opc_check_email))
         if ((!OPCloader::logged($cart)) && (empty($uid)))
         if (!empty($userFields['fields']['email']))
         {
         
            $un = $userFields['fields']['email']['formcode']; 
         		 $un = str_replace('id=', ' onblur="javascript: Onepage.email_check(this);" id=', $un);
         		 $un .=  '<span class="email_already_exist" style="display: none; position: relative; color: red; font-size: 10px; background: none; border: none; padding: 0; margin: 0;" id="email_already_exists">';
         		 $un .= OPCLang::sprintf('COM_ONEPAGE_EMAIL_ALREADY_EXISTS', OPCLang::_('COM_VIRTUEMART_USER_FORM_EMAIL')); 
         		 $un .= '</span>'; 
         		 $userFields['fields']['email']['formcode'] = $un; 
         }
         */
     }
     /*
     	$OPCloader->reorderFields($userFields); 
     */
     if (count($userFields['fields']) === 0) {
         // no fields found
         return '';
     }
     //if (empty($opc_email_in_bt) && (!empty($double_email)))
     //$OPCloader->insertAfter($userFields['fields'], 'email', $email2, 'email2');
     $vars = array('rowFields' => $userFields, 'cart' => $obj, 'is_registration' => true);
     $html = $OPCloader->fetch($OPCloader, 'list_user_fields.tpl', $vars);
     $html = str_replace("'password'", "'opc_password'", $html);
     $html = str_replace("password2", "opc_password2", $html);
     if (strpos($html, 'email_field') !== false) {
         $html .= '<input type="hidden" name="email_in_registration" value="1" id="email_in_registration" />';
     } else {
         $html .= '<input type="hidden" name="email_in_registration" value="0" id="email_in_registration" />';
     }
     return $html;
 }
Exemple #23
0
 /**
  * This function just gets the post data and put the data if there is any to the cart
  *
  * @author Max Milbers
  */
 private function saveToCart($data)
 {
     if (!class_exists('VirtueMartCart')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     $cart = VirtueMartCart::getCart();
     $cart->saveAddressInCart($data, $data['address_type']);
 }
    jQuery("body").live("updateVirtueMartCartModule", function(e) {
        jQuery("#vmCartModule").updateVirtueMartCartModule();
    });
});
';
vmJsApi::addJScript('vm.CartModule.UpdateModule',$js);

$jsVars  = ' jQuery(document).ready(function(){
	jQuery(".vmCartModule").productUpdate();
});' ;
//vmJsApi::addJScript('vm.CartModule.UpdateProduct',$jsVars);


//This is strange we have the whole thing again in controllers/cart.php public function viewJS()
if(!class_exists('VirtueMartCart')) require(VMPATH_SITE.DS.'helpers'.DS.'cart.php');
$cart = VirtueMartCart::getCart(false);

$viewName = vRequest::getString('view',0);
if($viewName=='cart'){
	$checkAutomaticPS = true;
} else {
	$checkAutomaticPS = false;
}
$data = $cart->prepareAjaxData($checkAutomaticPS);

if (!class_exists('CurrencyDisplay')) require(VMPATH_ADMIN . DS. 'helpers' . DS . 'currencydisplay.php');
$currencyDisplay = CurrencyDisplay::getInstance( );

vmJsApi::cssSite();

$moduleclass_sfx = $params->get('moduleclass_sfx', '');
Exemple #25
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $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');
     $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';
     }
     $this->cart = VirtueMartCart::getCart();
     $this->cart->prepareVendor();
     //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') {
         $this->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') {
             $this->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, $this->cart->cartfields);
                 if (!class_exists('CurrencyDisplay')) {
                     require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php';
                 }
                 $currencyDisplay = CurrencyDisplay::getInstance($this->cart->pricesCurrency);
                 $this->assignRef('currencyDisplay', $currencyDisplay);
                 $customfieldsModel = VmModel::getModel('Customfields');
                 $this->assignRef('customfieldsModel', $customfieldsModel);
                 $this->lSelectCoupon();
                 $totalInPaymentCurrency = $this->getTotalInPaymentCurrency();
                 $checkoutAdvertise = $this->getCheckoutAdvertise();
                 if ($this->cart->getDataValidated()) {
                     if ($this->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 (VmConfig::get('oncheckout_opc', 1)) {
                     if (!class_exists('vmPSPlugin')) {
                         require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php';
                     }
                     JPluginHelper::importPlugin('vmshipment');
                     JPluginHelper::importPlugin('vmpayment');
                     $this->lSelectShipment();
                     $this->lSelectPayment();
                 } else {
                     $this->checkPaymentMethodsConfigured();
                     $this->checkShipmentMethodsConfigured();
                 }
                 if ($this->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 ($this->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);
                 $this->cart->prepareAddressFieldsInCart();
                 $layoutName = $this->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);
     shopFunctionsF::setVmTemplate($this, 0, 0, $layoutName);
     //We never want that the cart is indexed
     $document->setMetaData('robots', 'NOINDEX, NOFOLLOW, NOARCHIVE, NOSNIPPET');
     if ($this->cart->_inConfirm) {
         vmInfo('COM_VIRTUEMART_IN_CONFIRM');
     }
     if ($this->cart->layoutPath) {
         $this->addTemplatePath($this->cart->layoutPath);
     }
     $current = JFactory::getUser();
     $this->allowChangeShopper = 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 {
             $adminID = JFactory::getSession()->get('vmAdminID', false);
             if ($adminID) {
                 $adminIdUser = JFactory::getUser($adminID);
                 if ($adminIdUser->authorise('core.admin', 'com_virtuemart') or $adminIdUser->authorise('vm.user', 'com_virtuemart')) {
                     $this->allowChangeShopper = true;
                 }
             }
         }
     }
     parent::display($tpl);
 }
Exemple #26
0
 /**
  * Check the Joomla ReCaptcha Plg
  *
  * @author Maik Künnemann
  */
 function checkCaptcha($retUrl)
 {
     if (JFactory::getUser()->guest == 1 and VmConfig::get('reg_captcha')) {
         $recaptcha = vRequest::getVar('recaptcha_response_field');
         JPluginHelper::importPlugin('captcha');
         $dispatcher = JDispatcher::getInstance();
         $res = $dispatcher->trigger('onCheckAnswer', $recaptcha);
         if (!$res[0]) {
             $data = vRequest::getPost();
             $data['address_type'] = vRequest::getVar('addrtype', 'BT');
             if (!class_exists('VirtueMartCart')) {
                 require VMPATH_SITE . DS . 'helpers' . DS . 'cart.php';
             }
             $cart = VirtueMartCart::getCart();
             $prefix = '';
             if ($data['address_type'] == 'STaddress' || $data['address_type'] == 'ST') {
                 $prefix = 'shipto_';
             }
             $cart->saveAddressInCart($data, $data['address_type'], true, $prefix);
             $errmsg = vmText::_('PLG_RECAPTCHA_ERROR_INCORRECT_CAPTCHA_SOL');
             $this->setRedirect(JRoute::_($retUrl . '&captcha=1', FALSE), $errmsg);
             return FALSE;
         } else {
             return TRUE;
         }
     } else {
         return TRUE;
     }
 }
Exemple #27
0
 /**
  *
  * @author Max Milbers
  */
 function getUserInfoInUserFields($layoutName, $type, $uid, $cart = true, $isVendor = false)
 {
     // 		if(!class_exists('VirtueMartModelUserfields')) require(JPATH_VM_ADMINISTRATOR.DS.'models'.DS.'userfields.php' );
     // 		$userFieldsModel = new VirtuemartModelUserfields();
     $userFieldsModel = VmModel::getModel('userfields');
     $prepareUserFields = $userFieldsModel->getUserFieldsFor($layoutName, $type);
     if ($type == 'ST') {
         $preFix = 'shipto_';
     } else {
         $preFix = '';
     }
     /*
      * JUser  or $this->_id is the logged user
      */
     if (!empty($this->_data->JUser)) {
         $JUser = $this->_data->JUser;
     } else {
         $JUser = JUser::getInstance($this->_id);
     }
     $data = null;
     $userFields = array();
     if (!empty($uid)) {
         $dataT = $this->getTable('userinfos');
         $data = $dataT->load($uid);
         if ($data->virtuemart_user_id !== 0 and !$isVendor) {
             $user = JFactory::getUser();
             if (!($user->authorise('core.admin', 'com_virtuemart') or $user->authorise('core.manage', 'com_virtuemart'))) {
                 if ($data->virtuemart_user_id != $this->_id) {
                     vmError('Hacking attempt loading userinfo, you got logged');
                     echo 'Hacking attempt loading userinfo, you got logged';
                     return false;
                 }
             }
         }
         if ($data->address_type != 'ST') {
             $BTuid = $uid;
             $data->name = $JUser->name;
             $data->email = $JUser->email;
             $data->username = $JUser->username;
             $data->address_type = 'BT';
         }
         vmdebug('getUserInfoInUserFields !$uid', $data->name);
     } else {
         vmdebug('getUserInfoInUserFields case empty $uid');
         //New Address is filled here with the data of the cart (we are in the userview)
         if ($cart) {
             if (!class_exists('VirtueMartCart')) {
                 require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
             }
             $cart = VirtueMartCart::getCart();
             $adType = $type . 'address';
             if (empty($cart->{$adType})) {
                 $data = $cart->{$type};
                 if (empty($data)) {
                     $data = array();
                 }
                 if ($JUser) {
                     if (empty($data['name'])) {
                         $data['name'] = $JUser->name;
                     }
                     if (empty($data['email'])) {
                         $data['email'] = $JUser->email;
                     }
                     if (empty($data['username'])) {
                         $data['username'] = $JUser->username;
                     }
                     if (empty($data['virtuemart_user_id'])) {
                         $data['virtuemart_user_id'] = $JUser->id;
                     }
                 }
                 $data = (object) $data;
             }
         } else {
             if ($JUser) {
                 if (empty($data['name'])) {
                     $data['name'] = $JUser->name;
                 }
                 if (empty($data['email'])) {
                     $data['email'] = $JUser->email;
                 }
                 if (empty($data['username'])) {
                     $data['username'] = $JUser->username;
                 }
                 if (empty($data['virtuemart_user_id'])) {
                     $data['virtuemart_user_id'] = $JUser->id;
                 }
                 $data = (object) $data;
             }
         }
     }
     if (empty($data)) {
         vmdebug('getUserInfoInUserFields $data empty', $uid, $data);
         $cart = VirtueMartCart::getCart();
         $data = $cart->BT;
     }
     $userFields[$uid] = $userFieldsModel->getUserFieldsFilled($prepareUserFields, $data, $preFix);
     return $userFields;
 }
Exemple #28
0
 /** Create empty order head record from admin only
  *
  * @author Ondřej Spilka
  * @return ID of the newly created order
  */
 public function CreateOrderHead()
 {
     // TODO
     // multivendor
     //usrid
     $usrid = 0;
     $_orderData = new stdClass();
     $_orderData->virtuemart_order_id = null;
     $_orderData->virtuemart_user_id = 0;
     $_orderData->virtuemart_vendor_id = 1;
     //TODO
     $_orderData->order_total = 0;
     $_orderData->order_salesPrice = 0;
     $_orderData->order_billTaxAmount = 0;
     $_orderData->order_billDiscountAmount = 0;
     $_orderData->order_discountAmount = 0;
     $_orderData->order_subtotal = 0;
     $_orderData->order_tax = 0;
     $_orderData->order_shipment = 0;
     $_orderData->order_shipment_tax = 0;
     $_orderData->order_payment = 0;
     $_orderData->order_payment_tax = 0;
     $_orderData->order_discount = 0;
     $_orderData->order_status = 'P';
     $_orderData->order_currency = $this->getVendorCurrencyId($_orderData->virtuemart_vendor_id);
     $_orderData->virtuemart_paymentmethod_id = JRequest::getInt('virtuemart_paymentmethod_id');
     $_orderData->virtuemart_shipmentmethod_id = JRequest::getInt('virtuemart_shipmentmethod_id');
     $_orderData->customer_note = '';
     $_orderData->ip_address = $_SERVER['REMOTE_ADDR'];
     $_orderData->order_number = '';
     JPluginHelper::importPlugin('vmshopper');
     $dispatcher = JDispatcher::getInstance();
     $_orderData->order_number = $this->generateOrderNumber($usrid, 4, $_orderData->virtuemart_vendor_id);
     $_orderData->order_pass = '******' . substr(md5((string) time() . rand(1, 1000) . $_orderData->order_number), 0, 5);
     $orderTable = $this->getTable('orders');
     $orderTable->bindChecknStore($_orderData);
     $errors = $orderTable->getErrors();
     foreach ($errors as $error) {
         vmError($error);
     }
     $db = JFactory::getDBO();
     $_orderID = $db->insertid();
     $_usr = JFactory::getUser();
     if (!$this->_writeUserInfo($_orderID, $_usr, array())) {
         vmError($error);
     }
     $orderModel = VmModel::getModel('orders');
     $order = $orderModel->getOrder($_orderID);
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('vmcustom');
     JPluginHelper::importPlugin('vmshipment');
     JPluginHelper::importPlugin('vmpayment');
     if (!class_exists('VirtueMartCart')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     $cart = VirtueMartCart::getCart();
     $returnValues = $dispatcher->trigger('plgVmConfirmedOrder', array($cart, $order));
     return $_orderID;
 }
 private function handle3DSRequest()
 {
     $realexInterface = $this->initRealexInterface(false);
     $cart = VirtueMartCart::getCart();
     $realexInterface->setCart($cart, false);
     $saved_cc_selected = $this->customerData->getVar('saved_cc_selected');
     $realvault = false;
     if ($saved_cc_selected > 0) {
         $realvault = $realexInterface->getStoredCCsData($saved_cc_selected);
         $realvault->cc_cvv_realvault = $this->customerData->getVar('cc_cvv_realvault');
         $this->customerData->saveCustomerRealVaultData((array) $realvault);
     }
     if (!($payments = $this->getDatasByOrderId($realexInterface->order['details']['BT']->virtuemart_order_id))) {
         $this->redirectToCart();
         return FALSE;
     }
     $dcc_payment = $realexInterface->getTransactionData($payments, array($realexInterface::REQUEST_TYPE_DCCRATE, $realexInterface::REQUEST_TYPE_REALVAULT_DCCRATE));
     if ($dcc_payment) {
         $xml_dcc_payment = simplexml_load_string($dcc_payment->realex_hpp_api_fullresponse);
     } else {
         $xml_dcc_payment = NULL;
     }
     $response3DSVerifysig = $realexInterface->request3DSVerifysig($realvault);
     $realexInterface->manageResponse3DSVerifysig($response3DSVerifysig);
     $eci = $realexInterface->getEciFrom3DSVerifysig($response3DSVerifysig, $this->_currentMethod->require_liability);
     $xml_response3DSVerifysig = simplexml_load_string($response3DSVerifysig);
     if ($eci !== false) {
         $xml_response3DSVerifysig->threedsecure->eci = $eci;
         if ($realvault) {
             $response = $realexInterface->requestReceiptIn($realvault, $xml_dcc_payment, $xml_response3DSVerifysig);
         } else {
             $response = $realexInterface->requestAuth($xml_dcc_payment, $xml_response3DSVerifysig);
         }
         $realexInterface->manageResponseRequestAuth($response);
         $xml_response = simplexml_load_string($response);
         $success = $realexInterface->isResponseSuccess($xml_response);
     } else {
         $success = false;
     }
     $order_history = array();
     $redirectToCart = false;
     if ($success) {
         $userfield = $realexInterface->handleCardStorage($saved_cc_selected);
         $realexInterface->storeNewPayment($userfield);
         $status = $this->_currentMethod->status_success;
         $amountValue = vmPSPlugin::getAmountInCurrency($realexInterface->order['details']['BT']->order_total, $realexInterface->order['details']['BT']->order_currency);
         $currencyDisplay = CurrencyDisplay::getInstance($realexInterface->cart->pricesCurrency);
         $order_history['comments'] = vmText::sprintf('VMPAYMENT_REALEX_HPP_API_PAYMENT_STATUS_CONFIRMED', $amountValue['display'], $realexInterface->order['details']['BT']->order_number);
         if (isset($xml_response->dccinfo) and isset($xml_response->dccinfo->cardholderrate)) {
             $order_history['comments'] .= "<br />";
             if ($xml_response->dccinfo->cardholderrate != 1.0) {
                 $order_history['comments'] .= vmText::sprintf('VMPAYMENT_REALEX_HPP_API_DCC_PAY_OWN_CURRENCY_CHARGED', $this->getCardHolderAmount($xml_response->dccinfo->merchantamount), $xml_response->dccinfo->merchantcurrency, $this->getCardHolderAmount($xml_response->dccinfo->cardholderamount), $xml_response->dccinfo->cardholdercurrency);
             } else {
                 $order_history['comments'] .= vmText::sprintf('VMPAYMENT_REALEX_HPP_API_DCC_PAY_MERCHANT_CURRENCY', $this->getCardHolderAmount($xml_response->dccinfo->merchantamount), $xml_response->dccinfo->merchantcurrency);
             }
             $order_history['comments'] .= "<br />";
         } else {
         }
     } else {
         $msgToShopper = '';
         $status = $this->_currentMethod->status_canceled;
         if ($realexInterface->isResponseDeclined($xml_response3DSVerifysig)) {
             $order_history['comments'] = vmText::sprintf('VMPAYMENT_REALEX_HPP_API_PAYMENT_DECLINED', $realexInterface->order['details']['BT']->order_number);
             $msgToShopper = $xml_response3DSVerifysig->message;
         } elseif ($realexInterface->isResponseWrongPhrase($xml_response3DSVerifysig)) {
             $order_history['comments'] = vmText::sprintf('VMPAYMENT_REALEX_HPP_API_PAYMENT_STATUS_CANCELLED', $realexInterface->order['details']['BT']->order_number);
             $msgToShopper = $xml_response3DSVerifysig->message;
         } elseif ($realexInterface->isResponseAlreadyProcessed($xml_response3DSVerifysig)) {
             $order_history['comments'] = $xml_response3DSVerifysig->message;
             $msgToShopper = $xml_response3DSVerifysig->message;
             // log this response, but do not change the order status
             $status = $realexInterface->order['details']['BT']->order_status;
             /* } elseif ($xml_response and $realexInterface->isResponseInvalidPaymentDetails($xml_response)) {
             
             					$order_history['comments'] =$xml_response->message;
             					if ($realvault) {
             						$accountURL=JRoute::_('index.php?option=com_virtuemart&view=user&layout=edit');
             						$msgToShopper=vmText::sprintf('VMPAYMENT_REALEX_HPP_API_INVALID_PAYMENT_DETAILS_REALVAULT',$xml_response->message, $accountURL);
             					} else {
             						$msgToShopper=vmText::sprintf('VMPAYMENT_REALEX_HPP_API_INVALID_PAYMENT_DETAILS',$xml_response->message);
             					}
             	*/
         } else {
             $order_history['comments'] = vmText::sprintf('VMPAYMENT_REALEX_HPP_API_PAYMENT_STATUS_CANCELLED', $realexInterface->order['details']['BT']->order_number);
         }
         $redirectToCart = true;
     }
     $order_history['customer_notified'] = true;
     $order_history['order_status'] = $status;
     //	$this->updateOrderStatus($realexInterface->order, $redirectToCart);
     $modelOrder = VmModel::getModel('orders');
     $modelOrder->updateStatusForOneOrder($realexInterface->order['details']['BT']->virtuemart_order_id, $order_history, false);
     /*
     		$payments = $this->getDatasByOrderId($realexInterface->order['details']['BT']->virtuemart_order_id);
     
     		$html = $realexInterface->getResponseHTML($payments);
     		$this->customerData->clear();
     		$cart = VirtueMartCart::getCart();
     		$cart->emptyCart();
     		vRequest::setVar('display_title', false);
     		vRequest::setVar('html', $html);
     		echo $html;
     */
     //$html = $realexInterface->getResponseHTML($payments);
     if ($redirectToCart) {
         $this->redirectToCart($msgToShopper);
     } else {
         $this->customerData->clear();
         $cart = VirtueMartCart::getCart();
         $cart->emptyCart();
         $submit_url = JURI::root() . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&pm=' . $this->_currentMethod->virtuemart_paymentmethod_id . '&on=' . $realexInterface->order['details']['BT']->order_number . '&Itemid=' . vRequest::getInt('Itemid') . '&lang=' . vRequest::getCmd('lang', '');
         $app = JFactory::getApplication();
         $app->redirect(JRoute::_($submit_url));
     }
     return true;
 }
Exemple #30
0
	/**
	 * For Express Checkout
	 * @param $type
	 * @param $name
	 * @param $render
	 * @return bool|null
	 */

	function plgVmOnSelfCallFE($type, $name, &$render) {
		if ($name != $this->_name || $type != 'vmpayment') {
			return FALSE;
		}
		$action = vRequest::getCmd('action');
		$virtuemart_paymentmethod_id = vRequest::getInt('pm');
		//Load the method
		if (!($this->_currentMethod = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) {
			return NULL; // Another method was selected, do nothing
		}
		if (!$this->selectedThisElement($this->_currentMethod->payment_element)) {
			return FALSE;
		}
		if ($action != 'SetExpressCheckout') {
			return false;
		}
		$expressCheckout = vRequest::getVar('SetExpressCheckout', '');

		if($expressCheckout=='done') {
			if (!class_exists('VirtueMartCart')) {
				require(VMPATH_SITE . DS . 'helpers' . DS . 'cart.php');
			}
			$cart = VirtueMartCart::getCart();
			$cart->prepareCartData();
			$cart->virtuemart_paymentmethod_id = $virtuemart_paymentmethod_id;
			$cart->setCartIntoSession();
			//$this->_currentMethod = $currentMethod;
			$paypalInterface = $this->_loadPayPalInterface();
			$paypalInterface->setCart($cart);
			$paypalInterface->setTotal($cart->cartPrices['billTotal']);
			$paypalInterface->loadCustomerData();
			// will perform $this->getExpressCheckoutDetails();
			$paypalInterface->getExtraPluginInfo($this->_currentMethod);

			if (!$paypalInterface->validate()) {
				VmInfo('VMPAYMENT_PAYPAL_PAYMENT_NOT_VALID');
				return false;
			} else {
				$app = JFactory::getApplication();
				$app->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart&Itemid=' . vRequest::getInt('Itemid'), false));
			}
		}	elseif($expressCheckout=='cancel') {
				$this->customerData->clear();
				if (!class_exists('VirtueMartCart')) {
					require(VMPATH_SITE . DS . 'helpers' . DS . 'cart.php');
				}
				$cart = VirtueMartCart::getCart();
				$cart->virtuemart_paymentmethod_id = 0;
				$cart->setCartIntoSession();
				$app = JFactory::getApplication();
				$app->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart&Itemid=' . vRequest::getInt('Itemid'), false), vmText::_('VMPAYMENT_PAYPAL_PAYMENT_CANCELLED'));
		}

	}