- Posts: 171
- Thank you received: 9
Send order status change email with function
- pepecortez
-
Topic Author
- Offline
Less
More
12 years 1 month ago #168393
by pepecortez
Send order status change email with function was created by pepecortez
-- HikaShop version -- : 2.3.2
-- HikaMarket version -- : 1.4.3
-- Joomla version -- : 3.3
Hi Jerome,
We need to speed up the vendors' frontend confirmation process a bit.
I created a button and connected a function for it in /components/com_hikamarket/controllers/order.php
The buttons in the listing view template are injected in this way:
It works as we need, the only missing point is to solve somehow to send the order status change notification emails (both to user and vendor) the same way as it sends if we use the frontend status editing in the default way (click on order details, click on edit order status part, click on dropdown to choose status, then click save).
Could you give me a small code hint how should I solve that?
-- HikaMarket version -- : 1.4.3
-- Joomla version -- : 3.3
Hi Jerome,
We need to speed up the vendors' frontend confirmation process a bit.
I created a button and connected a function for it in /components/com_hikamarket/controllers/order.php
Code:
function jovahagyott_order(){
$app = JFactory::getApplication();
$db = JFactory::getDBO();
$order_id = JRequest::getVar('order_id');
$order_number = JRequest::getVar('order_number');
$query = 'UPDATE '.hikashop_table('order').' SET order_status="confirmed" WHERE order_number='.$db->Quote($order_number);
$db->setQuery($query);
$result = $db->query();
$redirect_url = JRequest::getVar('redirect_url');
$app->redirect($redirect_url);
return true;
}
}
The buttons in the listing view template are injected in this way:
Code:
<?php if($order->order_status == 'created') {?>
<form id="adminForm_<?php echo $order->order_id; ?>_jovahagyott" action="<?php echo hikashop_currentURL(); ?>" method="post" name="adminForm_<?php echo $order->order_id; ?>_jovahagyott">
<button type="submit" class="btn btn-large right" name="jovahagyott_order" value="OK" onclick="var field=document.getElementById('<?php echo $order->order_id; ?>');document.adminForm_<?php echo $order->order_id; ?>_jovahagyott.submit();return false;">OK</button>
<input type="hidden" name="Itemid" value="<?php echo $Itemid; ?>"/>
<input type="hidden" name="option" value="<?php echo HIKAMARKET_COMPONENT; ?>" />
<input type="hidden" name="task" value="jovahagyott_order" />
<input type="hidden" name="order_number" value="<?php echo $order->order_number ?>" />
<input type="hidden" name="email" value="1" />
<input type="hidden" name="order_id" value="<?php echo $order->order_id; ?>" />
<input type="hidden" name="ctrl" value="<?php echo JRequest::getCmd('ctrl'); ?>" />
<input type="hidden" name="redirect_url" value="<?php echo hikashop_currentURL(); ?>" />
<?php echo JHTML::_( 'form.token' ); ?>
</form>
<?php }?>
It works as we need, the only missing point is to solve somehow to send the order status change notification emails (both to user and vendor) the same way as it sends if we use the frontend status editing in the default way (click on order details, click on edit order status part, click on dropdown to choose status, then click save).
Could you give me a small code hint how should I solve that?
Please Log in or Create an account to join the conversation.
12 years 1 month ago #168399
by Jerome
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Replied by Jerome on topic Send order status change email with function
Hi,
You have to use the HikaShop API if you want to change the order status and trigger the different events (like HikaMarket and his process to link the main order with the sub orders).
I also recommend you to put a token verification for security purpose.
Regards,
PS : Don't use order_number as identifier, use the order_id.
You have to use the HikaShop API if you want to change the order status and trigger the different events (like HikaMarket and his process to link the main order with the sub orders).
Code:
// Security stuff
$config = hikamarket::config();
if(!$config->get('frontend_edition',0))
return false;
if(!hikamarket::loginVendor())
return false;
if(!hikamarket::acl('order_edit'))
return false;
$order_id = hikamarket::getCID('order_id');
if(!hikamarket::isVendorOrder($order_id))
return false;
// Processing stuff
$shopConfig = hikamarket::config(false);
$orderClass = hikamarket::get('shop.class.order');
$o = new stdClass();
$o->order_id = $order_id;
$o->order_status = $shopConfig->get('confirm_status', 'confirmed');
$o->history = new stdClass();
$o->history->history_notified = true;
$o->history->history_type = 'modification';
$orderClass->save($o);
Regards,
PS : Don't use order_number as identifier, use the order_id.
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
The following user(s) said Thank You: pepecortez
Please Log in or Create an account to join the conversation.
- pepecortez
-
Topic Author
- Offline
Less
More
- Posts: 171
- Thank you received: 9
12 years 1 month ago - 12 years 1 month ago #168465
by pepecortez
Replied by pepecortez on topic Send order status change email with function
Jerome, thanks for the help, and the tips, works great.
Now vendor gets the oder status notification email correctly.
But user, who made the order do not get it. I think user's status email is a hikashop mail, not hikamarket's, maybe that can cause this, isn't it?
Edit: added code you earlier helped me, now user also gets it:
Thanks again!
Now vendor gets the oder status notification email correctly.
But user, who made the order do not get it. I think user's status email is a hikashop mail, not hikamarket's, maybe that can cause this, isn't it?
Edit: added code you earlier helped me, now user also gets it:
Code:
$o->hikamarket->force_email = true;
Thanks again!
Last edit: 12 years 1 month ago by pepecortez.
Please Log in or Create an account to join the conversation.
12 years 1 month ago #168470
by Jerome
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Replied by Jerome on topic Send order status change email with function
Hi,
Right, if the order is a sub order, you have to "force the email" so HikaMarket will allow the user notification.
Regards,
Right, if the order is a sub order, you have to "force the email" so HikaMarket will allow the user notification.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
Moderators: Obsidev
Time to create page: 0.179 seconds