Osclass Support Forums
Osclass plugin support => Osclass Pay Plugin => Topic started by: Tango on January 05, 2022, 12:22:53 PM
-
At the moment, our eCommerce system is missing an alert system for when a seller has orders that need processing.
Many times sellers will forget to check if they have new or old orders that need processing.
To fix this, we need to a nagging alert that appears every time you refresh the site, if there are orders with Processing status.
(https://i.ibb.co/9s6C90d/notification.png)
Logic:
- Check if Product Selling is enabled
- Check if the user is a seller and has products for sale
- Check Orders mng. for all orders that have the status Processing
- Count the Processing orders and output the alert if the value is > 0
This would help A LOT! ;D
Thanks!
-
@Tango
Thanks for feedback ;)
-
Great :)
-
@Michal
I'm trying to implement this by adding the following in osclas_pay/functions.php:
// FLASH MESSAGE FOR ORDERS THAT NEED PROCESSING
function osp_new_orders_notification() {
if(osc_is_web_user_logged_in()) {
$sellers = array_filter(explode(',', osp_param('seller_users')));
$is_seller = false;
if(in_array(osc_logged_user_id(), $sellers) || osp_param('seller_all') == 1) {
$is_seller = true;
}
if($is_seller && osp_param('enable_user_management') == 1) {
$params = Params::getParamsAsArray();
$order_items = isset($order['order_items']) ? $order['order_items'] : 0;
if( (isset($order_items['i_status']) == OSP_ORDER_PROCESSING) > 0 ) {
osc_add_flash_warning_message(__('You have orders that need processing. <a href="' . osc_route_url('osp-manager') . '">Click here</a> to fulfill them.', 'osclass_pay'));
}
}
}
}
osc_add_hook('header', 'osp_new_orders_notification');
However, the flash message always appears, for all users.
The idea is to have it appear only for sellers that have orders with the status Processing.
Any feedback?
Thanks!
-
@Tango
I do not see source for this:
$order_items = isset($order['order_items']) ? $order['order_items'] : 0;
-
Yeah, tried this but still nothing:
// FLASH MESSAGE FOR ORDERS THAT NEED PROCESSING
function osp_new_orders_notification() {
if(osc_is_web_user_logged_in()) {
$is_seller = osp_user_is_seller(osc_logged_user_id());
if($is_seller && osp_param('enable_user_management') == 1) {
$params = Params::getParamsAsArray();
$orders = ModelOSP::newInstance()->getOrdersWithItems($params);
if(is_array($orders) && count($orders) > 0) {
if($orders['i_status'] == OSP_ORDER_PROCESSING) {
osc_add_flash_warning_message(__('You have orders that need processing. <a href="' . osc_route_url('osp-manager') . '">Click here</a> to fulfill them.', 'osclass_pay'));
}
}
}
}
}
osc_add_hook('header', 'osp_new_orders_notification');
I give up, my head hurts :'(
-
I think you should just get orders for specific user and check if there is some in processing, or get only processing orders.
Do not have time to check into code now.
-
I think you should just get orders for specific user and check if there is some in processing, or get only processing orders.
Yeah, I got the user sales where the order status is also present, but still nothing.
There's something fishy going on, as this should be a fairly simple function: check if the user is seller > check if he has orders > check if those orders have PROCESSING status > if true, output the message.
// FLASH MESSAGE FOR ORDERS THAT NEED PROCESSING
function osp_new_orders_notification() {
if(osc_is_web_user_logged_in()) {
$is_seller = osp_user_is_seller(osc_logged_user_id());
if($is_seller && osp_param('enable_user_management') == 1) {
$orders = ModelOSP::newInstance()->getUserSales($is_seller);
if(is_array($orders) && count($orders) > 0) {
if(isset($orders['i_status']) && $orders['i_status'] == OSP_ORDER_PROCESSING) {
osc_add_flash_warning_message(__('You have orders that need processing. <a href="' . osc_route_url('osp-manager') . '">Click here</a> to fulfill them.', 'osclass_pay'));
}
}
}
}
}
osc_add_hook('header', 'osp_new_orders_notification');
-
@Tango
Shouldnt be this part:
if(is_array($orders) && count($orders) > 0) {
if(isset($orders['i_status']) && $orders['i_status'] == OSP_ORDER_PROCESSING) {
osc_add_flash_warning_message(__('You have orders that need processing. <a href="' . osc_route_url('osp-manager') . '">Click here</a> to fulfill them.', 'osclass_pay'));
}
replaced with:
if(is_array($orders) && count($orders) > 0) {
foreach($orders as $order) {
if(isset($order['i_status']) && $order['i_status'] == OSP_ORDER_PROCESSING) {
osc_add_flash_warning_message(__('You have orders that need processing. <a href="' . osc_route_url('osp-manager') . '">Click here</a> to fulfill them.', 'osclass_pay'));
break;
}
}
-
We finally have a solution (I've also added a check for seller_all, in order to prevent showing the notification for both sellers and buyers when Enable All Registered to Sell Products is active).
Maybe you can implement it in the next plugin version (don't forget to add the translation string in languages).
// FLASH MESSAGE FOR ORDERS THAT NEED PROCESSING
function osp_new_orders_notification() {
if(osc_is_web_user_logged_in()) {
$is_seller = osp_user_is_seller(osc_logged_user_id());
if($is_seller && osp_param('seller_all') != 1 && osp_param('enable_user_management') == 1) {
$orders = ModelOSP::newInstance()->getUserSales($is_seller);
if(is_array($orders) && count($orders) > 0) {
foreach($orders as $order) {
if(isset($order['i_status']) && $order['i_status'] == OSP_ORDER_PROCESSING) {
osc_add_flash_warning_message(__('You have orders that need processing. <a href="' . osc_route_url('osp-manager') . '">Click here</a> to fulfill them.', 'osclass_pay'));
break;
}
}
}
}
}
}
osc_add_hook('header', 'osp_new_orders_notification');
Thanks a lot Michal! :P
-
Hi @Tango I have been following you for some time and I like your commitment. I would like to understand (New order notice)
-
Hi @Tango I have been following you for some time and I like your commitment. I would like to understand (New order notice)
There's nothing to understand. You got the design proposition in the first post and the implementation in the one above.
At this point, you can only pray that MB Themes finds the time to test this and implement it in the plugin.
Until then, you're on your own.
Good luck!
-
Hi @Tango I have been following you for some time and I like your commitment. I would like to understand (New order notice)
There's nothing to understand. You got the design proposition in the first post and the implementation in the one above.
At this point, you can only pray that MB Themes finds the time to test this and implement it in the plugin.
Until then, you're on your own.
Good luck!
I don't care it was just curiosity all here
I understand how to develop my site