News:

Support the VirtueMart project and become a member

Main Menu

How to redirect to Home -> Thank you for your order

Started by ndaumalle, August 04, 2016, 23:44:42 PM

Previous topic - Next topic

ndaumalle

We are writing a payment plugin. After redirecting back from the payment gateway to the shop, we would like the user to be redirected to the page Home->Thank you for your Order! instead of just Home for a successful payment, like the standard payment method...

how can i do that? This is my plgVmOnPaymentResponseReceived function
    function plgVmOnPaymentResponseReceived(&$html) {
        if (!class_exists('VirtueMartCart')) {
            require_once(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php');
        }

        if (!class_exists('shopFunctionsF')) {
            require_once(JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php');
        }
        if (!class_exists('VirtueMartModelOrders')) {
            require_once(VMPATH_ADMIN . DS . 'models' . DS . 'orders.php');
        }

        $jinput = JFactory::getApplication()->input;
        $inputValues = $jinput->getArray(array(
            'option' => 'STRING',
            'view' => 'STRING',
            'task' => 'STRING',
            'session' => 'ALNUM',
            'vmpm' => 'int',
            'vmoid' => 'int',
            'vmuid' => 'int',
            'gcReference' => 'CMD',
            'gcMerchantTxId' => 'RAW',
            'gcBackendTxId' => 'RAW',
            'gcAmount' => 'int',
            'gcCurrency' => 'ALNUM',
            'gcResultPayment' => 'int',
            'gcHash' => 'ALNUM'
        ));



        if (!($method = $this->getVmPluginMethod($inputValues['vmpm']))) {
            return NULL; // Another method was selected, do nothing
        }

        if (!$this->selectedThisElement($method->payment_element)) {
            return NULL;
        }

            //MORE CODE to check if it is a successful transaction

            if ($notify->paymentSuccessful()) {
                $cart = VirtueMartCart::getCart();

                $payment_name = parent::renderPluginName($method);

                $orderModel = VmModel::getModel('orders');
                $order = $orderModel->getOrder($inputValues["vmoid"]);

                if (!class_exists('CurrencyDisplay')) {
                    require(VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php');
                }

                $totalInPaymentCurrency = vmPSPlugin::getAmountInCurrency($order['details']['BT']->order_total,$method->payment_currency);

                $html = $this->renderByLayout('post_payment', array(
                    'order_number' => $order['details']['BT']->order_number,
                    'order_pass' => $order['details']['BT']->order_pass,
                    'payment_name' => $payment_name,
                    'displayTotalInPaymentCurrency' => $totalInPaymentCurrency['display']
                ));
$cart->emptyCart();
                return TRUE;
            } else {

                $html = $notify->getResponseMessage($notify->getResponseParam('gcResultPayment'), GiroCheckout_Utility::getLanguageCode());
                $mainframe = JFactory::getApplication();
                $mainframe->enqueueMessage($html, 'Warning');
                $mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart&task=editpayment'));
            }

        return NULL;
    }

GJC Web Design

but a return TRUE will send you back to the cart - order_done.php template and display the $html

you can over ride and display what u want there
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

ndaumalle

I return True but the user is redirected to the path Home (see attachment img1)
I would like the user to be redirected to Home -> Thank you for your order! (see attachment img2)

GJC Web Design

but what does the url path matter?

that is the order_done.php template and u can alter this is any way you like
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

ndaumalle

So, how can i have the same url? i do the same than the standard payment method but i don't obtain the same path