• Resolved nordrium

    (@nordrium)


    Hello!
    I use your wonderful filter, but there is one problem.
    I am developing a theme for a website, for personal use, I wrote the code to determine what is displayed on the page, products or subcategories. Also, I use the condition of which template to display, depending on what is displayed on the page.
    And what’s the problem. After I select something in the filter and if I reload the page, an “Undefined variable $term” error appears
    Can you suggest how this can be fixed? I will provide code examples.

    Code to determine what is “on the screen” in functions.php

    function is_product_list_display_type( $term ) {
    	$taxonomy = 'product_cat';
    	if( ! term_exists( $term, $taxonomy ) )
    	return false;
    	if( ! is_numeric( $term ) )
    	$term = get_term_by( 'slug', sanitize_title( $term ), $taxonomy )->term_id;
    return get_term_meta( $term, 'display_type', true ) === 'products' ?  true : false;
    }

    Condition for choosing a template in taxonomy-produc-cat.php

    if(is_product_list_display_type( $term )){
    wc_get_template( 'archive-product-custom.php' ); 
    } elseif (is_subcategory_display_type( $term )) {
    	wc_get_template( 'archive-product-category.php' ); 
    } else {
    	wc_get_template( 'archive-product.php' );
    }

    Thanks you for help!

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Problem after reload page’ is closed to new replies.