Hi, I am trying to get the order_number, payment_name and order total in orderdone.php, I have tried several ways, for example doing a
var_dump($this);
// and
VmModel::getModel('orders');
in both cases return null or empty results.
What am I doing wrong or what is the way to go?
I know that $this->html shows us those values, but it shows it formatted with html, I need to access them individually to use them in if() conditions.
I have tested on Joomla 3.9.19, Joomla 3.9.25, Virtuemart 3.8.8 10472, PHP 7.3.21, database 5.7.23
Thanks in advance.
http://forum.virtuemart.net/index.php?topic=79799.0 (http://forum.virtuemart.net/index.php?topic=79799.0)
Payment Plugin uses as well!!
I am testing with the core orderdone.php file, the plugins all work differently, so I would like to know if there is any way to obtain the data I request
Thanks.
The contents displayed in the order confirmation page is controlled by payment plugins. orderdone.php is not always the order confirmation page. For example, if you use PayPal Standard then orderdone.php is used for redirection and order confirmation page is displayed by - components/com_virtuemart/views/pluginresponse/tmpl/default.php
For standard VirtueMart payment plugin the order confirmation contents are displayed using - plugins/vmpayment/standard/standard/tmpl/post_payment.php
for PayPal Standard the order confirmation contents are displayed using - plugins/vmpayment/paypal/paypal/tmpl/stdresponse.php
and so on.. It is different for every payment methods.
Take look at VP Conversion Tracking plugin - https://www.virtueplanet.com/extensions/vp-conversion-tracking It allows you to have common thank you page for all payment methods and you can also access the order details in the thank you page. It also have many other features. Please go through the list of features.
Disclaimer: I am the developer of this plugin.
As Jumbo says
The payment plugin controls the data that is passed to their specific view handling. There is nothing in orderdone for you to "grab" unless you provide it
If you had told me your payment plugins as I asked - I could probably have suggested a method/s
In VM 3.8.8 (J 3.10.5), I can't find a simple and quick way to get the order number or order id as a variable on page orderdone.php.
I have read all the answers above. I understand that we can use own layout in each payment plugin. But this is terribly inconvenient when using several different payment plugins.
I have a simple, at first glance, task - to add an analytics track and transfer order data to the CRM from orderdone page. Back in VM 3.8.4, I could use $this->cart->orderDetails to get all the necessary data. But in VM 3.8.8 there is nothing that would help to get this data on page orderdone.php. There is no order number, no order ID (we are talking about orders without registration and authorization). There is only customer_number, but it is displayed incorrectly on orderdone page in some cases (this is probably a bug related to the fact that seconds of the current time are used to generate this value)
$qdate = date("Ymd_His_");
self::$_cart->customer_number = 'nonreg_'.shopFunctionsF::vmSubstr($firstName,0,2).shopFunctionsF::vmSubstr($lastName,0,2).shopFunctionsF::vmSubstr($email,0,2).$qdate;
Please tell me the easiest way to get at least some clue on orderdone page that will point to the current order.
Temporary solution in virtuemart 3.8.8 on the link
http://forum.virtuemart.net/index.php?topic=146256.msg520780#msg520780
Quote from: Sandruk1 on February 08, 2022, 21:01:47 PM
Temporary solution in virtuemart 3.8.8 on the link
http://forum.virtuemart.net/index.php?topic=146256.msg520780#msg520780
QuoteIn Virtuemart 3.8.8 it doesn't work
we can see orderDetails: '0'
if I comment string 1843 in helpers/cart.php
//$cart = VirtueMartCart::getCart(true);
then everything works again, and you can see orderDetails in page orderdone.
Big thanks, Sandruk1!
But it confuses me that this is a hack. I see that the topic on the link is almost a year old, but the question has remained open: how to get a single code execution point after order confirmation, including the data of this order, regardless of payment plugins?
[removed misplaced cut/paste data]
I once had a similar task where I needed to email CSV order data. I used a quite simple system plugin for this.
Maybe it helps here.
htdocs/plugins/system/myfancypluing/myfancyplugin.php:
<?php
defined('_JEXEC') or die;
class PlgSystemMyfancyplugin extends JPlugin {
public function () (&$subject, $config) {
parent::__construct($subject, $config);
} // __construct
public function plgVmConfirmedOrder($cart, $order) {
// $cart: object VirtueMartCart
// $orderdata: array orderdata incl. customer's addresses etc.
if( ! class_exists('VmModel')) require(JPATH_ADMINISTRATOR . '/components/com_virtuemart/helpers/vmmodel.php');
vmLanguage::loadJLang('com_virtuemart_countries');
// Get some extra data
$billing_countryname=vmText::_('COM_VIRTUEMART_COUNTRY_' . shopfunctions::getCountryByID($order['details']['BT']->virtuemart_country_id, 'country_3_code'));
$shipping_countryname=vmText::_('COM_VIRTUEMART_COUNTRY_' . shopfunctions::getCountryByID($order['details']['ST']->virtuemart_country_id, 'country_3_code'));
$order_created_on_ts=strtotime($order['details']['BT']->created_on);
$model=VmModel::getModel('shipmentmethod');
$modeldata=$model->getShipment($order['details']['BT']->virtuemart_shipmentmethod_id);
$order_shipment_name=trim(strip_tags($modeldata->shipment_name));
$model=VmModel::getModel('paymentmethod');
$modeldata=$model->getPayment($order['details']['BT']->virtuemart_paymentmethod_id);
$order_payment_name=trim(strip_tags($modeldata->payment_name));
unset($model);
unset($modeldata);
//more code here
} // plgVmConfirmedOrder()
} // class
htdocs/plugins/system/myfancypluing/myfancyplugin.xml:
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="system" method="upgrade">
<name>PLG_SYSTEM_MYFANCYPLUGIN</name>
<description>PLG_SYSTEM_MYFANCYPLUGIN_XML_DESCRIPTION</description>
<version>1.0</version>
<author>[...]</author>
<creationDate>2019-07</creationDate>
<authorEmail>[...]</authorEmail>
<authorUrl>https://obengelb.de (https://obengelb.de)</authorUrl>
<copyright>Copyright (c) 2019 obengelb GmbH</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<files>
<filename plugin="MYFANCYPLUGIN">MYFANCYPLUGIN.php</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_system_MYFANCYPLUGIN.ini</language>
<language tag="en-GB">en-GB.plg_system_MYFANCYPLUGIN.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field />
</fieldset>
</fields>
</config>
</extension>
Thanks
for oder data in CSV we use EasyFeeder, not myfancyplugin.
And Im definitely sure exist more others app.
If you're trying to access the order number, payment name, and order total in the orderdone.php file in VirtueMart, you can use the following code to get that information:
// Get the order ID from the URL
$order_id = JRequest::getInt('order_id');
// Load the order model and get the order object wordle (https://wordle2.io/)
$order_model = VmModel::getModel('orders');
$order = $order_model->getOrder($order_id);
// Get the order number, payment name, and order total
$order_number = $order->order_number;
$payment_name = $order->payment_name;
$order_total = $order->order_total;
This code retrieves the order ID from the URL, loads the order model, and gets the order object for the specified order ID. From there, you can access the order number, payment name, and order total using the $order object.