Jump to content

Variables empty when using API call


Recommended Posts

Hi all,

 

I am making my very first own module.
What I want to do is handle my own feedback mails.


What I have so far is that when an admin changes the status of an order to "send", then a message will be send to me. In the email I read out some variables for testing, for example $params['cart']->getProducts(true)

 

My module code:

public function hookActionOrderStatusUpdate($params = NULL)
{
$testvar1 = $params['newOrderStatus']->id;
$testvar2 = print_r(Context::getContext()->customer, true);
$testvar3 = print_r($params['cart'], true);
$testvar4 = print_r($params['cart']->getProducts(true), true);
$pmail = "info@myemailadress.com";
$subject = "Order status changed";
$message = "Customer information:\n <pre>".$testvar2;
$message .= "</pre>";
$message .= "<br />Products in this order:\n <pre>".$testvar4;
$message .= "</pre>";
$headers = "From: info@myemailadress.com" . "\r\n";
mail($pmail,$subject,$message,$headers);

}


The above script is working great.

However, I am using a webservice as well. The webservice will automatically change the status of an order when it's really shipped.
Evertime the webservice is doing it's job, I receive the email as well (like above), BUT the variables like $params['cart']->getProducts(true) etc are EMPTY.

PS: In my Prestashop admin I gave the webservice for everything read and fast read permissions.
How come those variables are empty while it is working perfectly when an administrator in the backoffice is changing the order status?

Thanks for your help.

- Kevin

 

Edited by kevinnn (see edit history)

Share this post


Link to post
Share on other sites

Unfortunately I do not believe Prestashop designed the webservice implementation very well.  The webservice does not always do the same thing that the front or backoffice does.

Now, I'm curious why you are using the cart object in your code, as opposed to the order object?  Since we are talking about order status changes here, I would suspect you would want to use the order object. 

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