Display products for individual vendors and
Home / Topic / WCMp Vendor Frontend Reports / Display products for individual vendors and
WCMp Vendor Frontend Reports
Display products for individual vendors and Resolved
- This topic has 11 replies, 3 voices, and was last updated 1 month, 2 weeks ago by
WCMp Support Ninja.
-
AuthorPosts
-
-
September 24, 2020 at 5:18 AM #106258
randomdudeftw5
ParticipantI’m trying to display individual vendors’ products and would like to know how to do so, currently I’m using [wcmp_products id=””] but I want to display products listed without having to key in the id individually, is there a way?
And also, when I use the short code, the edit and trash image gets messed up, how do I fix that?
Help is very much appreciated!
-
September 24, 2020 at 5:19 AM #106259
randomdudeftw5
Participanthere is a picture of how it looks like
Attachments:
-
September 25, 2020 at 6:40 AM #106330
abhirup
ModeratorHi,
WCMP already have vendor shop page for individual vendor products.
otherwise add this below code for getting the vendor products.
Modify below code as per your requirement.
please add this code in the function.php of the current active theme :add_shortcode( 'vendor_store', 'shortcode_get_products' ); function shortcode_get_products($args = array()) { global $WCMp; $user_id = get_current_user_id(); if(is_user_wcmp_vendor($user_id)){ $default = array( 'post_type' => 'product', 'post_status' => 'publish', 'posts_per_page' => -1, 'author' => $user_id, //change your vendor id here ); $args = wp_parse_args($args, $default); ob_start(); $products = new WP_Query( $args ); if ($products->have_posts()){ ?> <?php woocommerce_product_loop_start(); ?> <?php while ($products->have_posts()) : $products->the_post(); ?> <?php wc_get_template_part('content', 'product'); ?> <?php endwhile; // end of the loop. ?> <?php woocommerce_product_loop_end(); ?> <?php }else{ echo "No Product Found"; } woocommerce_reset_loop(); wp_reset_postdata(); $return = '<div class="woocommerce ">' . ob_get_clean() . '</div>'; // Remove ordering query arguments WC()->query->remove_ordering_args(); return $return; }else{ return $msg="<h2>You are not vendor</h2>"; } }
CopyUse this shortcode [vendor_store]
>> And also, when I use the short code, the edit and trash image gets messed up, how do I fix that?
Its look like your theme conflict with this.
apply custom css for fixed this issue.Regards.
-
September 25, 2020 at 9:45 AM #106341
randomdudeftw5
Participant>>Use this shortcode [vendor_store]
The code works well but I want it to display the projects from the person I am currently viewing. Is this possible? I want to add the products by each user at the bottom of their buddypress profile.>>Its look like your theme conflict with this.apply custom css for fixed this issue.
What custom css should I add in order to fix this? -
September 26, 2020 at 1:03 AM #106462
abhirup
ModeratorHi,
>> The code works well but I want it to display the projects from the person I am currently viewing. Is this possible? I want to add the products by each user at the bottom of their buddypress profile.
— You have to need some custom code for getting the product.
— Modify the above code.
— Get the vendor id from the page and put this id ‘$user_id = get_current_user_id();’ here.
>> What custom css should I add in order to fix this?
— You need to check what is wrong with this then apply your css
This is the class you can use for your css.wcmp_fpm_buttons
CopyRegards,
-
September 26, 2020 at 3:45 AM #106492
randomdudeftw5
Participant>>Get the vendor id from the page and put this id ‘$user_id = get_current_user_id();’ here.
>>You need to check what is wrong with this then apply your css
Can you elaborate a bit more on how to do them? -
September 27, 2020 at 2:55 AM #106539
randomdudeftw5
ParticipantI cant quite figure out what is wrong with the theme I am using, is it possible then to remove the icons and only allow users to edit in the dashboard?
-
September 28, 2020 at 5:14 AM #106639
abhirup
ModeratorHi,
>> remove the icons and only allow users to edit in the dashboard?
–Please add this code in the function.php of the current active theme :add_action('init','wcmp_frontend_edit_product_remove'); function wcmp_frontend_edit_product_remove(){ global $WCMp; remove_action('woocommerce_before_shop_loop_item', array($WCMp->product, 'frontend_product_edit'), 5); remove_action('woocommerce_before_single_product_summary', array($WCMp->product, 'frontend_product_edit'), 5); }
Copy>> Get the vendor id from the page and put this id ‘$user_id = get_current_user_id();’ here.
— Maybe this function will help you.bp_displayed_user_id();
Copyuse above function instant of get_current_user_id();
If this not worked then please ask to the plugin author ‘how to get buddypress user id on profile page?’Regards,
-
September 28, 2020 at 8:20 AM #106664
randomdudeftw5
ParticipantHi
>>Please add this code in the function.php of the currently active theme :
thanks for the reply, this works.
>>use above function instant of get_current_user_id();
this does not work but ill see what I can do thanks.
you can close the thread now -
September 28, 2020 at 9:04 AM #106667
randomdudeftw5
ParticipantLast question before you close this thread is it possible to add in a display by category for this?
add_shortcode( ‘vendor_store’, ‘shortcode_get_products’ );
function shortcode_get_products($args = array()) {
global $WCMp;
$user_id = get_current_user_id();
if(is_user_wcmp_vendor($user_id)){
$default = array(
‘post_type’ => ‘product’,
‘post_status’ => ‘publish’,
‘posts_per_page’ => -1,
‘author’ => $user_id, //change your vendor id here
);$args = wp_parse_args($args, $default);
ob_start();
$products = new WP_Query( $args );
if ($products->have_posts()){
?><?php woocommerce_product_loop_start(); ?>
<?php while ($products->have_posts()) : $products->the_post(); ?>
<?php wc_get_template_part(‘content’, ‘product’); ?>
<?php endwhile; // end of the loop. ?>
<?php woocommerce_product_loop_end(); ?>
<?php
}else{
echo “No Product Found”;
}woocommerce_reset_loop();
wp_reset_postdata();$return = ‘<div class=”woocommerce “>’ . ob_get_clean() . ‘</div>’;
// Remove ordering query arguments
WC()->query->remove_ordering_args();return $return;
}else{
return $msg=”<h2>You are not vendor</h2>”;
}
} -
September 29, 2020 at 5:14 AM #106736
abhirup
ModeratorHi,
Using below code you can get the products category wise.add_shortcode( 'vendor_store', 'shortcode_get_products' ); function shortcode_get_products($args = array()) { global $WCMp; $user_id = get_current_user_id(); if(is_user_wcmp_vendor($user_id)){ $category = 'music,tshirts'; //chage categories from here sapareted by comma ','. $default = array( 'post_type' => 'product', 'post_status' => 'publish', 'posts_per_page' => -1, 'author' => $user_id, //change your vendor id here 'tax_query' => array( array( 'taxonomy' => 'product_cat', 'terms' => array_map( 'sanitize_title', explode( ',', $category )), 'field' => 'slug', 'operator' => 'IN' ) ) ); $args = wp_parse_args( $args, $default ); ob_start(); $products = new WP_Query( $args ); if ($products->have_posts()){ ?> <?php woocommerce_product_loop_start(); ?> <?php while ( $products->have_posts() ) : $products->the_post(); ?> <?php wc_get_template_part( 'content', 'product' ); ?> <?php endwhile; // end of the loop. ?> <?php woocommerce_product_loop_end(); ?> <?php } else { echo "No Product Found"; } woocommerce_reset_loop(); wp_reset_postdata(); $return = '<div class="woocommerce ">' . ob_get_clean() . '</div>'; // Remove ordering query arguments WC()->query->remove_ordering_args(); return $return; } else { return $msg = "<h2>You are not a vendor</h2>"; } }
CopyUse this shortcode [vendor_store]
Regards,
-
December 1, 2020 at 3:40 PM #110832
WCMp Support Ninja
ModeratorWe have not received any update from you for a long. Hope this ticket is already been resolved.
We are now closing this ticket. Kindly create a new one if you need any further help.
-
-
AuthorPosts
The topic ‘Display products for individual vendors and’ is closed to new replies.