Okay
  Public Ticket #2169892
Woocommerce Loop - Kalium function : "kalium_woocommerce_product_loop_categories_default_layout()"
Closed

Comments

  •  15
    hahni started the conversation

    Hello,

    i am asking for a problem with the named function "kalium_woocommerce_product_loop_categories_default_layout()" which is called from "kalium_woocommerce_product_loop_item_info()".

    I want to change some things in "kalium_woocommerce_product_loop_categories_default_layout()" and it works great and perfect.

    The customization of your function is here:

    //START FUNCTION

    if( !function_exists( kalium_woocommerce_product_loop_categories_default_layout ) ){
    function kalium_woocommerce_product_loop_categories_default_layout() {
    global $product;
    if ( get_data( 'shop_product_category_listing' ) ) {
    $classes = array( 'product-terms' );
    ?>
    <div <?php kalium_class_attr( $classes ); ?>>
    <?php if ( function_exists( 'GMP_get_primary_category_and_list' ) ) { echo GMP_get_primary_category_and_list ( $product->get_id(), ", ", FALSE ); } else { echo wc_get_product_category_list( $product->get_id() ); } ?>
    </div>
    <?php
    }
    }
    }

    //END FUNCTION

    All works! But it works only with normal pagination! When I change to infinite or infinite + auto scroll it seems that the function will not be called - I have only overwritten your function - so it seems that your function too will not be called and there seems to be a fallback to whatever???

    I dont need help by developing my function but I need the information why your function will not be called with infinite option or where is "another hook" or "place" where I should have to change something.

    If you are asking what I want to do with my function ->

    Normally your function generates a tag list with "wc_get_product_category_list( $product->get_id()", but I want to change the normal comma separated tag list with my function to:

    NORMAL:

    Amplifiers, DA-Converter, Streamer

    MY OUTPUT:

    Amplifiers (DA-Converter, Streamer)

    Only the primary category is the first and the other ones are in brackets

    It works perfect, but with infinite scroll option it works only for the first load and after scrolling it seems that the function will not be called.


    Regards André

  • [deleted] replied

    Hi André,

    If you overwrite a Kalium template function then you don't need to add the "function_exists" condition but only the function to overwrite so your function should be added like this (in child theme functions.php):

    https://d.pr/n/ebns8G

    I hope this will fix the issue, otherwise I can take further look in it.