Banner Logo

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

Dashboard issue with Woocommerce Bundle

WCMp Core

Resolved
Viewing 23 reply threads
  • Author
    Posts
    • #131116
      MaxenceTP
      Participant

      Hello,
      I have an issue with the “Product Sales Report” on the main page of the vendor dashboard.
      I use this plugin : https://woocommerce.com/products/product-bundles/

      The bundle product is displayed, that’s not a problem. But the products within this bundle are also displayed in the list.
      Where I can add a condition to display the unique sales ? Even for products within bundles

      Thank you

    • #131126

      Hi,
      The display option comes from the plugin itself.
      .
      It seems to be a theme issue, kindly switch to a default theme and check again.

      If the issue still persists, then share a video and explain in details so that we can help you out.

    • #131161
      MaxenceTP
      Participant
      This reply has been marked as private.
    • #131162
      MaxenceTP
      Participant

      The “Revenue” is correct, but the quantity sold is not

    • #131241

      Hi,
      We couldn’t recreate this on our end.
      Kindly create a staging site and share admin,ftp access.
      Also do not forget to mark the response as private while sharing the access.

    • #131309

      Also, as you can see even for bundle products WooCommerce handles each bundle product as an individual product and displays the same in the report : https://loom.com/share/8e874d7608884bd7a6e7c5a0a68f00da

    • #131332
      MaxenceTP
      Participant
      This reply has been marked as private.
    • #131370
      This reply has been marked as private.
    • #131377
      MaxenceTP
      Participant

      I don’t look at Woocommerce data so it doesn’t matter to me, but the problem is that sellers think they have made more sales than reality according to the data displayed in their dashboard.
      Isn’t there a way to verify that the product’s commission is >0 before counting it in “Unique purshaces”?

      Since in the commissions, the products in the bundle are indeed 0€

    • #131418

      HI,
      As per your requirement you can change the table data using the below filter. It’s need good amount of custom code.

      apply_filters( ‘wcmp_widget_vendor_product_sales_report_row_data’, $row, $product_id, $sold_item_data );

      Regards,

    • #132015
      MaxenceTP
      Participant

      The filters don’t allow me to make the change I want, I would just have to add 2 lines of code like this: https://prnt.sc/22zk1q4
      With the filter wcmp_widget_vendor_product_sales_report_row_data I can’t know if it is a bundle product if the quantity is >= 2.

      How to make this modification without touching directly the plugin code?

    • #132016
      MaxenceTP
      Participant

      Can you add a filter here in an update ?
      That I can use it to do that

    • #132040

      HI,
      AS per your requirement, We can’t add filter there.
      Kindly add filter in the selected line and try to add custom code to delete products.
      Check out the image – https://prnt.sc/2343l6z

      Otherwise
      add below code to your function.php of your active theme and make change here –

      function wcmp_custom_changes(){
       global $WCMp;
       remove_action('wp_ajax_wcmp_widget_vendor_product_sales_report', array($WCMp->ajax, 'wcmp_widget_vendor_product_sales_report'));
       add_action('wp_ajax_wcmp_widget_vendor_product_sales_report', 'wcmp_widget_vendor_product_sales_report');
      
      }
      
      function wcmp_widget_vendor_product_sales_report(){
          global $wpdb;
          if (is_user_logged_in() && is_user_wcmp_vendor(get_current_vendor_id())) {
      
              $vendor = get_wcmp_vendor(get_current_vendor_id());
              $requestData = ( $_REQUEST ) ? wc_clean( $_REQUEST ) : array();
              $today = @date('Y-m-d 00:00:00', strtotime("+1 days"));
              $days_range = apply_filters('wcmp_widget_vendor_product_sales_report_days_range', 7, $requestData, $vendor);
              $last_seven_day_date = date('Y-m-d H:i:s', strtotime("-$days_range days"));
              
              $query = array(
                  'author' => $vendor->id,
                  'date_query' => array(
                      array(
                          'after'     => $last_seven_day_date,
                          'before'    => $today,
                          'inclusive' => true,
                      ),
                  ),
                  'meta_query'    => array(
                      'relation' => 'AND',
                      array(
                          'key'       => '_commission_id',
                          'value'   => 0,
              'compare' => '!=',
                      )
                  )
              );
              $vendor_orders = apply_filters('wcmp_widget_vendor_product_sales_report_orders', wcmp_get_orders( $query, 'object' ), $query);
              
              $sold_product_list = array();
              if ( $vendor_orders ) :
                  foreach ( $vendor_orders as $order ) {
                      $line_items = $order->get_items('line_item');
                      foreach ( $line_items as $item_id => $item ) {
                          if (array_key_exists($item->get_product_id(), $sold_product_list)) {
                              $sold_product_list[$item->get_product_id()]['qty'] += $item->get_quantity();
                              $sold_product_list[$item->get_product_id()]['item_total'] += $item->get_total();
                          } else {
                              $sold_product_list[$item->get_product_id()]['qty'] = $item->get_quantity();
                              $sold_product_list[$item->get_product_id()]['item'] = $item;
                              $sold_product_list[$item->get_product_id()]['item_total'] = $item->get_total();
                              $sold_product_list[$item->get_product_id()]['order_id'] = $order->get_id();
                          }
                      }
                  }
              endif;
              arsort($sold_product_list);
              $data = array();
              foreach ($sold_product_list as $product_id => $sold_item_data) {
                  $item = $sold_item_data['item'];
                  $product = $item->get_product();
                  $row = array();
                  if ($product) {
                      $row ['product'] = '<a href="' . wcmp_get_product_link( $product_id ) . '">' . $product->get_image(array(40, 40)) . ' ' . wp_trim_words($item->get_name(), 60, '...') . '</a>';
                      $row ['revenue'] = wc_price( $sold_item_data['item_total'] );
                      $row ['unique_purchase'] = $sold_item_data['qty'];
                  } else {
                      $row ['product'] = __('This product does not exists', 'dc-woocommerce-multi-vendor');
                      $row ['revenue'] = '-';
                      $row ['unique_purchase'] = $sold_item_data['qty'];
                  }
                  $data[] = apply_filters( 'wcmp_widget_vendor_product_sales_report_row_data', $row, $product_id, $sold_item_data );
              }
      
              $json_data = array(
                  "draw" => intval($requestData['draw']), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. 
                  "recordsTotal" => intval(count($sold_product_list)), // total number of records
                  "recordsFiltered" => intval(count($sold_product_list)), // total number of records after searching, if there is no searching then totalFiltered = totalData
                  "data" => $data   // total data array
              );
              wp_send_json($json_data);
              die;
          }
      }
      Copy

      Regards,

    • #132215
      MaxenceTP
      Participant

      It’s a shame to have to overwrite the whole function just for an if but if there’s no other solution I’d do it that way.

      The changes I make in my theme are not taken into account, it is always the original function that is executed. Even with this code :

      Copy

      `function wcmp_custom_changes(){
      global $WCMp;
      remove_action(‘wp_ajax_wcmp_widget_vendor_product_sales_report’, array($WCMp->ajax, ‘wcmp_widget_vendor_product_sales_report’));

      Copy

      `
      The widget is still displayed, which means it doesn’t remove wcmp_widget_vendor_product_sales_report

    • #132262

      Hi,
      The full code modification is a alternative suggestion. We can’t add filter there to check the data but also we will add filter here ( https://prnt.sc/2343l6z ). So we asked you to check if you compatible to add custom code if we add filer there.
      If you are compatible then we surely add a filter here ( https://prnt.sc/2343l6z ) in our next update.

      Otherwise you have to add custom code to modify this.

      Use below code to remove ajax request

      add_action('init', 'wcmp_custom_changes');
      function wcmp_custom_changes(){
         global $WCMp;
         remove_action('wp_ajax_wcmp_widget_vendor_product_sales_report', array($WCMp->ajax, 'wcmp_widget_vendor_product_sales_report'));
      }
      Copy

      Regards,

    • #132282
      MaxenceTP
      Participant

      No the filter on this line doesn’t help. Or is it possible to add a filter on this line ?

      $line_items = $order->get_items('line_item');
      Copy
    • #132315

      Hi,
      Yes, it is possible to add filter in this line.
      Kindly checkout the below plugin and confirm so we will add same filter in our next update.

      https://drive.google.com/file/d/17-TZzyp2EM2MG3nEH4yEjmTNQN4T-Z3z/view?usp=sharing

      Use this filter – wcmp_widget_vendor_product_sales_report_line_items

      Regards,

    • #132351
      MaxenceTP
      Participant

      Are you sure you sent me the right files?
      I don’t see this filter in the code

    • #132379
    • #132515
      MaxenceTP
      Participant

      Hello,
      Yes you can add it in your next update 😉

    • #132554

      Hi,

      Kindly follow this link to checkout the progress – https://github.com/wcmarketplace/dc-woocommerce-multi-vendor/issues/1002

      Regards,

    • #132575
      MaxenceTP
      Participant

      Ok, thank you

    • #132579

      🙂

    • #132885
      MaxenceTP
      Participant

      Thank you for the update, this thread can be closed

Viewing 23 reply threads

The topic ‘Dashboard issue with Woocommerce Bundle’ is closed to new replies.