Compare / Wishlist issues with saving on page refresh

This topic has 21 replies, 3 voices, and was last updated 2 months, 1 weeks ago ago by Luca Rossi

  • Avatar: Niddy
    Niddy
    Participant
    September 14, 2025 at 13:59

    Hi

    On compare / wishlist (single product page) – if you add to wishlist or compare the text changes to whatever we set from within the settings of the widget – ie “Added to Wishlist / Remove from Wishlist” but when you’re on a product and let’s say the page refreshes; or they look around and come back – it reverts back to “Add to” instead of “Remove / View”.

    How can we resolve this so it remembers that you’ve added THAT SPECIFIC product, so upon a return to that same product in the same browser session, it remembers what was added?

    It’s kinda odd that it doesn’t allow more customisation and auto-flow as in –

    1. Add to ->
    2. Remove from ->
    3. View ->

    I could use js but surely if I can build a fix, I’m questioning why it’s not built-in?

    Example –

    jQuery(document).ready(function($){
    
        // --- Wishlist Button Handling ---
        $('.xstore-wishlist-btn').each(function(){
            var $btn = $(this);
            var productID = $btn.data('product-id');
    
            // Check if product is already in wishlist
            if (window.XStoreWishlist && window.XStoreWishlist.items && window.XStoreWishlist.items.includes(productID)) {
                $btn.text('Remove from Wishlist').addClass('added');
            }
        });
    
        // Wishlist click behavior: Add → Remove → View
        $('.xstore-wishlist-btn').on('click', function(e){
            e.preventDefault();
            var $btn = $(this);
            var productID = $btn.data('product-id');
    
            if (!$btn.hasClass('added')) {
                // Add to wishlist
                $btn.text('Remove from Wishlist').addClass('added');
            } else {
                // Remove from wishlist
                $btn.text('Add to Wishlist').removeClass('added');
            }
        });
    
        // --- Compare Button Handling ---
        $('.xstore-compare-btn').each(function(){
            var $btn = $(this);
            var productID = $btn.data('product-id');
    
            // Check if product is already in compare list
            if (window.XStoreCompare && window.XStoreCompare.items && window.XStoreCompare.items.includes(productID)) {
                $btn.text('View Compare').addClass('added');
            }
        });
    
        // Compare click behavior: Add → Remove → View
        $('.xstore-compare-btn').on('click', function(e){
            e.preventDefault();
            var $btn = $(this);
            var productID = $btn.data('product-id');
    
            if (!$btn.hasClass('added')) {
                $btn.text('Remove from Compare').addClass('added');
            } else {
                $btn.text('View Compare').addClass('added'); // or navigate to compare page if you want
            }
        });
    
    });
    20 Answers
    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    September 15, 2025 at 07:01

    Hello @Niddy,

    Thank you for reaching out.

    To better understand the issue, could you please confirm the following: when you add a product to your wishlist and then refresh the page, does the button display correctly? However, if you navigate using the browser’s back or forward buttons, does the button then display incorrect text?

    If possible, we kindly ask you to provide a short video demonstrating the issue. This will help us investigate the matter more effectively from our side.

    Best regards,
    The 8Theme Team

    Avatar: Niddy
    Niddy
    Participant
    September 15, 2025 at 09:10

    Hi

    Here you are – on one of your own demos – all I am doing is refreshing the page – the exact same happens on our site so it’s not our cache or anything, else yours would work fine – I have put the js fix above however wanted to avoid repairing your theme as it clearly needs addressing – so here’s the video showing when you add a wishlist / compare item then refresh – leave or come back = empties and reverts text back as if it was never added.

    Same issue regardless whether you refresh or go elsewhere on the site then return to the same product.

    Thanks

    Video -> https://we.tl/t-2UMxHB1mPA

    Avatar: Niddy
    Niddy
    Participant
    September 15, 2025 at 15:40

    Any update on this issue guys? 👍

    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    September 16, 2025 at 16:58

    Hello, Niddy

    To ensure you get the best support, we’re escalating your request to another specialist from our team, who will take a closer look at the issue.

    They will update you as soon as possible, and we’ll make sure to keep you posted. If you have any additional details that might help, feel free to reply here.

    Thank you for your cooperation!

    Best Regards,
    The 8Theme Team

    Avatar: Justin
    Luca Rossi
    Support staff
    September 22, 2025 at 16:03

    Dear @Niddy,

    Sorry for the late response!

    We would like to assist you with the issue you reported; however, it appears that the video you provided has been deleted.

    Could you kindly re-upload the video so that we can review it and provide the appropriate support?

    Thank you for your cooperation.

    Best regards,
    The 8Theme Team

    Avatar: Niddy
    Niddy
    Participant
    September 22, 2025 at 16:11

    Hi

    You really don’t need a video. Just go to any of your themes; but for reference I’m using Fashion Minimalist.

    Go to any product. Add to wishlist / compare list.

    The text changes. Agreed.

    Now. Hit page refresh. The text reverts back to default “Add to…” albeit it’s added.

    The session isn’t storing and saving your selection to add to wishlist or compare list.

    That’s the issue. Happens everywhere on product to quick view.

    Avatar: Justin
    Luca Rossi
    Support staff
    September 23, 2025 at 11:16

    Dear @Niddy,

    We hope this message finds you well.

    We would like to inform you that the primary issue appears to be that certain JavaScript events related to product variations are not being triggered when the product page initially loads.

    To address this, we kindly ask you to add the following custom JavaScript code to your site:

    
    jQuery(document).ready(function($) {
        function triggerVariationEvents() {
            var $form = $('.variations_form');
            
            if ($form.length) {
                // Trigger the main variation events
                $form.trigger('check_variations');
                $form.trigger('woocommerce_variation_select_change');
                
                // Also trigger on the document (some themes listen here)
                $(document).trigger('woocommerce_variation_select_change', [$form]);
                
                console.log('Variation events triggered');
            }
        }
        
        // Trigger after page load
        setTimeout(triggerVariationEvents, 500);
        
        // Also trigger when variations form is ready
        $('.variations_form').on('woocommerce_variation_form', function() {
            setTimeout(triggerVariationEvents, 100);
        });
    });
    

    Please implement this code and let us know if it resolves the issue. Should you require any further assistance, feel free to reach out.

    Best regards,
    The 8Theme Team

    Avatar: Niddy
    Niddy
    Participant
    September 23, 2025 at 11:31

    Hi

    That has no effect when you refresh the page – I have to create it into a function though – do you have a js element that we can drop raw js into to avoid this?

    I used –

    /**
     * Compare / Wishlist - Text Updating Fix
     */
    // Fix variation events for XStore Wishlist / Compare
    function my_variation_fix_script() {
        // Make sure jQuery is loaded first
        wp_add_inline_script('jquery-core', "
            (function($){
                function initVariationFix(){
                    function triggerVariationEvents(){
                        var \$form = $('.variations_form');
                        
                        if (\$form.length){
                            // Trigger the main variation events
                            \$form.trigger('check_variations');
                            \$form.trigger('woocommerce_variation_select_change');
    
                            // Also trigger on the document (some themes listen here)
                            $(document).trigger('woocommerce_variation_select_change', [\$form]);
    
                            console.log('Variation events triggered');
                        }
                    }
    
                    // Trigger after page load
                    setTimeout(triggerVariationEvents, 500);
    
                    // Also trigger when variations form is ready
                    $(document).on('woocommerce_variation_form', '.variations_form', function(){
                        setTimeout(triggerVariationEvents, 100);
                    });
                }
    
                // Run when DOM is ready
                $(document).ready(function(){
                    initVariationFix();
                });
            })(jQuery);
        ");
    }
    add_action('wp_enqueue_scripts', 'my_variation_fix_script');
    Avatar: Justin
    Luca Rossi
    Support staff
    September 23, 2025 at 18:03

    Hi @Niddy,

    Please try adding the following code under functions.php file locates in your child theme:

    
    add_action('wp_footer', 'n2t_wp_footer', 100);
    function n2t_wp_footer() {
        if(is_singular('product')) {
        ?>
        <script>
            jQuery(document).ready(function($) {
                function triggerVariationEvents() {
                    var $form = $('.variations_form');
    
                    if ($form.length) {
                        // Trigger the main variation events
                        $form.trigger('check_variations');
                        $form.trigger('woocommerce_variation_select_change');
    
                        // Also trigger on the document (some themes listen here)
                        $(document).trigger('woocommerce_variation_select_change', [$form]);
    
                        console.log('Variation events triggered');
                    }
                }
    
                // Trigger after page load
                setTimeout(triggerVariationEvents, 500);
    
                // Also trigger when variations form is ready
                $('.variations_form').on('woocommerce_variation_form', function() {
                    setTimeout(triggerVariationEvents, 100);
                });
            });
        </script>
        <?php
        }
    }
    

    Hope it helps!

    Avatar: Niddy
    Niddy
    Participant
    September 25, 2025 at 09:03

    Hi

    This has no effect – maybe test it on your own demo’s and you will see that it is a bigger issue that requires some investigation as it never saves the added items and just looks unprofessional to customers who add it but then see the “Add to…” text again instead of “View or Remove from…”.

    Can you please properly look into this as its clearly not my install as the same occurs on every single demo that the wishlist and compare is on.

    Thanks again

    Avatar: Justin
    Luca Rossi
    Support staff
    September 25, 2025 at 12:13

    Hi @Niddy,

    Could you please check again the product we’ve added in the Private Content Area?

    Thank you!

    Please contact administrator
    for this information.
    Avatar: Niddy
    Niddy
    Participant
    September 25, 2025 at 12:43

    Hi

    Yes it works perfectly on that product but only that product lol.

    So you’ve definitely sussed it out 🤞

    I’ll leave it with you. Thanks again.

    Sorry – can you please clarify the css or how I change the colour of the fancy hearts once added to wishlist – as seen on my site it is a black icon.

    Thanks

    Avatar: Justin
    Luca Rossi
    Support staff
    September 26, 2025 at 06:59

    Hello @Niddy,

    We have increased the timeout to ensure that all variations are fully loaded before the events are triggered.

    If you would like to change the heart/compare icon, you may use the following CSS code:

    
    .xstore-wishlist[data-action="remove"] .et-icon, 
    .xstore-compare[data-action="remove"] .et-icon {
        color: red !important;
    }
    

    Best regards,
    The 8Theme Team

    Avatar: Niddy
    Niddy
    Participant
    September 26, 2025 at 12:46

    Awesome thank you – so that is fixed on all products now presumably? Legend – appreciate your help.

    One other issue I have just encountered, with the Xstore checkout page not using the official woo checkout block, the google pay button does not render on checkout page (stripe payments – gpay button for android).

    I did add a fix (see below) but this only applies to the actual woo shortcode [woocommerce_checkout] and has no effect on Xstore.

    Any idea how to get the google / apple button to appear on checkout page please?

    The fix I tried which had no effect is –

    add_action('woocommerce_review_order_before_submit', function() {
        if (function_exists('wc_stripe_payment_request_button')) {
            wc_stripe_payment_request_button();
        }
    });

    Access via private – thanks.

    Please contact administrator
    for this information.
    Avatar: Justin
    Luca Rossi
    Support staff
    September 27, 2025 at 12:03

    Dear @Niddy,

    Could you please try the solution provided in the following link?

    https://www.8theme.com/topic/stripe-payment-options-are-not-available-on-checkout-page/#post-441073

    We are not certain which hook the Worldpay plugin is using.

    Best regards,
    8Theme Team

    Avatar: Niddy
    Niddy
    Participant
    September 27, 2025 at 12:23

    Hi

    Thats done it perfectly – thanks. Worldpay is only using the payment form – not wallet so plays no part however your fix sorted it.

    Can I just ask though, how do we get it to sit directly above the left side – as on your layout it is split in 2 columns on checkout, and this now looks silly right across the top of the page so wondered how we can align it to the same left block within Order Details so it keeps the width of that column?

    Thanks again – appreciate your help.

    Please contact administrator
    for this information.
    Avatar: Niddy
    Niddy
    Participant
    September 27, 2025 at 20:31

    Edit – I’ve fixed the positioning using js script.

    Just the query as to why both Apple & gpay show on iOS 👍

    Thanks

    Avatar: Justin
    Luca Rossi
    Support staff
    September 29, 2025 at 07:56

    Hi @Niddy,

    Could you kindly create a support ticket with Worldpay on our behalf?

    Our XStore is not generating the GPay or ApplePay button on the checkout page.

    Thank you very much.

    Best regards,
    8Theme Team

    Avatar: Niddy
    Niddy
    Participant
    September 29, 2025 at 08:16

    Hi

    No need as I already told you this is not Worldpay. The issue is Stipe – we use stripe to handle the wallets.

    Worldpay was disabled and the issue persists. When we disabled stripe, we seen no wallet buttons. The issue is stripe not Worldpay as wallets is not enabled on our Worldpay account.

    Thanks

    Avatar: Justin
    Luca Rossi
    Support staff
    September 29, 2025 at 08:26

    Hi @Niddy,

    Could you please contact the Stripe Support team at the following link: https://wordpress.org/support/plugin/woocommerce-gateway-stripe/?

    Thank you very much.

    Best regards,
    8Theme Team

  • Viewing 21 results - 1 through 21 (of 21 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.