This topic contains a post which is marked as Best Answer. Press here if you would like to see it.
*

Tango

  • ****
  • 212 posts
New Order Alert
« 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.


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!

*

MB Themes

Re: New Order Alert
« Reply #1 on: January 05, 2022, 12:50:18 PM »
@Tango
Thanks for feedback ;)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Re: New Order Alert
« Reply #2 on: January 09, 2022, 07:10:17 AM »
Great  :)

*

Tango

  • ****
  • 212 posts
Re: New Order Alert
« Reply #3 on: September 27, 2022, 01:36:10 PM »
@Michal
I'm trying to implement this by adding the following in osclas_pay/functions.php:
Code: [Select]
// 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!

*

MB Themes

Re: New Order Alert
« Reply #4 on: September 27, 2022, 01:53:00 PM »
@Tango
I do not see source for this:
Code: [Select]
      $order_items = isset($order['order_items']) ? $order['order_items'] : 0;
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Tango

  • ****
  • 212 posts
Re: New Order Alert
« Reply #5 on: September 27, 2022, 02:48:20 PM »
Yeah, tried this but still nothing:
Code: [Select]
// 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 :'(

*

MB Themes

Re: New Order Alert
« Reply #6 on: September 27, 2022, 06:27:47 PM »
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.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Tango

  • ****
  • 212 posts
Re: New Order Alert
« Reply #7 on: September 28, 2022, 11:41:32 AM »
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.

Code: [Select]
// 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');

*

MB Themes

Re: New Order Alert
« Reply #8 on: September 28, 2022, 01:21:04 PM »
@Tango
Shouldnt be this part:
Code: [Select]
      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:
Code: [Select]
      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;
          }
        }
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Marked as best answer by Tango on September 28, 2022, 02:26:03 PM
*

Tango

  • ****
  • 212 posts
Re: New Order Alert
« Reply #9 on: September 28, 2022, 02:22:34 PM »
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).

Code: [Select]
// 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

*

Fabio Massaro

  • *****
  • 291 posts
Re: New Order Alert
« Reply #10 on: October 25, 2022, 09:12:16 AM »
Hi @Tango I have been following you for some time and I like your commitment. I would like to understand (New order notice)

*

Tango

  • ****
  • 212 posts
Re: New Order Alert
« Reply #11 on: October 25, 2022, 06:08:36 PM »
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!

*

Fabio Massaro

  • *****
  • 291 posts
Re: New Order Alert
« Reply #12 on: October 25, 2022, 08:31:49 PM »
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