Jump to content

Duplicate Emails for Order State Updation via Webservice


ExpressTech

Recommended Posts

When trying to update an Order, an email is sent out to the buyer irrespective of the 'current_state' value. For example, if I send this : 

 

<?xml version="1.0" encoding="utf-8"?>
<prestashop>
    <order>
        <id>18</id>
        <reference>TGEWKKMSY</reference>
        <id_customer>10</id_customer>
        <total_paid>43</total_paid>
        <payment>Bank wire</payment>
        <current_state>4</current_state>
        <shipping_number>test1234</shipping_number>
        <id_address_delivery>8</id_address_delivery>
        <id_address_invoice>8</id_address_invoice>
        <id_cart>27</id_cart>
        <id_currency>1</id_currency>
        <id_lang>1</id_lang>
        <id_carrier>4</id_carrier>
        <module>bankwire</module>
        <total_paid_real>0</total_paid_real>
        <total_products>27</total_products>
        <total_products_wt>30</total_products_wt>
        <conversion_rate>1.000000</conversion_rate>
        <id_shop_group>1</id_shop_group>
        <id_shop>1</id_shop>
    </order>
</prestashop>
 
So, here <current_state> is 4 and its already 4 in the database, in other words I didn't change it. But an email is sent whereas its expected to NOT send an email if the state does not change. 
 
Please let me know if I am doing something wrong.
Edited by vikas.programmer (see edit history)
Link to comment
Share on other sites

Well, I found this code. It emails the user without checking of new 'current_state'

 


public function setCurrentState($id_order_state, $id_employee = 0)
{
if (empty($id_order_state))
return false;
$history = new OrderHistory();
$history->id_order = (int)$this->id;
$history->id_employee = (int)$id_employee;
$history->changeIdOrderState((int)$id_order_state, $this);
$res = Db::getInstance()->getRow('
SELECT `invoice_number`, `invoice_date`, `delivery_number`, `delivery_date`
FROM `'._DB_PREFIX_.'orders`
WHERE `id_order` = '.(int)$this->id);
$this->invoice_date = $res['invoice_date'];
$this->invoice_number = $res['invoice_number'];
$this->delivery_date = $res['delivery_date'];
$this->delivery_number = $res['delivery_number'];
$this->update();


$history->addWithemail();
}
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...