Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Feature Request › Total number of sales on each seller's store
- This topic has 4 replies, 3 voices, and was last updated 4 years, 3 months ago by Javaris Fountain.
- AuthorPosts
- April 14, 2020 at 10:50 am #118936LewisParticipant
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
- April 16, 2020 at 12:06 am #119518Ramamurthy KrishnanKeymaster
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,
- April 16, 2020 at 2:54 am #119559LewisParticipant
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
- April 16, 2020 at 1:43 pm #119690Ramamurthy KrishnanKeymaster
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,
- July 21, 2020 at 9:23 pm #153588Javaris FountainParticipant
is it a away to apply this if you are using elementor to style the page?
- AuthorPosts
- You must be logged in to reply to this topic.