News:

Looking for documentation? Take a look on our wiki

Main Menu

Get products ids in order done page

Started by pm4698, December 15, 2021, 23:19:49 PM

Previous topic - Next topic

pm4698

Hi there. I have a Joomla 3.10.4 and Virtuemart 3.8.8. Inside orderdone.php I would like to get order's product ids.
What was inside orderdone.php
$db = JFactory::getDBO();
$query = "SELECT * FROM #__virtuemart_orders ORDER BY virtuemart_order_id DESC LIMIT  0, 1";
$db->setQuery($query);
$res_obj  = $db->LoadObject();


What I did is this:
$productquery = "SELECT virtuemart_product_id FROM #__virtuemart_order_items WHERE virtuemart_order_id='".$res_obj->virtuemart_order_id."'";
$db->setQuery($productquery);
$res_obj2  = $db->LoadObject();
print_r($res_obj2);


So If i run query of what I did in phpMyAdmin with my latest order id, then query works (if I have 2 items in order I see the 2 items). In my php code, inside the print_r, I get only 1 product from the order and not all.

Any ideas?

Thank you in advance

pinochico

In orderdone.php is only

echo $this->html;

from every payment plugin.

I think your construct can't function anytime.
So I don't have ideas too.
Maybe go to payment plugin and hack this.
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

Studio 42

pm4698, your query is not safe, because you get last oder and this order can be form another user, if someone finish the order at same date time
Perhaps you can get orderdetails using
$cart = VirtueMartCart::getCart();
var_dump($cart->orderDetails);
I think you should see the current order from last cart

pm4698

Thank you all for your input. When trying to print_r($this) i don't get any details regarding order items, just the order. Also tried:
$cart = VirtueMartCart::getCart();
var_dump($cart->orderDetails);

but I get error message that couldn't find the function. Any ideas?

pinochico

QuoteAny ideas?

I think, I already wrote it to you:
The value for $this is generated by the payment plugin, look at its code and create your own.

www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products