Banner Logo

Be a part of the family: Connect, Receive Support,
Contribute, and Reap Abundant Rewards!

Default Date Range In Orders Not Working Recently

MultivendorX Pro

Resolved
Viewing 16 reply threads
  • Author
    Posts
    • #194328
      Chris
      Participant

      Hi support,
      I was using the code provided previously via a support thread to set the default date range for orders, as shown below:
      Hi,
      For order table override dc-woocommerce-multi-vendor/templates/vendor-dashboard/vendor-orders.php template by copying it to yourtheme/MultiVendorX/vendor-dashboard/vendor-orders.php
      then change line no 37 instant of below code
      <input type=”date” name=”mvx_start_date_order” class=”pickdate gap1 mvx_start_date_order form-control” placeholder=”<?php esc_attr_e(‘from’, ‘multivendorx’); ?>” value=”<?php echo isset($_POST[‘mvx_start_date_order’]) ? wc_clean($_POST[‘mvx_start_date_order’]) : date( ‘Y-m-d’, strtotime(‘-90 days’)); ?>” />

      However, recently, as you can see from this screenshot, https://prnt.sc/aD3Kb6uD8E5L , the orders are not showing the orders as per the date range set.

    • #194329
      Chris
      Participant

      I have to click the show button to make all the other orders appearing, as in this screenshot, https://prnt.sc/WdzM77_zzRwI

      Could you please have a check on this? Thanks

    • #194330
      Chris
      Participant
    • #194358

      @Chris Our team is checking the issue. Kindly provide them some time.

    • #194407

      Hello @Chris
      You need to override the vendor-orders.php template with this https://drive.google.com/file/d/1zQiId4NPuZHfE9ZW17EWJitYGnl1-_cv/view?usp=sharing
      You need to follow the below path to override the template yourtheme/MultiVendorX/vendor-dashboard/vendor-orders.php
      Also add the below code in the functions.php file of your current active theme –

      
      add_filter('mvx_datatable_get_vendor_all_orders', 'default_load_order_table', 10, 3);
      function default_load_order_table($all_orders, $requestData, $method) {
          if ($method['submit_data'] != 1) {
              $start_date = date( 'Y-m-d', strtotime('-90 days')); 
              $end_date = date( 'Y-m-d');
              $vendor = get_current_vendor();
              $args = array(
                  'author' => $vendor->id,
                  'post_status' => 'any',
                  'date_query' => array(
                      array(
                          'after'     => $start_date,
                          'before'    => $end_date,
                          'inclusive' => true,
                      ),
                  )
              );
              $all_orders = mvx_get_orders($args);
              return $all_orders;
          } else {
              return $all_orders;
          }
      }
      
      Copy
    • #194508
      Chris
      Participant

      Hi, the code snippet has following errors.

      Snippet automatically deactivated due to an error on line 3:
      Syntax error, unexpected identifier ” “.

    • #194511

      Sorry for the inconvenience. Kindly add the below code in the functions.php file of your current active theme –

      
      add_filter('mvx_datatable_get_vendor_all_orders', 'default_load_order_table', 10, 3);
      function default_load_order_table($all_orders, $requestData, $method) {
          if ($method['submit_data'] != 1) {
              $start_date = date( 'Y-m-d', strtotime('-90 days')); 
              $end_date = date( 'Y-m-d');
              $vendor = get_current_vendor();
              $args = array(
                  'author' => $vendor->id,
                  'post_status' => 'any',
                  'date_query' => array(
                      array(
                      'after'  => $start_date,
                      'before' => $end_date,
                      'inclusive' => true,
                      ),
                  )
              );
              $all_orders = mvx_get_orders($args);
              return $all_orders;
          } else {
              return $all_orders;
          }
      }
      
      Copy
    • #194512
      Chris
      Participant
      This reply has been marked as private.
    • #194516

      @Chris kindly add the below code and check –

      
      add_filter('mvx_datatable_get_vendor_all_orders', 'default_load_order_table_new', 10, 3);
      function default_load_order_table_new($all_orders, $requestData, $method) {
           if ($method['submit_data'] != 1) {
              $start_date = date( 'Y-m-d', strtotime('-90 days')); 
              $end_date = date( 'Y-m-d');
              $vendor = get_current_vendor();
              $args = array(
                  'author' => $vendor->id,
                  'post_status' => 'any',
                  'date_query' => array(
                      array(
                          'after'     => $start_date,
                          'before'    => $end_date,
                          'inclusive' => true,
                      ),
                  )
              );
              $all_orders = mvx_get_orders($args);
              return $all_orders;
           } else {
              return $all_orders;
           }
      }
      
      Copy
    • #194517
      Chris
      Participant

      Alright, tested & its working now. Thanks

    • #194518

      You are welcome.

    • #194519
      Chris
      Participant

      Not sure if the history table is working or not as I don’t have much data available for it yet. If it’s not working also, can I have a fix for the history table too? Else, that’s all for this part. Thanks

    • #194522

      The code and template modification we have provided is for the vendor orders page.
      Now if you need modification for the history tab too then please let us know we will help you accordingly.

    • #194525
      Chris
      Participant

      Yes, I need it also for the history tab. Please help me accordingly. Thank you

    • #194529

      For history table override dc-woocommerce-multi-vendor/templates/vendor-dashboard/vendor-transactions.php template by copying it to yourtheme/MultiVendorX/vendor-dashboard/vendor-transactions.php
      then change line no 31 instant of below code

      
      <input type="date" id="mvx_from_date" class="form-control" name="from_date" class="pickdate gap1" placeholder="From" value ="<?php echo date( 'Y-m-d', strtotime('-90 days')); ?>"/>
      
      Copy
    • #194645
      Chris
      Participant

      Okay thanks

    • #194651

      You are welcome.

Viewing 16 reply threads

The topic ‘Default Date Range In Orders Not Working Recently’ is closed to new replies.