Display products for individual vendors and

WCMp Vendor Frontend Reports

Display products for individual vendors and Resolved

Viewing 11 reply threads
  • Author
    Posts
    • #106258
      randomdudeftw5
      Participant

      I’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!

    • #106259
      randomdudeftw5
      Participant

      here is a picture of how it looks like

      Attachments:
    • #106330
      abhirup
      Moderator

      Hi,
      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>";
              }
          }
      Copy

      Use 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.

    • #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?

    • #106462
      abhirup
      Moderator

      Hi,
      >> 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
      Copy

      Regards,

    • #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?

    • #106539
      randomdudeftw5
      Participant

      I 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?

    • #106639
      abhirup
      Moderator

      Hi,
      >> 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();
      Copy

      use 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,

    • #106664
      randomdudeftw5
      Participant

      Hi
      >>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

    • #106667
      randomdudeftw5
      Participant

      Last 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>”;
      }
      }

    • #106736
      abhirup
      Moderator

      Hi,
      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>";
              }
          }
      Copy

      Use this shortcode [vendor_store]

      Regards,

    • #110832

      We 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.

Viewing 11 reply threads

The topic ‘Display products for individual vendors and’ is closed to new replies.

Buy all Marketplace addons together, check out our Bundle

Buy at Slashed Price