[*] WS : order history add(POST) send customer email if sendemail=1 url parameter, thanks @gerdus

This commit is contained in:
gRoussac
2013-07-26 17:55:53 +02:00
parent 2704f52fe4
commit 42c5335f27
+27 -1
View File
@@ -64,6 +64,9 @@ class OrderHistoryCore extends ObjectModel
'id_order_state' => array('required' => true, 'xlink_resource'=> 'order_states'),
'id_order' => array('xlink_resource' => 'orders'),
),
'objectMethods' => array(
'add' => 'addWs',
),
);
/**
@@ -445,4 +448,27 @@ class OrderHistoryCore extends ObjectModel
AND os.`logable` = 1');
}
}
/**
* Add method for webservice create resource Order History
* If sendemail=1 GET parameter is present sends email to customer otherwise does not
* @return bool
*/
public function addWs()
{
$sendemail = (bool)Tools::getValue('sendemail', false);
if ($sendemail)
{
//Mail::Send requires link object on context and is not set when getting here
$context = Context::getContext();
if ($context->link == null)
{
$protocol_link = (Tools::usingSecureMode() && Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://';
$protocol_content = (Tools::usingSecureMode() && Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://';
$context->link = new Link($protocol_link, $protocol_content);
}
return $this->addWithemail();
}
else
return $this->add();
}
}