• Resolved Sania Syed

    (@saniasyed)


    I am working on a store in woocommerce. In the store, products button ‘Add to cart” does not changes to “Added to cart” immediately and changes after refreshing the page. I think it may be the woocommerce plugin cache causing it. I do not use any plugins for cache clearance. I want to clear the cache in woocommerce plugin manually.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Hello,

    Could you please share a copy of your site’s System Status? You can find it via WooCommerce > Status. Select “Get system report” and then “Copy for support”.? Once you’ve done that, paste it here in your response.

    Thread Starter Sania Syed

    (@saniasyed)

    
    ### WordPress Environment ###
    
    WordPress address (URL): https://gulqualitystore.com
    Site address (URL): https://gulqualitystore.com
    WC Version: 5.4.1
    REST API Version: ? 5.4.1
    WC Blocks Version: ? 5.1.0
    Action Scheduler Version: ? 3.1.6
    WC Admin Version: ? 2.3.1
    Log Directory Writable: ?
    WP Version: 5.7.2
    WP Multisite: –
    WP Memory Limit: 256 MB
    WP Debug Mode: –
    WP Cron: ?
    Language: en_US
    External object cache: –
    
    ### Server Environment ###
    
    Server Info: Apache
    PHP Version: 7.3.12
    PHP Post Max Size: 33 MB
    PHP Time Limit: 30
    PHP Max Input Vars: 1000
    cURL Version: 7.45.0
    OpenSSL/1.0.1e
    
    SUHOSIN Installed: –
    MySQL Version: 5.7.26-29-log
    Max Upload Size: 33 MB
    Default Timezone is UTC: ?
    fsockopen/cURL: ?
    SoapClient: ?
    DOMDocument: ?
    GZip: ?
    Multibyte String: ?
    Remote Post: ?
    Remote Get: ?
    
    ### Database ###
    
    WC Database Version: 5.4.1
    WC Database Prefix: wp_y26xj31sz7_
    Total Database Size: 9.60MB
    Database Data Size: 7.57MB
    Database Index Size: 2.03MB
    wp_y26xj31sz7_woocommerce_sessions: Data: 1.52MB + Index: 0.05MB + Engine InnoDB
    wp_y26xj31sz7_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wp_y26xj31sz7_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    wp_y26xj31sz7_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
    wp_y26xj31sz7_woocommerce_order_items: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    wp_y26xj31sz7_woocommerce_order_itemmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wp_y26xj31sz7_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
    wp_y26xj31sz7_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wp_y26xj31sz7_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
    wp_y26xj31sz7_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wp_y26xj31sz7_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
    wp_y26xj31sz7_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    wp_y26xj31sz7_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wp_y26xj31sz7_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    wp_y26xj31sz7_actionscheduler_actions: Data: 0.02MB + Index: 0.11MB + Engine InnoDB
    wp_y26xj31sz7_actionscheduler_claims: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    wp_y26xj31sz7_actionscheduler_groups: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    wp_y26xj31sz7_actionscheduler_logs: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wp_y26xj31sz7_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wp_y26xj31sz7_comments: Data: 0.02MB + Index: 0.09MB + Engine InnoDB
    wp_y26xj31sz7_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    wp_y26xj31sz7_options: Data: 2.08MB + Index: 0.11MB + Engine InnoDB
    wp_y26xj31sz7_postmeta: Data: 1.52MB + Index: 0.28MB + Engine InnoDB
    wp_y26xj31sz7_posts: Data: 1.52MB + Index: 0.14MB + Engine InnoDB
    wp_y26xj31sz7_termmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wp_y26xj31sz7_terms: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wp_y26xj31sz7_term_relationships: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    wp_y26xj31sz7_term_taxonomy: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wp_y26xj31sz7_usermeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wp_y26xj31sz7_users: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
    wp_y26xj31sz7_wc_admin_notes: Data: 0.05MB + Index: 0.00MB + Engine InnoDB
    wp_y26xj31sz7_wc_admin_note_actions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    wp_y26xj31sz7_wc_category_lookup: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
    wp_y26xj31sz7_wc_customer_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wp_y26xj31sz7_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wp_y26xj31sz7_wc_order_coupon_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wp_y26xj31sz7_wc_order_product_lookup: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
    wp_y26xj31sz7_wc_order_stats: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
    wp_y26xj31sz7_wc_order_tax_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wp_y26xj31sz7_wc_product_meta_lookup: Data: 0.02MB + Index: 0.09MB + Engine InnoDB
    wp_y26xj31sz7_wc_reserved_stock: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
    wp_y26xj31sz7_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    wp_y26xj31sz7_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    wp_y26xj31sz7_wpfm_backup: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
    wp_y26xj31sz7_yoast_indexable: Data: 0.02MB + Index: 0.08MB + Engine InnoDB
    wp_y26xj31sz7_yoast_indexable_hierarchy: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
    wp_y26xj31sz7_yoast_migrations: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    wp_y26xj31sz7_yoast_primary_term: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wp_y26xj31sz7_yoast_seo_links: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    
    ### Post Type Counts ###
    
    attachment: 241
    custom_css: 2
    customize_changeset: 17
    et_body_layout: 4
    et_footer_layout: 1
    et_header_layout: 2
    et_pb_layout: 2
    et_template: 18
    et_theme_builder: 7
    nav_menu_item: 6
    page: 7
    post: 2
    product: 48
    revision: 368
    
    ### Security ###
    
    Secure connection (HTTPS): ?
    Hide errors from visitors: ?
    
    ### Active Plugins (3) ###
    
    UpdraftPlus - Backup/Restore: by UpdraftPlus.Com
    DavidAnderson – 1.16.56
    
    WooCommerce Payments: by Automattic – 2.6.0
    WooCommerce: by Automattic – 5.4.1
    
    ### Inactive Plugins (0) ###
    
    ### Dropin Plugins (1) ###
    
    object-cache.php: APCu Object Cache
    
    ### Must Use Plugins (1) ###
    
    System Plugin: by  – 4.6.5
    
    ### Settings ###
    
    API Enabled: –
    Force SSL: –
    Currency: USD ($)
    Currency Position: left
    Thousand Separator: ,
    Decimal Separator: .
    Number of Decimals: 2
    Taxonomies: Product Types: external (external)
    grouped (grouped)
    simple (simple)
    variable (variable)
    
    Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)
    exclude-from-search (exclude-from-search)
    featured (featured)
    outofstock (outofstock)
    rated-1 (rated-1)
    rated-2 (rated-2)
    rated-3 (rated-3)
    rated-4 (rated-4)
    rated-5 (rated-5)
    
    Connected to WooCommerce.com: –
    
    ### WC Pages ###
    
    Shop base: #70 - /shop/
    Cart: #71 - /cart-2/
    Checkout: #72 - /checkout-2/
    My account: #73 - /my-account/
    Terms and conditions: ? Page not set
    
    ### Theme ###
    
    Name: Divi Child Theme
    Version: 1.0.0
    Author URL: https://divilife.com
    Child Theme: ?
    Parent Theme Name: Divi
    Parent Theme Version: 4.9.7
    Parent Theme Author URL: https://www.elegantthemes.com
    WooCommerce Support: ?
    
    ### Templates ###
    
    Overrides: –
    
    ### Action Scheduler ###
    
    Complete: 8
    Oldest: 2021-05-29 12:11:27 +0000
    Newest: 2021-06-27 08:28:05 +0000
    
    ### Status report information ###
    
    Generated at: 2021-06-28 12:07:37 +00:00
    
    Plugin Support AW a11n

    (@slash1andy)

    Automattic Happiness Engineer

    Hey there!

    There is not any cache that is a part of WooCommerce. This would all be handled by your hosting service, or through a plugin/configuration on your WordPress site.

    It looks like your hosting has one setup here: object-cache.php: APCu Object Cache

    I would recommend checking with them on this.

    Thread Starter Sania Syed

    (@saniasyed)

    I have already cleared the cache on the server site. Its clear the problem is not with the cache but it was the coding. Since I am not expert in PHP coding I will need help with on-click button function, on clicking the button ‘Add to Cart’ it will change into ‘Added to Cart’. I will really appreciate your help. Thank You.

    Plugin Support AW a11n

    (@slash1andy)

    Automattic Happiness Engineer

    Hey again!

    If you’re looking to change the text after clicking on a button, this is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Thread Starter Sania Syed

    (@saniasyed)

    Ok. Thank you for your help !

    Mirko P.

    (@rainfallnixfig)

    Hi @saniasyed,

    In addition to what was already mentioned here by my colleagues, I’d like to point you to this Stack Overflow question where the most voted answer provides snippets that could help you achieve that.

    I’ve tried the snippets on one of my WooCommerce test sites and it’s working:

    Before –


    Link to image: https://bit.ly/3e9JNVR

    After –


    Link to image: https://bit.ly/3kcUpr3

    Hope this helps.

    Thread Starter Sania Syed

    (@saniasyed)

    Hi.
    I tried the snippets but the button text changes only after refreshing the page. I want it to change live at the same time.
    Thank You.

    Thread Starter Sania Syed

    (@saniasyed)

    The second answer with 0 votes worked, it worked only on the product page and as clicking on the button ‘the page refreshed it self’ and the text changed. Is there any way of doing it without getting the page refreshed itself and getting the results.
    Thank You,
    Sania.

    Mirko P.

    (@rainfallnixfig)

    Hi again,

    I’ve double-checked both snippets I’ve used for this and they’re working smoothly on my test site without refreshing the page:

    
    add_filter( 'woocommerce_product_add_to_cart_text', 'customizing_add_to_cart_button_text', 10, 2 );
    add_filter( 'woocommerce_product_single_add_to_cart_text', 'customizing_add_to_cart_button_text', 10, 2 );
    function customizing_add_to_cart_button_text( $button_text, $product )
    {
        $is_in_cart = false;
    
        foreach ( WC()->cart->get_cart() as $cart_item )
           if ( $cart_item['product_id'] == $product->get_id() ) {
               $is_in_cart = true;
               break;
           }
    
        if( $is_in_cart )
            $button_text = __( 'Added to cart', 'woocommerce' );
    
        return $button_text;
    }
    

    
    add_action('wp_footer','custom_jquery_add_to_cart_script');
    function custom_jquery_add_to_cart_script(){
        if ( is_shop() || is_product_category() || is_product_tag() ): // Only for archives pages
            $new_text = __( 'Added to cart', 'woocommerce' );
            ?>
                <script type="text/javascript">
                    // Ready state
                    (function($){
                        $('a.add_to_cart_button').click( function(){
                            $this = $(this);
                            $( document.body ).on( 'added_to_cart', function(){
                                $($this).text('<?php echo $new_text; ?>');
                                console.log('EVENT: added_to_cart');
                            });
                        });
    
                    })(jQuery); // "jQuery" Working with WP (added the $ alias as argument)
                </script>
            <?php
        endif;
    }
    

    If those snippets are still not working for you, I’d suggest reaching out to a web developer or customization expert that can take a look and fix it for you. Kindly note this forum is more focused on the default functions packaged with the core WooCommerce plugin.

    Thanks.

    Mirko P.

    (@rainfallnixfig)

    Hi there,

    We’ve not heard back from you in a while so I’ll go ahead and mark this thread as resolved. I hope you will find the above information useful.

    Please feel free to create a new thread if you have further questions about the WooCommerce core plugin.

    Thanks.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘how to clear the cache of woocommerce plugin’ is closed to new replies.