Show Vendor Details on Single Product Page

Theme and Plugin Support

Show Vendor Details on Single Product Page Resolved

Viewing 8 reply threads
  • Author
    Posts
    • #91954
      Franzie
      Participant

      Hello! I would like to show vendor details on the Single Product page. I can see the mobile / tel number and email address on the vendor dashboard, and I’d like to show the same thing on the single product page, like from the screenshot attached.

      Public can click it, but they need to be registered user in order to show the mobile number of the vendor. I tried copying the code from archive_vendor_info.php to functions.php but it didn’t show up.

      Can you please assist me on this?

      Page link: https://bit.ly/2JwLey4

      Thanks!

    • #92024

      Hi @Franzie, thanks for getting in touch with us.

      In order to display the phone number in single product page, add this code to the function.php of the currently active theme :

      add_action('woocommerce_single_product_summary','phoneno_additional_text');
      function phoneno_additional_text() {
      if(is_user_logged_in()){
      global $post;
      $author_id=$post->post_author;
      $phone_no=metadata_exists('user',$author_id ,'_vendor_phone')?get_user_meta($author_id ,'_vendor_phone',true):'';
      $email=get_userdata($author_id)->user_email;
      if(!empty($phone_no)) echo 'Vendor Contact No : '.$phone_no.'<br>';
      if(!empty($email)) echo 'Vendor Mail-id : ' .$email;
      }
      }
      Copy
    • #92107
      Franzie
      Participant

      Hey Moumita,

      Thanks for your reply!

      I added the code and now both the number and email is now showing up – however, I’d like to add the location as well and the vendor link (please see screenshot).

      Here’s my code:

      function my_new_information($vendor_id){
      
      global $post;    
      $vendor = get_wcmp_vendor($vendor_id);
      $author_id=$post->post_author;
      $seller=metadata_exists('user',$author_id ,'_vendor_page_title')?get_user_meta($author_id ,'_vendor_page_title',true):'';
      $phone_no=metadata_exists('user',$author_id ,'_vendor_phone')?get_user_meta($author_id ,'_vendor_phone',true):'';
      $email=get_userdata($author_id)->user_email;
      
      $location=metadata_exists('user',$author_id ,'_vendor_address1')?get_user_meta($author_id ,'_vendor_address1',true):'';
      
      $vendorLink=metadata_exists('user',$author_id ,'_vendor_slug')?get_user_meta($author_id ,'_vendor_slug',true):'';
      
      ?>
      <div class="vendor-details">
          <h4>Vendor Details</h4>
          <p class="wcmp_vendor_detail">
          <i class="fa fa-user"></i><label>&nbsp; Seller: <?php echo $seller; ?></label>
          <br/>
          <p class="wcmp_vendor_detail"><i class="fa fa-phone"></i><label>&nbsp;<?php echo $phone_no; ?></label></p>
          <p class="wcmp_vendor_detail"><i class="fa fa-map-marker"></i><label>&nbsp;<?php echo $location; ?></label></p>
          <p class="wcmp_vendor_detail"><i class="fa fa-envelope"></i><label>&nbsp;<?php if(!empty($email)) echo $email; ?></label></p>
          <p><a href="<?php echo $vendorLink ?>" class="vendor-link">See more items ></a></p>
          </p>
      </div>
      Copy

      Not sure how to make the location appear – if the user is logged in, they can see the details. But I’d like all details to be showing as well even if the user is not logged in.

      Looking forward to your reply!

    • #92192

      Hi, please use this updated code :

      add_action('woocommerce_before_add_to_cart_button','my_new_information',10,1);
      function my_new_information($vendor_id){
      
      global $post;    
      $vendor = get_wcmp_vendor($vendor_id);
      $author_id=$post->post_author;
      $seller=metadata_exists('user',$author_id ,'_vendor_page_title')?get_user_meta($author_id ,'_vendor_page_title',true):'';
      $phone_no=metadata_exists('user',$author_id ,'_vendor_phone')?get_user_meta($author_id ,'_vendor_phone',true):'';
      $email=get_userdata($author_id)->user_email;
      
      $location=metadata_exists('user',$author_id ,'_vendor_address_1')?get_user_meta($author_id ,'_vendor_address_1',true):'';
      
      $vendorLink=metadata_exists('user',$author_id ,'_vendor_slug')?get_user_meta($author_id ,'_vendor_slug',true):'';
      
      ?>
      <div class="vendor-details">
         <h4>Vendor Details</h4>
         <p class="wcmp_vendor_detail">
         <i class="fa fa-user"></i><label>&nbsp; Seller: <?php echo $seller; ?></label>
         <br/>
         <p class="wcmp_vendor_detail"><i class="fa fa-phone"></i><label>&nbsp;<?php echo $phone_no; ?></label></p>
         <p class="wcmp_vendor_detail"><i class="fa fa-map-marker"></i><label>&nbsp;<?php echo $location; ?></label></p>
         <p class="wcmp_vendor_detail"><i class="fa fa-envelope"></i><label>&nbsp;<?php if(!empty($email)) echo $email; ?></label></p>
         <p><a href="<?php echo $vendorLink ?>" class="vendor-link">See more items ></a></p>
         </p>
      </div>
      <?php
      }
      Copy
    • #93394
      damien
      Participant

      Hello!

      It works for me but 2 issues:

      – Fa Awesome icons didn’t display
      – Vendor link doesn’t work

      Code modified for our needs:

      <div class="vendor-details">
         <p class="wcmp_vendor_detail"><i class="fas fa-store"></i><label>&nbsp;Vendu par <?php echo $seller; ?> -> <a href="<?php echo $vendorLink ?>" class="vendor-link"> Accès à la boutique </a></label></p>
      </div>
      Copy

      Thanks for your help

    • #93402

      @damien, can you share the page link, so I can check.

    • #93424
      damien
      Participant
      This reply has been marked as private.
    • #93471
      This reply has been marked as private.
    • #95032
      sreya
      Moderator

      I presume this issue has been resolved, so I am closing this thread.

      If you need any further help, please do open another thread.

Viewing 8 reply threads

The topic ‘Show Vendor Details on Single Product Page’ is closed to new replies.

COVID-19 Outbreak: WCMp team is supporting business affected by coronavirus

Read the Message Buy at Slashed Price