Total number of sales on each seller's store

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Multi Vendor Marketplace Plugin | WCFM Marketplace Forums WCFM – Feature Request Total number of sales on each seller's store

Viewing 3 reply threads
  • Author
    Posts
    • #118936
      Lewis
      Participant

      Would it be possible to be able to display the total number of sales on the sellers page. It could also be a shortcode to put on the sidebar.

      thanks

    • #119518

      Hi,

      Add the below code to your child theme’s functions.php file.

      add_shortcode( 'wcfm_vendor_orders', 'get_wcfm_vendor_orders' );
      function get_wcfm_vendor_orders( $atts, $vendor_id ) {
      	ob_start();
      	global $wpdb;
      	$att = shortcode_atts( array(
              'vendor_id' => ''
          ), $atts );
      	$sql = 'SELECT * FROM ' . 'wp_wcfm_marketplace_orders';
      	if ( $att['vendor_id'] ) {
      		$sql .= ' WHERE vendor_id=' . $att['vendor_id'];
      	}
      	$order_data = $wpdb->get_results( $sql );
      	echo '<p><strong>Total Sales/Orders: ' . count( $order_data ) . '</strong></p>';
      	return ob_get_clean();
      }

      Then use the following shortcode in text widget : “[wcfm_vendor_orders vendor_id=”2″]”
      Just pass the correct vendor id in “vendor_id” attribute and it will display the number of orders placed against that particular vendor.

      Thanks,

      • #119559
        Lewis
        Participant

        Hi Molay Das,
        thank you for your answer!

        What I wanted to say, however, is to have the possibility of displaying the total sales numbers for each seller on their store.

        With this method, I would have to place the code manually for each store, it is unthinkable.

        Quite the same as you suggest, but without the constraint of having to specify the id maybe? It could be retrieved based on the store id of the page on which the code is placed? Like how the product display, i guess..

        Thank you

    • #119690

      Hi,

      Replace the previous code with the below given code.

      add_shortcode( 'wcfm_vendor_orders', 'get_wcfm_vendor_orders' );
      function get_wcfm_vendor_orders() {
      	ob_start();
      	global $wpdb;
      	$store_id  = 0;
      	if ( wcfm_is_store_page() ) {
      		$wcfm_store_url = get_option( 'wcfm_store_url', 'store' );
      		$store_name = get_query_var( $wcfm_store_url );
      		if ( !empty( $store_name ) ) {
      			$store = get_user_by( 'slug', $store_name );
      		}
      		$store_id = $store->ID;
      	} elseif( is_product() ) {
      		$store_id = get_post_field( 'post_author', get_the_ID() );
      	}
      	$sql = 'SELECT * FROM ' . 'wp_wcfm_marketplace_orders WHERE vendor_id=' . $store_id;
      	$order_data = $wpdb->get_results( $sql );
      	echo '<p><strong>Total Sales/Orders: ' . count( $order_data ) . '</strong></p>';
      	return ob_get_clean();
      }

      And use the following shortcode in “Vendor Store Sidebar” widget: [wcfm_vendor_orders]

      It will display the total number of sales/orders for each vendors.

      Thanks,

    • #153588
      Javaris Fountain
      Participant

      is it a away to apply this if you are using elementor to style the page?

Viewing 3 reply threads
  • You must be logged in to reply to this topic.