Author Topic: getOrder($this->cart->virtuemart_order_id) doesnt work any more  (Read 554 times)

Leila

  • Beginner
  • *
  • Posts: 26
  • A beginner
    • Интернет магазин Ковровик
  • VirtueMart Version: 3.8.6
getOrder($this->cart->virtuemart_order_id) doesnt work any more
« on: February 01, 2021, 20:28:18 pm »
Hello!
I used the code below to pass order data to CRM after checkout on orderdone.php
Code: [Select]
$orderModel = VmModel::getModel('orders');
$order = $orderModel->getOrder($this->cart->virtuemart_order_id);
$order_number = $this->cart->orderDetails['details']['BT']->order_number;
But after update tp VM 3.8.8 it doesnt work any more.

When I downgrade to 3.8.6 version all works perfectly.

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3395
  • VirtueMart Version: 3.8.8
Re: getOrder($this->cart->virtuemart_order_id) doesnt work any more
« Reply #1 on: February 02, 2021, 11:24:44 am »

I believe that this is a snippet of code from the OPC of Abishek (based on the last post you made regarding this issue for your site)

You have to talk to the developer - to ensure that the OPC is compatible with the latest version.

They will then be able to confirm changes that need to be made.  As you pay for OPC - you should receive updates.



regards
A

Joomla 3.9.23
php 7.3

Leila

  • Beginner
  • *
  • Posts: 26
  • A beginner
    • Интернет магазин Ковровик
  • VirtueMart Version: 3.8.6
Re: getOrder($this->cart->virtuemart_order_id) doesnt work any more
« Reply #2 on: February 02, 2021, 15:55:56 pm »
I turned off VP Onepage Checkout. The problem remains on default cart as well.
When I replace $this->cart->virtuemart_order_id with existing order ID i can print_r array of order data.

Code: [Select]
$orderModel = VmModel::getModel('orders');
$virtuemart_order_id = 'My_Order_ID';
$order = $orderModel->getOrder($virtuemart_order_id);

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3395
  • VirtueMart Version: 3.8.8
Re: getOrder($this->cart->virtuemart_order_id) doesnt work any more
« Reply #3 on: February 02, 2021, 17:19:23 pm »
If you debug your "$this->cart->virtuemart_order_id"  you might see that it does not contain the virtuemart_order_id

You need to get the order id and pass it to your function.  in "default cart" - orderdone.php - There is no code to load the order model or get an order.

Which is what I think you are adding and trying to use.

Replacing the value with a "known" virtuemart_order_id will obvioulsy work -  but you need to pass orderdone.php something to work with.

The getOrder function does require a valid virtuemart_order_id
regards
A

Joomla 3.9.23
php 7.3

Leila

  • Beginner
  • *
  • Posts: 26
  • A beginner
    • Интернет магазин Ковровик
  • VirtueMart Version: 3.8.6
Re: getOrder($this->cart->virtuemart_order_id) doesnt work any more
« Reply #4 on: February 03, 2021, 09:19:08 am »
Quote
You need to get the order id and pass it to your function.  in "default cart" - orderdone.php - There is no code to load the order model or get an order.
I add $orderModel = VmModel::getModel('orders'); to default cart orderdone.php manually and my code works. I can get all order data and pass them to CRM on Virtuemart 3.8.6. I don't understand why the code doesnt work on V3.8.8.
Quote
The getOrder function does require a valid virtuemart_order_id
How can I get virtuemart_order_id and pass customer info, order items and payment, shipment details on V3.8.8?

Sandruk1

  • Beginner
  • *
  • Posts: 12
  • A beginner
Re: getOrder($this->cart->virtuemart_order_id) doesnt work any more
« Reply #5 on: February 13, 2021, 20:23:26 pm »
I also after updating virtuemart to 3.8.8 stopped working data output for conversion to google ads.
in file orderdone.php:
$ orderNumber = $ this-> cart-> orderDetails ['details'] ['BT'] -> order_number;
will not show order_number
if i do check
<pre> <? php print_r ($ this-> cart-> orderDetails); ?> </pre>
orderDetails does not display order data.
in virtuemart 3.8.6 and 3.8.7 everything worked,
is it a bug or is it a new change?
 
Joomla 3.9.24
Virtuemart 3.8.8
Php 7.4

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3395
  • VirtueMart Version: 3.8.8
Re: getOrder($this->cart->virtuemart_order_id) doesnt work any more
« Reply #6 on: February 20, 2021, 10:35:59 am »
Please review my replies above -

