Author Topic: Get products ids in order done page  (Read 664 times)

pm4698

  • Jr. Member
  • **
  • Posts: 176
Get products ids in order done page
« on: December 15, 2021, 23:19:49 pm »
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
Code: [Select]
$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:
Code: [Select]
$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

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1441
    • MiniJoomla
  • Skype Name: support-easysoftware
  • VirtueMart Version: 3
Re: Get products ids in order done page
« Reply #1 on: December 16, 2021, 08:39:06 am »
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

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4608
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Get products ids in order done page
« Reply #2 on: December 16, 2021, 16:15:44 pm »
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

  • Jr. Member
  • **
  • Posts: 176
Re: Get products ids in order done page
« Reply #3 on: December 17, 2021, 19:18:28 pm »
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

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1441
    • MiniJoomla
  • Skype Name: support-easysoftware
  • VirtueMart Version: 3
Re: Get products ids in order done page
« Reply #4 on: December 17, 2021, 22:18:19 pm »
Quote
Any 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