Jump to content

Getting customer details and shipping details for specific order.


Recommended Posts

Hi All,

I'm trying to get customer details and shipping address after the orders are processed from selective carts. I've got the cart Id to start with. But I'm having difficulty retrieving the customer's first name, last, name and shipping address. I've tried the following so far.

$cart_id = $value['cart_id'];
$result = false;
$order = Order::getOrderByCartId((int)($cart_id));
$order_details = OrderDetail::getList((int)$order);
if(isset($order_details[0])) {
    $order_id = $order_details[0]['id_order'];
    $customer = new Customer ($order_id);
    if (!Validate::isLoadedObject($customer)) {
        print_r($customer);
    }
}

The above code is giving me the entire customer object. But I'm not sure how to get the firstname, lastname, address and email from it.

Appreciate you taking out time for this.

Regards

B

Link to comment
Share on other sites

I solved this. The following is my solution.

$cart_id = $value['cart_id'];
$result = false;
$order = Order::getOrderByCartId((int)($cart_id));
$order_details = new Order((int)($order));
$delivery_details = new Address((int)($order_details->id_address_delivery));
$customer = new Customer((int)($delivery_details->id_customer));
print_r($customer);
print_r($delivery_details);

I was able to get customer details like email etc with $customer and delivery details like firstname, lastname, phone, address, etc with $delivery_details

 

P.S : this thread can be closed (i think.) as long as nobody wants to add a new answer.

Regards

B

Link to comment
Share on other sites

  • 3 years later...

Hello Bhagirath

i gonna try this in a different task i am working on it, i am setting up the google enhanced conversion

and i am doing it like this :

php

$phoneNumber = (!empty($delivery_address->phone) ? $delivery_address->phone : $delivery_address->phone_mobile);

php

script

 

var enhanced_conversion_data = {

    "email": prestashop.customer.email,

   "phone_number" :'<?=$phoneNumber?>'

   //$this->context->customer

    }

script

 

all this variable reference coming from google

https://support.google.com/google-ads/answer/9888145?hl=en#zippy=%2Cidentify-and-define-your-enhanced-conversions-fields

 

if u can help me to find the address and the phone number for the customer after their purchase  i will really appreciated

 

please let me know

thanks

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...