You need to get your payment method plugin to hand over the data - it is not there by default for all plugins
regards
A

Joomla 3.9.23
php 7.3

Sandruk1

  • Beginner
  • *
  • Posts: 12
  • A beginner
Re: getOrder($this->cart->virtuemart_order_id) doesnt work any more
« Reply #7 on: February 21, 2021, 21:56:01 pm »
Thanks for the answer,
maybe I'm not explaining my problem correctly.
Example:
In Virtuemart 3.8.6
In the file orderdone.php at the end add:
Code: [Select]
?>
<pre><?php print_r($this->cart->orderDetails); ?></pre>
and make a test order
we can see orderDetails:
Code: [Select]
Array
(
    [details] => Array
        (
            [BT] => stdClass Object
                (
                    [virtuemart_order_id] => 60
                    [virtuemart_user_id] => 42
                    [virtuemart_vendor_id] => 1
                    [order_note] =>
                    [order_number] => RMG8062
                    [customer_number] => AD21232f2
                    [order_pass] => p_9JHfsWZK
                    [order_create_invoice_pass] => gYefOSiJ
                    [invoice_locked] => 0
                    [order_total] => 700.00000
                    [order_salesPrice] => 700.00000
                    [order_billTaxAmount] => 0.00000
                    [order_billTax] => 0
                    [order_billDiscountAmount] => 0.00000
                    [order_discountAmount] => 0.00000
                    [order_subtotal] => 700.00000
                    [order_tax] => 0.00000
                    [order_shipment] => 0.00000
                    [order_shipment_tax] => 0.00000
                    [order_payment] => 0.00
                    [order_payment_tax] => 0.00000
                    [coupon_discount] => 0.00
                    [coupon_code] =>
                    [order_discount] => 0.00
                    [order_currency] => 199
                    [order_status] => P
                    [user_currency_id] => 199
                    [user_currency_rate] => 1.000000
                    [user_shoppergroups] => 2
                    [payment_currency_id] => 199
                    [payment_currency_rate] => 1.000000
                    [virtuemart_paymentmethod_id] => 1
                    [virtuemart_shipmentmethod_id] => 1
                    [delivery_date] =>
                    [order_language] => ru-RU
                    [ip_address] => xx
                    [STsameAsBT] => 1
                    [paid] => 0
                    [paid_on] => 0000-00-00 00:00:00
                    [o_hash] => 74b03076d7ccd80412afea3172abd199
                    [created_on] => 2021-02-21 20:25:35
                    [created_by] => 42
                    [modified_on] => 2021-02-21 20:25:35
                    [modified_by] => 42
                    [locked_on] => 0000-00-00 00:00:00
                    [locked_by] => 0
                    [order_created] => 2021-02-21 20:25:35
                    [order_modified] => 2021-02-21 20:25:35
                    [order_modified_by] => 42
                    [virtuemart_order_userinfo_id] => 60
                    [address_type] => BT
                    [address_type_name] =>
                    [company] =>
                    [title] =>
                    [last_name] => Dz
                    [first_name] => Andriy
                    [middle_name] =>
                    [phone_1] => 0111111111
                    [phone_2] =>
                    [fax] =>
                    [address_1] => sadowa
                    [address_2] =>
                    [city] => London
                    [virtuemart_state_id] => 0
                    [virtuemart_country_id] => 220
                    [zip] => 82100
                    [email] => 1lifepro@gmail.com
                    [agreed] => 0
                    [tos] => 1
                    [customer_note] =>
                    [order_status_code] => P
                    [order_status_color] =>
                    [order_status_name] => COM_VIRTUEMART_ORDER_STATUS_PENDING
                    [order_status_description] =>
                    [order_stock_handle] => R
                    [ordering] => 1
                    [order_name] => Andriy Dz
                )
In 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.

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3395
  • VirtueMart Version: 3.8.8
Re: getOrder($this->cart->virtuemart_order_id) doesnt work any more
« Reply #8 on: February 22, 2021, 11:15:54 am »
Sandruk1
What payment plugin are you using
regards
A

Joomla 3.9.23
php 7.3

Jumbo!

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 729
  • Full-stack Web Developer
    • www.virtueplanet.com
  • VirtueMart Version: Always latest

I believe that this is a snippet of code from the OPC of Abishek (based on the last post you made regarding this issue for your site)

You have to talk to the developer - to ensure that the OPC is compatible with the latest version.

They will then be able to confirm changes that need to be made.  As you pay for OPC - you should receive updates.

Just to clarify, this has nothing to do with VP One Page Checkout plugin. The plugin does not have any such codes.