-
AuthorPosts
-
August 15, 2018 at 2:37 pm #997562
Hi,
Do you have any nice snippet to remove/hide update cart button on cart page of woocommerce shop .
And to make it so that if you change quantity price etc. will be automatically updated.I found page that has CSS code to hide update cart button and also code for function.php to make total price etc. update when you change the quantity. CSS code didnt work at all. PHP code worked almost but still you need to click on quantity number box to make it update so it wont update just by clicking – or +.
Here is link: https://businessbloomer.com/woocommerce-automatically-update-cart-quantity-change/Any tips how to solve this?
Thanks.
August 15, 2018 at 3:18 pm #997571Hi,
I already solved that php part, do you think its okay ( check the code below)? I am not even on beginner level in coding anything. Anyway now i need to hide that update cart button ( now ” päivitä ostoskori”). Notice because of this code i need to hide it not remove totally.
/** * @snippet Automatically Update Cart on Quantity Change - WooCommerce * @how-to Watch tutorial @ https://businessbloomer.com/?p=19055 * @sourcecode https://businessbloomer.com/?p=73470 * @author Rodolfo Melogli * @compatible Woo 3.4 */ add_action( 'wp_footer', 'bbloomer_cart_refresh_update_qty' ); function bbloomer_cart_refresh_update_qty() { if (is_cart()) { ?> <script type="text/javascript"> jQuery('div.woocommerce').on('click', 'input.qty', function(){ jQuery("[name='update_cart']").trigger("click"); }); </script> if (is_cart()) { ?> <script type="text/javascript"> jQuery('div.woocommerce').on('click', 'input.plus', function(){ jQuery("[name='update_cart']").trigger("click"); }); </script> if (is_cart()) { ?> <script type="text/javascript"> jQuery('div.woocommerce').on('click', 'input.minus', function(){ jQuery("[name='update_cart']").trigger("click"); }); </script> <?php } }
August 16, 2018 at 9:10 am #997858Hi,
Thank you for using Enfold.
I don’t think this is a good idea because the page will refresh or load an AJAX request each time the product quantity is changed. Users will have to wait for the ajax request to finish before they can increase the quantity again. If you really want to implement it, replace the script with this one.
/** * @snippet Automatically Update Cart on Quantity Change - WooCommerce * @how-to Watch tutorial @ https://businessbloomer.com/?p=19055 * @sourcecode https://businessbloomer.com/?p=73470 * @author Rodolfo Melogli * @compatible Woo 3.4 */ add_action( 'wp_footer', 'ava_cart_refresh_update_qty', 9999 ); function ava_cart_refresh_update_qty() { if (is_cart()) { ?> <script type="text/javascript"> (function($) { var triggerUpdate = function() { $('.woocommerce-cart-form .quantity').on('click', '.qty, .plus, .minus', function(){ console.log('test'); $("button[name='update_cart']").trigger("click"); }); } triggerUpdate(); $(document).ajaxComplete(function() { triggerUpdate(); }); })(jQuery); </script> <?php } }
And then use this css code to hide the update button.
button[name='update_cart'] { display: none !important; }
Best regards,
IsmaelAugust 20, 2018 at 9:31 am #999251Hi,
I changed code to yours.
It worked for little time. Like hour or two. I tested it and it worked.
Later tried it again and now nothing worked. I mean whole Cart page is disappeared. When i go to cart whole page is empty.
Even if i remove this code from editor function.php . Now once i have tried to find solution i found many say do not make these changes through editor.Any idea what went wrong? By the way i didnt change anything else after i changed that code.
August 20, 2018 at 9:36 am #999254Hi,
You can try to access your theme files via ftp. Go to the directory wp-content/themes/ and download the modified files. Then edit them, delete the code and upload them again. Afterwards clear your browser cache and (if necessary) the wordpress cache.
Best regards,
DudeAugust 21, 2018 at 1:16 pm #999803Hi,
Sorry to bother you with this. I just still couldnt solve it.
I have modified function.php file through FTP. Also cleared browser cache. I dont use any cache plugin on wordpress right now. I have W3 total cache but its disabled until my page is ready.Cart page is still empty. Also noticed the cart still has products i have added before. ( i can see them by hovering over cart icon on store page)
August 24, 2018 at 7:47 am #1001054Hi,
Please create us an admin account and post a link to your website. Maybe we can find the culprit.
Best regards,
DudeAugust 24, 2018 at 8:59 am #1001068Hi,
Enclosed credentials.
PS. Languange is now something else than english let me know if you want me to change it back to english. Also feel free to change it if you want to.
August 26, 2018 at 2:00 pm #1001871Hi,
I couldn’t find any reasons why the cart page doesn’t work. However I’m sure it’s not a theme issue because the cart page doesn’t work with the default wordpress themes (TwentyFifteen, etc.) too.
I’d recommend to contact your server administrator/host – hopefully they can provide error logs or useful hints.
Best regards,
Dude -
AuthorPosts
- You must be logged in to reply to this topic.