fbpx
-50% OFF Black Friday coupon: BF2021

Critical Error in Product Template Edit

HomeTopicsSupport forumCritical Error in Product Template Edit
Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #16794
    Avatar
    Devrental
    Participant

    Hi , recently i am facing Critical Error in Product Template Editor in two of my website . Both of them were running fine.

    https://prnt.sc/1vbto51

    #16796
    Artem Temos
    Artem Temos
    Keymaster

    Hello,

    Try to add the following PHP code snippet to the child theme functions.php file to fix this

    function xts_get_product_attributes_labels() {
    	global $product;
    
    	if ( empty( $product ) || ! is_object( $product ) ) {
    		return;
    	}
    
    	$attributes = $product->get_attributes();
    
    	ob_start();
    
    	foreach ( $attributes as $attribute ) {
    		if ( ! isset( $attribute['name'] ) ) {
    			continue;
    		}
    
    		$show_attr_on_product = get_option( 'xts_' . $attribute['name'] . '_show_on_product' );
    
    		if ( 'on' === $show_attr_on_product ) {
    			$terms = wc_get_product_terms( $product->get_id(), $attribute['name'], array( 'fields' => 'all' ) );
    
    			foreach ( $terms as $term ) {
    				$classes   = '';
    				$content   = $term->name;
    				$image     = get_term_meta( $term->term_id, '_xts_attribute_image', true );
    				$image_url = wp_get_attachment_image_url( $image['id'] );
    
    				$classes .= ' xts-term-' . $term->slug;
    				$classes .= ' xts-attribute-' . $attribute['name'];
    
    				if ( $image_url ) {
    					$classes .= ' xts-with-img';
    					$content  = apply_filters( 'xts_image', '<img src="' . esc_url( $image_url ) . '" title="' . esc_attr( $term->slug ) . '" alt="' . esc_attr( $term->slug ) . '" />' );
    				}
    
    				?>
    				<span class="xts-attribute-label xts-product-label<?php echo esc_attr( $classes ); ?>">
    						<?php echo wp_kses( $content, 'xts_media' ); ?>
    					</span>
    				<?php
    
    			}
    		}
    	}
    
    	return ob_get_clean();
    }

    Kind Regards

    • This reply was modified 1 month, 2 weeks ago by Artem TemosArtem Temos.
    #16815
    Avatar
    Devrental
    Participant

    Hi ,

    I have added . But same Problem persists .

    #16817
    Artem Temos
    Artem Temos
    Keymaster

    Try to select some product in Theme Settings to be used for the product builder https://monosnap.com/file/1dOiaq3yt5YpM5QUfdpak3nWdaqtcg

    #16826
    Avatar
    rrogers
    Participant

    I continue to get the following notice on this “function xts_get_product_attributes_labels” even after updating the code:

    Illegal string offset ‘id’ /framework/integration/woocommerce/template-tags/global.php:310
    xts_get_product_attributes_labels()

    Uninitialized string offset: 0 1
    framework/integration/woocommerce/template-tags/global.php:310

    Thanks!

    • This reply was modified 1 month, 2 weeks ago by Avatarrrogers.
    #16828
    Avatar
    rrogers
    Participant

    I forgot to mention that I get the notice on the “domain.com/shop” but not on the category product page, for example: domain.com/product-category/category1/category2

    #16829
    Avatar
    rrogers
    Participant

    and on “domain.com/shop/category1/category2” single product page as well

    #16832
    Artem Temos
    Artem Temos
    Keymaster

    Hello,

    Could you please send us a screenshot of where do you see these errors now?

    #16841
    Avatar
    rrogers
    Participant

    Here is the file

    • This reply was modified 1 month, 2 weeks ago by Avatarrrogers.
    Attachments:
    You must be logged in to view attached files.
    #16847
    Artem Temos
    Artem Temos
    Keymaster

    Please, update the theme to the last version that was just released – 1.2.1

    #16848
    Avatar
    rrogers
    Participant

    Hi there,

    Unfortunately the warning persisted. So I fixed it like this:

    line 274 framework/integration/woocommerce/template-tags/global.php

    $image_url = ! empty( $image ) ? wp_get_attachment_image_url( $image['id'] ) : '';

    Now everything works

    Thanks

    #16849
    Artem Temos
    Artem Temos
    Keymaster

    Sorry for the inconvenience. You are right, there is one more issue there. We will fix it in our next update too.

Viewing 12 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.

Sign in

No account yet?

Create an Account