getOrder($this->cart->virtuemart_order_id) doesnt work any more

Started by Leila, February 01, 2021, 20:28:18 PM

Previous topic - Next topic

Leila

Hello!
I used the code below to pass order data to CRM after checkout on orderdone.php
$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


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.10.11
php 8.0

Leila

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.

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


AH

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.10.11
php 8.0

Leila

QuoteYou 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.
QuoteThe 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

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

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.10.11
php 8.0

Sandruk1

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:
?>
<pre><?php print_r($this->cart->orderDetails); ?></pre>

and make a test order
we can see orderDetails:
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

Regards
A

Joomla 3.10.11
php 8.0

Jumbo!

Quote from: AH 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.

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

Milbo

I also think it has nothing todo with an OPC or payment.

Which shipment do you use? The standard shipment can now use an extra own override within the plugin. So we can have different orderdones, depending on the plugin.

$orderModel = VmModel::getModel('orders');
$order = $orderModel->getOrder($this->cart->virtuemart_order_id);
$order_number = $this->cart->orderDetails['details']['BT']->order_number;


Hmm indeed that should work. I did some tiny changes. for example in cart/view.html.php private function lOrderDone() or the one in line 1843 in helpers/cart.php. hmmm




Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

AH

I think it is this new line in helpers cart that is clearing things out


//It looks like we need this to prevent, that the cart gets the old layout back (orderdone)
$cart = VirtueMartCart::getCart(true);
//vmdebug('emptyCartValues emptied',$test->layout);
Regards
A

Joomla 3.10.11
php 8.0

Leila

Quote from: AH on February 26, 2021, 09:58:48 AM
I think it is this new line in helpers cart that is clearing things out


//It looks like we need this to prevent, that the cart gets the old layout back (orderdone)
$cart = VirtueMartCart::getCart(true);
//vmdebug('emptyCartValues emptied',$test->layout);


Thank you very much! This works excellent!

Milbo

But what happens now, when we select a custom cart layout?
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/