I am writing a custom order handling script for magento CE. If a new order is picked up by the script through cron it should create an invoice and notify the user and send a comment. I use the SOAP api for this purpose.
This works when sending an email, but how can I make the comment visible to the user on the frontend?
If I manually login to Magento admin, I can add a comment to an order and then check Visible on Frontend
.
I would like the comments I add with sales_order_invoice.create
and sales_order_shipment.create
to be visible to the customer in the Frontend the same way. I know that is not possible with default settings in the backend, but I would like to do that.
If this is really hard to do, I would at least like the comments added with sales_order.addComment
to be visible to the customer on the frontend just as when I manually comment and check Visible on Frontend
.
Here is my code for the SOAP proxy:
class magentoProxyHandler{
protected $proxy;
protected $session;
function __construct(){
$this->proxy = new SoapClient('http://www.magento.nl/index.php/api/soap/?wsdl');
$this->session = $this->proxy->login('change_order', 'password');
}
function __destruct(){
$this->proxy->endSession($this->session);
}
function addComment($orderId, $status, $comment = '', $notifyCustomer = true){
$orderId = ($orderId > 100000000 ? $orderId : $orderId + 100000000);
$notify = $notifyCustomer ? true : false;
$changeOrder = array('orderIncrementId' => $orderId, 'status' => $status, 'comment'=> $comment, 'notify'=> $notify);
return $this->proxy->call($this->session, 'sales_order.addComment', $changeOrder);
}
function createInvoice($orderId, $status, $comment = 'Invoice ready', $notifyCustomer = true){
$orderId = ($orderId > 100000000 ? $orderId : $orderId + 100000000);
$notify = $notifyCustomer ? true : false;
return $this->proxy->call($this->session, 'sales_order_invoice.create', array($orderId, array(), $comment, true, true));
}
function shipOrder($orderId, $status, $comment = 'Order shipped', $notifyCustomer = true){
$orderId = ($orderId > 100000000 ? $orderId : $orderId + 100000000);
$notify = $notifyCustomer ? true : false;
return $this->proxy->call($this->session, 'sales_order_shipment.create', array($orderId, array(), $comment, true, true));
}
} //end of class
I know I can do some little improvements to this code, this was simply for testing the the soap API.
I also asked this question in stackoverflow. I hope thats OK. If It get answered there, I'll post the answer here. Hope you guys can help me. Thanks in advance.
Edit:
Ok , I found out this flag has to be set in database: is_visible_on_front
. Is there anyway to pass this through the SOAP api? Of course I tried adding it to the call, as well as isVisibleOnFront
but it doesn't work...