Author Topic: If ST, show these data instead BT  (Read 173 times)

m.davide82

  • Jr. Member
  • **
  • Posts: 115
If ST, show these data instead BT
« 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!


Code: [Select]
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

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 2752
  • VirtueMart Version: 3.2.15
Re: If ST, show these data instead BT
« Reply #1 on: June 28, 2018, 16:47:26 pm »
version etc

Plus what are you trying to achieve ?
regards
A

Joomla 3.8.8
php 7.0

m.davide82

  • Jr. Member
  • **
  • Posts: 115
Re: If ST, show these data instead BT
« Reply #2 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

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 2752
  • VirtueMart Version: 3.2.15
Re: If ST, show these data instead BT
« Reply #3 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.

regards
A

Joomla 3.8.8
php 7.0

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3154
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: If ST, show these data instead BT
« Reply #4 on: June 30, 2018, 00:35:16 am »
Code: [Select]
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

  • Jr. Member
  • **
  • Posts: 115
Re: If ST, show these data instead BT
« Reply #5 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!

Jörgen

  • Global Moderator
  • Full Member
  • *
  • Posts: 1541
    • Kreativ Fotografi
  • VirtueMart Version: 3.2.12
Re: If ST, show these data instead BT
« Reply #6 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
Joomla 3.8.3
Virtuemart 3.2.12
Olympiantheme Hera (customized)