Woocommerce update cart button not working - woocommerce

I recently updated to woocommerce 2.3.7 and now the update cart button on the cart page isn't updating the changes i've made to quantities of items. I can still remove items but the update cart button isn't working?
How do i solve this?
Is this a common error as i haven't installed any new plugins and everything was working fine on the previous woocommerce version 2.0.6

In case the used theme is not adding the correct nonce to the form, I would recommend you to correct the theme (eg. by using a child theme) and adding the nonce by yourself.
I did it by updating /woocommerce/cart/cart.php in a child theme, adding the nonce expected by woocommerce form handler <?php wp_nonce_field( 'woocommerce-cart' ); ?>.
By using this solution, you keep the csrf protection (I definitely would not recommend to deactivate it, especially for a web shop).

I know this is a very old question but I just fixed this issue myself, and in my case I needed to add both these lines below the button HTML code.
<?php do_action( 'woocommerce_cart_actions' ); ?>
<?php wp_nonce_field( 'woocommerce-cart', 'woocommerce-cart-nonce' ); ?>

Not sure if it will work for you, but I managed to fix this issue by simply de activating the problematic theme, activating twentyseventeen. De activating twenty seventeen and then re activating the problem them and Wordpress woo commerce started to play nicely again :)

Related

Customise my wordpress site to have the add to cart button appear when someone hovers over the products. I have attached the scree

I have very beginner level understanding of wordpress, woocommerce and elementor. I am still learning a lot of things. I believe that the best way to learn is to imitate. So, I go through various themes and try to imitate their behaviour and appearance using Elementor. But, this particular theme caught my eye. The Add to cart button appears when someone hovers over the product image instead of always being there. Can you guys please help me figure this out or atleast point me in the right direction?
This is how it should look when someone hovers over the images
This is how it looks when the mouse pointer is away
More info
<?php if($available) {?>
Buy now
<?php } ?>
This code solves my problem as expected.
WooCommerce documentation reference
Solution: Add code in your theme's function.php file.
add_action( 'woocommerce_single_product_summary', 'my_extra_button_on_product_page', 30 );
function my_extra_button_on_product_page() {
global $product;
echo 'Add to cart';
}
Solution: Install Custom WooCommerce Add to Cart plugin
Custom WooCommerce Add to Cart Plugin
Solution: You can use hooks with shortcodes:
custom add to cart button
Or create overrides for WooCommerce files in your own template

Woocommerce best_selling_products shortcode not working

Trying to add:
<?php echo do_shortcode('[products best_selling="true" limit="4"]'); ?>
In a template returns nothing. I see that no hooks are present for this but woocommerce says it should be supported.
Please Try this shortcode
[best_selling_products per_page="12"]
Please refer below link for Woocommerce Shortcodes
https://docs.woocommerce.com/document/woocommerce-shortcodes/
Coming back to this one because I came across another shortcode that wasn't working.
It turned out that the theme was the culprit. After switching to the default theme all shortcodes were working correctly.

Wordpress plugin shortscodes in other plugins?

I'm developing a plugin that creates custom wordpress pages, however I ran into a problem when trying to get shortcodes from other plugins to integrate into my plugin, well more like I couldn't find any info on it.
For example if someone uses my custom page builder and adds a short code [gallery] that is associated with an enabled plugin, I want the shortcode to do it's thing.
Could anyone point me in the right direction for this?
Try wordpress
http://wordpress.org/plugins/synved-shortcodes/
while this plugin let's you integrate shortcodes on every wordpress page , I suppose that you issue is with wordpress functions.php file where you can have a look at , with this plugin installed !
You can check if a shortcode exist before printing it with the function shortcode_exists() (https://codex.wordpress.org/Function_Reference/shortcode_exists)
Example:
<?php
if ( shortcode_exists( 'gallery' ) ) {
// The [gallery] short code exists.
}
?>
Then, if it exist and you want to print that shortcode with PHP code you should use do_shortcode() function (https://developer.wordpress.org/reference/functions/do_shortcode/)
Example:
<?php echo do_shortcode('[gallery]); ?>
Always use in WordPress's in-built
the_content
hook to print your custom page content.
WordPress by default process all shortcodes before outputting any stuff from this hook.
More info can be found here: https://codex.wordpress.org/Function_Reference/the_content

Disqus and WooCommerce review compatibility issue

I am trying to use Woocommerce plugin and Disqus plugin together on my WordPress blog.
As I can see from other posts on internet, lot of users such as me are facing the issue that - Disqus disables reviews on product page created by Woocommerce.
As Disqus disables WordPress comments which in turn are used by Woocommerce for product review - now there is no way (as far as I could know) to show review form on Woocommerce.
Can anyone suggest a fix for this?
I have already tried the following:
Open Disqus plugin directly.
Go to line number 150 in disqus.php
notice the conditions which says for which posts types Disqus should not render comments.
add - if ( is_product() ) { return false; }
This will stop showing Disqus comment box from product pages created by Woocommerce and it will show usual review form. However, on submitting this - you will receive an error saying WP comments have been disabled.
Can anyone help me here?
I solved this by adding this code to my functions.php file:
add_action('the_post', 'sb_remove_woocommerce_disqus', 10, 2 );
remove_action('pre_comment_on_post', 'dsq_pre_comment_on_post');
function sb_remove_woocommerce_disqus( $post, $query ) {
global $post, $wp_query;
if ($query->is_main_query() && $post->post_type == 'product') {
remove_filter('comments_template', 'dsq_comments_template');
}
}
My problem was if I used Disqus plugin, it replaced my WordPress comment system with Disqus. Thus, disabling reviews on Woocommerce pages.
So instead using Disqus plugin, I simply used its universal code and added to my single.php file, before <?php comments_template(); ?> to be precise.
This seems to work.

"Custom Field Template" plugin - Content area dissapearing when switching templates

On top of all: This is a great plugin.
But after the latest core upgrade to 3.3.1, the plugin got this big bug: If you have more than one fields template set, when switching from one template to the other, the main content area disappears. If the post/page is saved in those conditions, the main content ends up empty.
This is happening on all the sites where I have this plugin installed.
http://wordpress.org/extend/plugins/custom-field-template/
You could try do display it by editing your theme with code like this for every field you wish to display:
<?php echo get_post_meta($post->ID, 'my_CustomFieldName', true); ?>
This bug was fixed on a later release of the plugin.

Resources