News:

Support the VirtueMart project and become a member

Main Menu

If ST, show these data instead BT

Started by m.davide82, June 28, 2018, 15:29:36 PM

Previous topic - Next topic

m.davide82

Hello,

I have this script but I need to add an if, how can I do it?
I tried some times, but with no luck!



if($status=="CONFIRMED_BY_SHOPPER")
{

$shipment     =   $this->get_shipment($virtuemart_order->virtuemart_shipmentmethod_id);

$order_details=   $this->get_order($virtuemart_order->virtuemart_order_id);
$order_details=  $order_details['details']['BT'];

$customerName =   $order_details->title. " " . $order_details->first_name. " " . $order_details->last_name;
$address      =   $order_details->address_1. " ".$order_details->address_2;
$state        =   $this->get_state($order_details->virtuemart_state_id);
$country      =   $this->get_country($order_details->virtuemart_country_id);
$order_currency=   $this->order_currency($order_details->order_currency);
$payment_methord= $this->get_paymentmethod($order_details->virtuemart_paymentmethod_id);





Thanks a lot in advance!

AH

version etc

Plus what are you trying to achieve ?
Regards
A

Joomla 4.4.5
php 8.1

m.davide82

I need to create the variables (you see in the code) to push them via api to a shipping service.

Everything is working right, in this situation I always push the billing address, but when the shipping address is set I need to push it, not the billing one.


Thanks,
Davide

AH

You have written this function -  $this->get_order

I assume this gets the order_userinfo data for this virtuemart_order_id

Check the returned rows
If you get more than one row it indicates that there is an ST address

An address_type of ST  indicates the shipping address.

Regards
A

Joomla 4.4.5
php 8.1

Studio 42

if(issset($order_details['details']['ST'])) $orderDetails =  $order_details['details']['ST'];
else  $orderDetails =  $order_details['details']['BT'];

Note that i changed $order_details to $orderDetails for clarity.

m.davide82

Hi Studio 42, thank you very much, I solved it (isset is written with 3 S in you code  :)).

Now it's working, but if I have the ST address, the email is not fetched, how can I retrieve the email address (it's always the same)?


Thanks!

Jörgen

The email belongs to the BT address, Fetch that first or copy it to the ST array.

regards

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.