Jump to content

Recommended Posts

Hi all,

I'm using Prestashop 1.6.0.14 and I'm trying to get the customer address in my module with the hook "hookActionOrderStatusUpdate".

My code:

$var_order_status = $params['newOrderStatus']->id;
$var_id_order = (int)$params['id_order'];
$order = new Order($var_id_order);
$var_id_cart = (int)$order->id_cart;
$cart = new Cart($var_id_cart);
$var_id_address = $cart->id_address_invoice;
$address = new Address($var_id_address);

 

The $var_id_address DOES contain an id, but the variable $address isn't created.
What am I doing wrong? How can I retrieve the customer address (so not shipping address)? I need the ZIP code and street name.

Thanks.

- Kevin.

 

Share this post


Link to post
Share on other sites

I would first abbreviate the code to the following.  There is no need to look at the cart object, since the order object would have the most update to date address information.

$var_order_status = $params['newOrderStatus']->id;
$var_id_order = (int)$params['id_order'];
$order = new Order($var_id_order);
$var_id_address = $order->id_address_invoice;
$address = new Address($var_id_address);

Now if the Address object is not valid, you should debug that by checking the value of id_address_invoice obtained from the Order object.  The value should be an int greater than zero. 

If it is, then go to your database and confirm that the ps_address table has a record with that address. 

If it is zero, then somehow your order or address records got corrupt, and I'm not sure how to help you with that.

Share this post


Link to post
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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More