• Resolved niclamarino

    (@niclamarino)


    Hi,
    I have all the lastest product displayed in Homepage, I’d like the “Sold by VENDORNAME” to be displayed BEFORE the product title. Is that possible?

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Dualcube

    (@dualcube)

    Hi, in order to display the Sold By Vendor_Name, first remove that from the current place usinng this code:

    global $WCMp;
    remove_action('woocommerce_product_meta_start', array($WCMp->vendor_caps, 'wcmp_after_add_to_cart_form'), 25);

    Now, use this hook woocommerce_single_product_summary to call the same functionality to display Sold By Name before product title.

    Let us know if you need any further support.

    Thread Starter niclamarino

    (@niclamarino)

    Hi, thanks for the reply, I’ve tried but it doesn’t work…
    I’ve added the code to functions.php and then added the hook to my page template file but no changes. I am newbie with php so I am not sure if everything is correct. Am I doing anything wrong?

    Dualcube

    (@dualcube)

    Hello @niclamarino,

    You need to write the code against the hook woocommerce_single_product_summary.

    If you will not be able to that, give us some time, we will be able to share the exact code.

    Thread Starter niclamarino

    (@niclamarino)

    Hi,
    if it’s not an issue I’d like to get the exact code as I said I am a newbie.

    So I’ll explain what I’d like to do:

    So I’ve a slideshow on my homepage which displays the products using this code:

    				$args = array(
    					'post_type' => 'product',
    					'posts_per_page' => 8
    				);
    				$loop = new WP_Query( $args );
    				if ( $loop->have_posts() ) {
    					while ( $loop->have_posts() ) : $loop->the_post();
    						woocommerce_get_template_part( 'content', 'product' );
    					
    					endwhile;
    				} else {
    					echo __( 'No products found' );
    				}
    				wp_reset_postdata();
    				?>		

    I’d like to add the Vendor’s name before the Product title. At the moment, on the products archieve it’s exactly like that (Vendor’s name before the Product). So, my issue is with this slideshow I have on the homepage.

    Many thanks

    Dualcube

    (@dualcube)

    @niclamarino As you are using woocommerce_get_template_part( ‘content’, ‘product’ ); within your while loop, this means in each loop call, your function is calling woocommerce content-product.php. So if you view woocommerce-> templates->content-product.php, you will find the respective hooks and filters.

    Here is the code snippet for you-

    function add_wcmp_vendor_name(){
        global $product;
        if($product && class_exists('WCMp')){
            $vendor = get_wcmp_product_vendors($product->get_id());
            if($vendor){
                $sold_by_text = apply_filters('wcmp_sold_by_text', __('Sold By', 'dc-woocommerce-multi-vendor'), $product->get_id());
                echo '<a class="by-vendor-name-link" style="display: block;" href="' . $vendor->permalink . '">' . $sold_by_text . ' ' . $vendor->user_data->display_name . '</a>';
            }
        }
    }
    add_action('woocommerce_shop_loop_item_title', 'add_wcmp_vendor_name', 5);
    Thread Starter niclamarino

    (@niclamarino)

    Hello, thanks for your help but unfortunately it still doesn’t work :/
    I’ve tried adding the snippet to my homepage.php and nothing is shown…and adding it to my functions and no changes.

    itzmekhokan

    (@itzmekhokan)

    @niclamarino you have to add the above code snippet to your active theme’s functions.php to work.

    Thread Starter niclamarino

    (@niclamarino)

    @itzmekhokan I added the whole code to my functions.php but the Vendor’s name is still displayed below the Product name

    Dualcube

    (@dualcube)

    In that case this might be happening, your theme using the same action woocommerce_shop_loop_item_title with priority lesser than 5. That’s why our code is not working. Kindly check that and assign a lower priority to make it working.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Move “Sold by” position in product list’ is closed to new replies.