Ошибка реагирует на:
$product_term = get_term_by($product->id, 'pa_size');
Если код убрать то ошибки нету.
Текст ошибки: (This message was added in version 3.0.) in on line for more information.
Честно говоря, ничего не понял из-за чего, как, откуда эта ошибка?
Подскажите кто сталкивался, спасибо.
Код который вызывается в цикле get_template_part продуктов в index.php
code
<?php $product = wc_get_product(); ?>
<a href="<?php echo get_permalink(); ?>">
<?php if ( $product->is_type( 'variable' ) ) : ?>
<?php $variations = $product->get_available_variations();
foreach ($variations as $key => $value){
$regular_price = $value['display_regular_price'] . '.00';
$sale_price = $value['display_price'] . '.00';
$discount = round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 ); ?>
<div class="product-item">
<div class="product-item__img-box">
<?php if ($sale_price != ''): ?>
<span class="product-item__img-discount"><?php echo '-' . $discount . ' %' ?></span>
<?php endif; ?>
<img src="<?php echo the_post_thumbnail_url( 'full-size' ); ?>" alt="">
</div>
<p class="product-item__price">
<?php if ($sale_price == ''): ?>
<?php echo "<span class='product-item__price-original'>" . $regular_price . " €</span>" ?>
<?php elseif ($sale_price != ''): ?>
<?php echo "<span class='product-item__price-sale'>" . $sale_price . " €</span>" . "<span class='product-item__price-regular'>" .$regular_price . " €</span>"?>
<?php endif; ?>
</p>
<p class="product-item__title"><?php the_title(); ?></p>
<div class="product-item--hover-items">
<?php
foreach( $value['attributes'] as $variation_attribute => $term_slug ){
$taxonomy = 'pa_size';
$term_name = get_term_by( 'slug', $term_slug, $taxonomy )->name;
echo "<span class='product-item--hover-item'>" . $term_name . "</span>";
}
?>
</div>
</div>
<?php break; ?>
<?php } ?>
<?php else: ?>
<?php
$regular_price = $product->get_regular_price();
$sale_price = $product->get_sale_price();
if ($regular_price && $sale_price){
$discount = round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
}
//
$product_term = get_term_by($product->get_id, 'pa_size');
?>
<div class="product-item">
<div class="product-item__img-box">
<?php if ($sale_price != ''): ?>
<span class="product-item__img-discount"><?php echo '-' . $discount . ' %' ?></span>
<?php endif; ?>
<img src="<?php echo the_post_thumbnail_url( 'full-size' ); ?>" alt="">
</div>
<p class="product-item__price">
<?php if ($sale_price == ''): ?>
<?php echo "<span class='product-item__price-original'>" . $regular_price . " €</span>" ?>
<?php elseif ($sale_price != ''): ?>
<?php echo "<span class='product-item__price-sale'>" . $sale_price . " €</span>" . "<span class='product-item__price-regular'>" .$regular_price . " €</span>"?>
<?php endif; ?>
</p>
<p class="product-item__title"><?php the_title(); ?></p>
<div class="product-item--hover-items">
<?php if ($product_term): ?>
<?php foreach ( $product_term as $product_terms ) { echo "<span class='product-item--hover-item'>" . $product_terms->name . "</span>"; } ?>
<?php else: ?>
<?php echo "<span class='product-item--hover-item'>All size</span>"?>
<?php endif ?>
</div>
</div>
<?php endif; ?>
</a>