WCMp bundle is available at a slashed price

Grab It Now

Change default start date and end date in Vendor Orders

Change default start date and end date in Vendor Orders2019-05-31T23:29:39-05:00

Home Support Forum WCMp Core Change default start date and end date in Vendor Orders

WCMp Core

Change default start date and end date in Vendor Orders Resolved

  • Author
    Posts
  • martin1
    Participant
    Post count: 2

    We want to change the start and end date in the vendor orders viewpoint.

    Right now it shows orders between Y-m-1 and Y-m-d. We want to show the last 30 days instead.
    Can you add a filter to start_date and end_date in wcmp_vendor_dashboard_vendor_orders_endpoint()

    Thanks in advance!

  • NerdySupportExpert Moumita
    Keymaster
    Post count: 4600

    @martin1, thanks for the query.

    Currently, we display the order of one month by default.

    However, in order to display the orders of last 30 days, you have to override the template file vendor-order.php. Here you can check that we are passing date(‘Y-m-t’), where l is for last day of the current month. ou can know more on how to override here – https://github.com/dualcube/dc-woocommerce-multi-vendor/blob/e9d0116da4636adf10d27ef788fb4b7cd91427bf/templates/vendor-dashboard/vendor-orders.php

    Now, you can also look this doc, here, it has modified the start date : https://stackoverflow.com/questions/10586615/current-date-2-months

    Follow the same flow, to modify the end date.

  • admin24
    Participant
    Post count: 469

    FYI I have done this and it still does not work right. The text is changed, but you still have to click the show button for it to change to what is actually displayed. It’s like this for any changes you make to the dropdown boxes via edits or overrides.

    • admin24
      Participant
      Post count: 469

      replied in wrong place

  • NerdySupportExpert Moumita
    Keymaster
    Post count: 4600

    @admin24, let our team check this further, we will try to provide a code snippet for this.

  • Raju The Cool Guy
    Moderator
    Post count: 136

    Hi @admin24,
    use this code in your current theme functions.php

    add_filter('wcmp_datatable_get_vendor_all_orders', 'change_order_details',10,3);
    function change_order_details($vendor_all_order, $requestData, $post){
        global $wpdb;
        $vendor = get_current_vendor();
        $vendor_all_order = $wpdb->get_results("SELECT DISTINCT order_id from <code>{$wpdb->prefix}wcmp_vendor_orders</code> where commission_id > 0 AND  created >= (CURDATE() - INTERVAL 1 MONTH ) AND vendor_id = '" . $vendor->id . "' and <code>is_trashed</code> != 1 ORDER BY <code>created</code> DESC", ARRAY_A);
        return $vendor_all_order;
    }
    • admin24
      Participant
      Post count: 469
      This reply has been marked as private.
  • NerdySupportExpert Moumita
    Keymaster
    Post count: 4600
    This reply has been marked as private.
    • admin24
      Participant
      Post count: 469

      If that reply was for me I can’t see it. Thanks.

  • NerdySupportExpert Moumita
    Keymaster
    Post count: 4600

    @admin24, yes the response was for you.

    It will be better if you can share a temporary admin, vendor and FTP access in a new thread.

  • NerdySupportExpert Moumita
    Keymaster
    Post count: 4600

    @admin24, you need to remove our previous code : https://wc-marketplace.com/support-forum/topic/change-default-start-date-and-end-date-in-vendor-orders/#post-61119

    Now, you have to override vendor-orders.php template by copying it to yourtheme/dc-product-vendor/vendor-dashboard/vendor-orders.php. Now change the line number 32 :
    <input type="text" name="wcmp_start_date_order" class="pickdate gap1 wcmp_start_date_order form-control" placeholder="<?php _e('from', 'dc-woocommerce-multi-vendor'); ?>" value="<?php echo isset($_POST['wcmp_start_date_order']) ? $_POST['wcmp_start_date_order'] : date('Y-m-01', strtotime('first day of last month')); ?>" />

  • admin24
    Participant
    Post count: 469

    Yeah, same issue. That still requires you to actually click “Show” before it actually displays that date range. So, the text of the date box will show correct but it still only shows the default orders in the chart until you click the button…..

  • admin24
    Participant
    Post count: 469
    This reply has been marked as private.
  • admin24
    Participant
    Post count: 469
    This reply has been marked as private.
  • NerdySupportExpert Moumita
    Keymaster
    Post count: 4600
    This reply has been marked as private.
    • admin24
      Participant
      Post count: 469

      If that reply was for me again, I can’t see it.

  • NerdySupportExpert Moumita
    Keymaster
    Post count: 4600

    @admin24, I have removed the private mode, you can check now.

    • admin24
      Participant
      Post count: 469
      This reply has been marked as private.
  • NerdySupportExpert Moumita
    Keymaster
    Post count: 4600

    @admin24, checked the video link again, it is still showing This video does not exist.

    Can you please check.

    • admin24
      Participant
      Post count: 469
      This reply has been marked as private.
  • NerdySupportExpert Moumita
    Keymaster
    Post count: 4600

    @admin24, please check the thread again.

    • admin24
      Participant
      Post count: 469

      I don’t know why my youtube upload is broken. I will try to fix it but all I did was click on the Orders tab. Then you can see the date range displayed looks fine. But, no orders before May 1st are showing. Then I click “SHOW” without changing any dates, and the proper date range shows up. You should be able to see this clearly with the login info I sent.

  • CrazyPluginAuthor Khokan
    Keymaster
    Post count: 196

    @admin24, I added the last 30 days data of vendor order by default by editing vendor-orders.php template in active theme’s folder.
    Please check this.

    • admin24
      Participant
      Post count: 469

      Ah ok, so in addition to changing the code you sent, the fix is to also add this “hidden” input type code. Cool, looks like it’s working great !

      So all the changes in one place for other readers:

      Line 32, change to:
      <input type="text" name="wcmp_start_date_order" class="pickdate gap1 wcmp_start_date_order form-control" placeholder="<?php _e('from', 'dc-woocommerce-multi-vendor'); ?>" value="<?php echo isset($_POST['wcmp_start_date_order']) ? $_POST['wcmp_start_date_order'] : date('Y-m-d', strtotime('-30 days')); ?>" />

      Insert before Line 36:
      <input type="hidden" id="wcmp_start_datetotime" value="<?php echo isset($_POST['wcmp_start_date_order']) ? strtotime($_POST['wcmp_start_date_order']) : strtotime(date('Y-m-d', strtotime('-30 days'))); ?>" />

      Insert before the new Line 41 after </span> (it’s new, but does not appear related to the above lines):
      <input type="hidden" id="wcmp_end_datetotime" value="<?php echo isset($_POST['wcmp_end_date_or6der']) ? strtotime($_POST['wcmp_end_date_order']) : strtotime(date('Y-m-d')); ?>" />

      Next, is there a similar change to force changes for the order status and number of rows? I want Processing to only be displayed by default and 50 rows, which would make the dashboard so much easier to use.

      1) I’ve currently changed the order displayed for order status by re-ordering Lines 130-132. But this doesn’t actually filter the list until you click “show”.

      2) I can’t figure out where to edit the number of default rows.

      Thank you!

  • CrazyPluginAuthor Khokan
    Keymaster
    Post count: 196

    @admin24, I added the above tasks modifications in your vendor-orders.php template in active theme’s folder. Please check this.

  • admin24
    Participant
    Post count: 469

    That’s fantastic, thank you so much. You guys are awesome.

    What happened to Martin? lol

  • NerdySupportExpert Moumita
    Keymaster
    Post count: 4600
  • admin24
    Participant
    Post count: 469

    Hello again, I just found a bug with the order status and number of rows. Now, I can’t change away from those defaults. Trying to change # of rows or displaying completed orders just refreshes to the default.

  • CrazyPluginAuthor Khokan
    Keymaster
    Post count: 196

    I can’t find any bugs as mentioned. Please re-check properly. If you find any such issue, kindly send us some attachments.

  • admin24
    Participant
    Post count: 469

    Well it definitely wasn’t working before but now it’s working just fine 🙂

    Note for whoever else tries this… the “processing” pop up default is halfway down, so for 50 rows it is not visible. I adjusted the CSS in the WCMp settings from top: 50%; to top: 0 !important; Also had to add a z-index of 1 because a border from the chart showed on top.

  • NerdySupportExpert Moumita
    Keymaster
    Post count: 4600

    @admin24, great to know that.

    I am closing this thread.

    If you need any further help, just open a new one.

The topic ‘Change default start date and end date in Vendor Orders’ is closed to new replies.