• Resolved ibalabanov

    (@ibalabanov)


    Hello,

    I want to add a img hover functionality for the brand thumbnails and I need to add a class with brand slug to all pwb-brand links. Is this possible with some code in mmy functions.php?

    Your help will be highly appreciated.
    Thanks in advance.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor titodevera

    (@titodevera)

    Hi ibalabanov,

    You don′t need to add any extra classes for add the img hover effect.

    You can use the default classes, the css below is for brand logo on the single product page for example:

    
    .pwb-single-product-brands a{
      position: relative;
      display: inline-block;
    }
    
    .pwb-single-product-brands a::after{
      content: "";
      position: absolute;
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;
      background-color: rgba(0,0,0,.5);
      z-index: 1;
      display: none;
    }
    
    .pwb-single-product-brands a:hover::after{
      display: block;
    }
    

    ??

    Thread Starter ibalabanov

    (@ibalabanov)

    Yes. I did the same. But I need different images for each brand so I need an extra class to the anchor to load each brand its hover image

    Thread Starter ibalabanov

    (@ibalabanov)

    I did it when I use shortcode for both single product and brands in loop:

    function show_brands_in_loop(){
    if( $brands_in_loop !== ‘brand_link’ || $brands_in_loop !== ‘brand_image’ ){
    $brands_in_loop == ‘brand_image’;
    global $product;
    $brands = get_the_terms( $product->ID, ‘pwb-brand’);
    foreach( $brands as $brand ){ ?>

    <div class=”pwb-brands-in-loop <?php echo $brand->slug;?>”>

    <?php echo do_shortcode(‘[pwb-brand]’); ?>

    </div>
    <?php
    }
    }
    }
    add_action( ‘woocommerce_after_shop_loop_item_title’, ‘show_brands_in_loop’, 6 );

    and for single product:

    function undrwr_sp_brand(){
    global $product;
    $brands = get_the_terms( $product->ID, ‘pwb-brand’);
    foreach( $brands as $brand ){ ?>

    <div class=”pwb-single-product-brands pwb-clearfix <?php echo $brand->slug;?>”>

    <?php echo do_shortcode(‘[pwb-brand]’); ?>

    </div>
    <?php
    }
    }
    add_action( ‘woocommerce_single_product_summary’, ‘undrwr_sp_brand’, 6 );

    but I disabled both in admin options do prevent double rendering but because of

    if( $brands_in_loop == ‘brand_link’ || $brands_in_loop == ‘brand_image’ ){

    its not showing on shop page loop ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add a class with brand slug to all pwb-brand links’ is closed to new replies.