VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: m.davide82 on June 28, 2018, 15:29:36 PM

Title: If ST, show these data instead BT
Post by: m.davide82 on June 28, 2018, 15:29:36 PM
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!
Title: Re: If ST, show these data instead BT
Post by: AH on June 28, 2018, 16:47:26 PM
version etc

Plus what are you trying to achieve ?
Title: Re: If ST, show these data instead BT
Post by: m.davide82 on June 28, 2018, 17:50:55 PM
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
Title: Re: If ST, show these data instead BT
Post by: AH on June 29, 2018, 22:26:26 PM
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.

Title: Re: If ST, show these data instead BT
Post by: Studio 42 on June 30, 2018, 00:35:16 AM
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.
Title: Re: If ST, show these data instead BT
Post by: m.davide82 on June 30, 2018, 19:17:13 PM
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!
Title: Re: If ST, show these data instead BT
Post by: Jörgen on June 30, 2018, 22:07:59 PM
The email belongs to the BT address, Fetch that first or copy it to the ST array.

regards

Jörgen @ Kreativ Fotografi