Answer the question
In order to leave comments, you need to log in
How to get count values in yith-compare?
Good evening.
There is a plugin YITH-Compare
And with it, as you know, you can compare products.
But it doesn't have a built-in counter function.
For example, the wishlist has.
<?php $wishlist_count = YITH_WCWL()->count_products();
echo $wishlist_count; ?>
<?php $compare_count = YITH_Woocompare()->count_products();
echo $compare_count; ?>
<?php global $yith_woocompare;
echo $yith_woocompare->obj->list_products_html(); ?>
foreach ( $this->products_list as $product_id ) {
$product = $this->wc_get_product( $product_id );
if ( ! $product )
continue;
?>
<a class="title" href="<?php echo get_permalink( $product_id ) ?>"><?php echo $product->get_title() ?></a>
<a href="<?php echo $this->remove_product_url( $product_id ) ?>" data-product_id="<?php echo $product_id; ?>" class="remove" title="<?php _e( 'Remove', 'yith-woocommerce-compare' ) ?>">x</a>
Answer the question
In order to leave comments, you need to log in
Happened! Who cares how to make a comparison counter in Woocommerce?
We need the YITH WooCommerce Compare
plugin
1. Open the class.yith-woocompare-frontend.php file (path: plugins/yith-woocommerce-compare-premium/includes)
2. Edit line 701. Delete everything from 701 to 711.
foreach ( $this->products_list as $product_id ) {
$product = $this->wc_get_product( $product_id );
if ( ! $product )
continue;
?>
<li>
<a class="title" href="<?php echo get_permalink( $product_id ) ?>"><?php echo $product->get_title() ?></a>
<a href="<?php echo $this->remove_product_url( $product_id ) ?>" data-product_id="<?php echo $product_id; ?>" class="remove" title="<?php _e( 'Remove', 'yith-woocommerce-compare' ) ?>">x</a>
</li>
<?php
}
$count = 0;
foreach ( $this->products_list as $product_id ) {
$product = $this->wc_get_product( $product_id );
$count++;
}
echo $count;
return ob_get_clean();
}
<?php global $yith_woocompare;
echo $yith_woocompare->obj->list_products_html(); ?>
<li class="user-btn__item">
<a class="user-btn__link" href="/compare/">
<span class="hidden-md-down hidden-sm-down user-btn__name">Сравнение</span>
<span class="user-btn__icon fa fa-balance-scale user-btn__icon--compare">
<span class="user-btn__number"><?php global $yith_woocompare;
echo $yith_woocompare->obj->list_products_html(); ?></span> <!-- тут выводим значение -->
</span>
</a>
</li>
At the same time, you need to disable the annoying update notification system. Light a candle for the rest of the site in the church. And add "Professional Site Fighter" in your signature.
The first rule of the WordPress world is don't change the core and third party code. Read, touch, but don't change.
You can just read, copy, make a neat shortcode and stick it where you need it. Nothing will break. And everything will be according to the code.
Otherwise, those who, after such maneuvers, accept sites for maintenance, run into such planted bombings, then shed crocodile tears and cover the authors of these maneuvers with a good obscenity. And in general for karma it is bad.
* As a morning humor :)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question