Okay
  Public Ticket #2386272
Link in catalog view
Closed

Comments

  •  5
    bosal started the conversation

    Also can you help me with something else, a I need a simple function to child theme for the Product Catalog page https://zbawcy.pl/katalog

    As we are removing the producer name from the Title and we are moving it to attribute pa_producent we would like to display the title (in the catalog as I managed to do it on a single page already) as:

    <h4>Attribute Manufacturer (pa_producent)</h4>

    <h3>product title</h3>

  • [deleted] replied

    Hi bosal,

    You can add this code in functions.php:

    function _show_producer_brand_name_shop_loop() {
        global $product;
        $pa_producent = $product->get_attribute( 'pa_producent' );
        if ( ! $pa_producent ) {
            return;
        }
        ?>
        <span class="brand-name"><?php echo $pa_producent; ?></span>
        <?php
    }
    add_action( 'kalium_woocommerce_product_loop_after_title', '_show_producer_brand_name_shop_loop' );



    This will display span.brand-name  element if its not empty.

  •  5
    bosal replied

    It's almost perfect but how to:

    display this attribute inside the a <h3> tag so it would be coresponding with the single page like here:

    https://zbawcy.pl/produkt/feudi-salentini-la-torre-primitivo/

  • [deleted] replied

    I understand it, please remove the previous code and replace with this:

    add_filter( 'the_title', function( $title ) {
        global $product;
        if ( $product instanceof WC_Product && $product->get_id() !== get_queried_object_id() && $product->get_title() === $title ) {
            $pa_producent = $product->get_attribute( 'pa_producent' );
            if ( $pa_producent ) {
                $title = sprintf( '<span class="head-producent">%s</span>%s', $pa_producent, $title );
            }
        }
        return $title;
    } );
    
    This will prepend producer before product title and also include in the tag you use in Single Product page.

  •  5
    bosal replied

    ok, great this works for me

  •  5
    bosal replied

    Hmm, it works well but it also shows the html in the admin product view, how to avoid that ? attachment

  • [deleted] replied

    Hi bosal,

    I have added an extra check to avoid this happening in admin panel:

    add_filter( 'the_title', function( $title ) {
        global $product;
        if ( ! ( is_admin() && ! defined( 'DOING_AJAX' ) ) && $product instanceof WC_Product && $product->get_id() !== get_queried_object_id() && $product->get_title() === $title ) {
            $pa_producent = $product->get_attribute( 'pa_producent' );
            if ( $pa_producent ) {
                $title = sprintf( '<span class="head-producent">%s</span>%s', $pa_producent, $title );
            }
        }
        return $title;
    } );
    
    This shoukd work for you.

  •  5
    bosal replied

    Hi can you please help me with the css to the site: 

    https://zbawcy.pl/katalog

    Under the product title: - show rating if there is one

    On hover on product I would like to:

    - the image to have less opacity (to be mroe white) - show attribute (every in new line, clickable):  --Kraj (country) https://zbawcy.pl/cecha/kraj/hiszpania/ --Style  https://zbawcy.pl/cecha/smak-styl/polslodkie

    https://zbawcy.pl/produkt/castillo-de-maetierra-libalis-frizz-55/

    Change the styling of recommended and simillar products to clear as the images are smaller. So on hover show solid background and details of the product and before hover just the image.

  • [deleted] replied

    Hi  bosal,

    You can add this code in functions.php to show product rating below title:

    https://d.pr/n/Jfqp15

    The styling of it is up to you because that is outside of support scope and its considered customization.

    P.S: If you're looking for professional help in this matter, there's always someone available for such tasks on Codeable website. Pricing and timeline are always straightforward there and that's the main reason for recommending those services.

  •  5
    bosal replied

    Ok thank you:

    what about showing additional items on catalog view on item hover like additional product attributes ?

    Also what are the template placments for kalium like: kalium_woocommerce_product_loop_after_title where can I find this ?

    Also how to show price on this list without hovering on the item ? https://zbawcy.pl/katalog 

  • [deleted] replied

    Hi bosal,

    Yes that hook will show additional if you assign hooks on "kalium_woocommerce_product_loop_after_title". All that matters is to make the container opacity (of item you add) initially zero then on hover of product show that element opacity to 1.

    "kalium_woocommerce_product_loop_after_title" is contained in kalium/includes/functions/template/woocommerce-template-functions.php in few places based on product layout for listing page.

  •  5
    bosal replied

    How about the rest of my question - how to add other attritubutes to the on hover under title links view ?

  • [deleted] replied

    I've explained, to add attributes on that hook simply assign a function:

    add_action( 'kalium_woocommerce_product_loop_after_title', function() {
        // Code to show attributes
    } );

    So its up to you how do you want to show attributes and the markup structure.

    A topic regarding WC Attributes to show programmatically can be found here:

    https://stackoverflow.com/questions/41772206/how-to-display-wordpress-woocommerce-custom-attribute-in-templates-functions

    Example:

    // Get a product instance. I could pass in an ID here.
    // I'm leaving empty to get the current product.
    $product = wc_get_product();
    // Output fabrics in a list separated by commas.
    echo $product->get_attribute( 'pa_fabrics' );
    // Now that I have $product, I could output other attributes as well.
    echo $product->get_attribute( 'pa_colors' );
    
  •  5
    bosal replied

    Arlind, 

    great but... :)

    I would like to show the additional attributes on hover like now is the category:

    https://zbawcy.pl/katalog

    Wha't the action name for that ?

  • [deleted] replied

    Hi bosal,

    In your case, this is the code executed for transparent background layout:

    medium
    (view large image)

    The hook you can attach your custom code is named "kalium_woocommerce_product_loop_after_title"

    However, if you want to completely modify the markup then:

    1. Open wp-content/themes/kalium/includes/functions/template/woocommerce-template-functions.php

    2. Copy the function "kalium_woocommerce_product_loop_item_info" from line 577-735

    3. Paste the copied function in functions.php of child theme and add your changes to it.

    As I mentioned above this code is executed when transparent background layout is used:

    medium
    (view large image)

  •  5
    bosal replied

    Manage to make it smoothly with your instructions :)

  • [deleted] replied

    Happy to hear that!

    Have a nice day.

    Will mark this ticket as solved from here