Skip Navigation

[Resolved] Show Number of Items in Comparison Tool

This support ticket is created 4 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by jeleenC 4 years, 5 months ago.

Assisted by: Waqar.

Author
Posts
#1388515

Tell us what you are trying to do? Show number of posts added to comparison table. When users add an item to compare, it will say "X posts added to compare." It can be a button, text, or floating widget, anywhere as long as there's an indicator.

Is there any documentation that you are following? I already set up a comparison tool using this doc: https://toolset.com/learn/create-an-ecommerce-wordpress-site/product-comparison/

Is there a similar example that we can see? I want to achieve something similar to this demo: hidden link (I was planning on using this plugin but apparently it only works on WooCommerce)

What is the link to your site? The property comparison page on our website is hidden link?

#1388609

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting us and I'd be happy to assist.

To show the count of selected items for the comparison, you'll need to include some custom script.

For example, on the properties page, you can add the following HTML code, where you'd like to show this count:


<div class="compare-counter">
<span>0</span> post(s) added to compare.
</div>

Next, in your view's "JS editor" tab, you can include the following script, which will execute whenever the compare label for any property will be clicked and will update the count value in the span tag, based on the number of checked items:


jQuery( document ).ready(function() {
    // trigger when any compare label is clicked
    jQuery( ".list-compare-wrapper label.compare" ).click(function() {
        // get the count of selected checkboxes
        var count = jQuery(".list-compare-wrapper label.compare input:checked").length;
        // update the count text
        jQuery('.compare-counter span').text(count);
    });   
});

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1388619

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.