02.02.2015 20:49
|
|
Jobos1
Name: J
07.10.2014
Сообщения: 30
|
Check order-status / Do stuff if order-status changed to "paid (6)"
Hi!
I want to execute some stuff if the status of the order has changed to "paid" (automatically).
Which PHP file(s) is the best place to insert it?
First I wanted to insert it in /controllers/checkout.php in step7, when the order is paid by Paypal or other direct payment method which immediately sets the order status to "paid".
But I think it would be best to insert it directly to where the order-status is changed to "paid".
So is it better to insert into models/checkout.php? In which function?
I want to include with a if-condition like " if ($order->order_total !== 0) && ($order->order_status == '6')) { .. do my stuff .. }
Would be very glad for help! Thank you :-)
Joomla: 3.5 PHP: 5 MySQL: 5
|
|
04.02.2015 15:29
|
|
Jobos1
Name: J
07.10.2014
Сообщения: 30
|
Aw: Check order-status / Do stuff if order-status changed to "paid (6)"
Hello,
I would be very glad if you would provide me this short information / code.
Thank you very much for your time!
|
|
08.02.2015 02:25
|
|
Jobos1
Name: J
07.10.2014
Сообщения: 30
|
Aw: Check order-status / Do stuff if order-status changed to "paid (6)"
Sorry, I do not want to get on your nerves but it would really be nice if you could help me, I don't want to make any mistakes.
Thank you!
|
|
08.02.2015 18:15
|
|
admin
(Support Team)
Name: Admin
05.08.2010
Сообщения: 25920
|
Aw: Check order-status / Do stuff if order-status changed to "paid (6)"
Create plugin group jshoppingorder
Triger onBeforeChangeOrderStatus(&$order_id, &$status, &$sendmessage, &$restext)
|
|
08.02.2015 22:15
|
|
Jobos1
Name: J
07.10.2014
Сообщения: 30
|
Aw: Check order-status / Do stuff if order-status changed to "paid (6)"
Hi and thank you for your answer,
I am sorry but I do not understand, should I create a plugin or what do you mean?
Can't I just insert it in the right place in models/checkout.php or controller/checkout.php?
Thank you,
|
|
09.02.2015 07:45
|
|
admin
(Support Team)
Name: Admin
05.08.2010
Сообщения: 25920
|
Aw: Check order-status / Do stuff if order-status changed to "paid (6)"
Or
Change
model/checkout.php
Search text 'onBeforeChangeOrderStatus'
|
|
09.02.2015 10:06
|
|
Jobos1
Name: J
07.10.2014
Сообщения: 30
|
Aw: Check order-status / Do stuff if order-status changed to "paid (6)"
I tried to insert the code but it is not working.
I added after the line
" $dispatcher->trigger('onBeforeChangeOrderStatus', array(&$order_id, &$status, &$sendmessage, &$restext)); "
and on some other places but it doesn't work. Should I create a function for it or should I just write it outside a function in the checkout.php?
Can you please provide a example?
Последнее изменение: 09.02.2015 10:06
|
|
09.02.2015 13:23
|
|
admin
(Support Team)
Name: Admin
05.08.2010
Сообщения: 25920
|
Aw: Check order-status / Do stuff if order-status changed to "paid (6)"
It should work.
Try change status order.
|
|
09.02.2015 13:38
|
|
Jobos1
Name: J
07.10.2014
Сообщения: 30
|
Aw: Check order-status / Do stuff if order-status changed to "paid (6)"
The first part of the changeStatusOrder function looks like this now: (I just inserted a mail function for testing if executed)
.....
function changeStatusOrder($order_id, $status, $sendmessage = 1){
$mainframe = JFactory::getApplication();
$lang = JSFactory::getLang();
$jshopConfig = JSFactory::getConfig();
$restext = '';
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('onBeforeChangeOrderStatus', array(&$order_id, &$status, &$sendmessage, &$restext));
$headers = "From: .....\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
$message = '...';
mail("$receiver", $sub, $message, $headers);
$order = JSFactory::getTable('order', 'jshop');
$order->load($order_id);
$order->order_status = $status;
$order->order_m_date = getJsDate();
$order->store();
.....
But also when I change the status of any order it is not sent.
|
|
09.02.2015 13:53
|
|
admin
(Support Team)
Name: Admin
05.08.2010
Сообщения: 25920
|
Aw: Check order-status / Do stuff if order-status changed to "paid (6)"
Try
die('00000000000');
admin / orders / change status
|
|
09.02.2015 14:12
|
|
Jobos1
Name: J
07.10.2014
Сообщения: 30
|
Aw: Check order-status / Do stuff if order-status changed to "paid (6)"
I am sorry, but that doesn't change anything.
Can I insert maybe inside
function sendOrderEmail($order_id, $manuallysend = 0)
?
|
|
10.02.2015 08:13
|
|
admin
(Support Team)
Name: Admin
05.08.2010
Сообщения: 25920
|
Aw: Check order-status / Do stuff if order-status changed to "paid (6)"
Try.
|
|
11.02.2015 00:07
|
|
Jobos1
Name: J
07.10.2014
Сообщения: 30
|
Aw: Check order-status / Do stuff if order-status changed to "paid (6)"
There it does not work.
Now I inserted into
function sendOrderEmail($order_id, $manuallysend = 0){ ..
and there it works, but only, if the order is created manually inside the order-list in the admin backend. But it is not working when you do the normal checkout in front-end.
How can that be?
Is there an other way where it can be inserted or do you know a solution why it is not working there? It is just simple mail function and mysql_query.
I do not want to change the shop system just because of that.
Please help me!
Последнее изменение: 11.02.2015 00:08
|
|
11.02.2015 08:03
|
|
admin
(Support Team)
Name: Admin
05.08.2010
Сообщения: 25920
|
Aw: Check order-status / Do stuff if order-status changed to "paid (6)"
Better decision use triggers
|
|
11.02.2015 09:34
|
|
Jobos1
Name: J
07.10.2014
Сообщения: 30
|
Aw: Check order-status / Do stuff if order-status changed to "paid (6)"
OK so should I use this trigger?:
$dispatcher->trigger('onBeforeChangeOrderStatus', array(&$order_id, &$status, &$sendmessage, &$restext));
Create a plugin-PHP with:
public function onContentPrepare($context, &$row, &$params, $limitstart)
{
my content
}
and then it is called on this trigger? Or do I need to add something?
|
|