wordpresswoocommerce

Ajax remove item from WooCommerce cart issue in a custom theme


Link on my site with issue ISSUE

So friends. Hi all. I almost completely fixed all the bugs and perfected the Botig theme (Link theme Wordpress) With your help, of course.

There is only 1 bad moment left. The item deletion cross does not work.

enter image description here

The cross DOES NOT WORK - when I select "postname" instead of "simple" in the Wookomers settings.
enter image description here

But, the cross WORKS - when I choose this setting ("simple") enter image description here

I can't use the "simple" setting. I prefer to use the "postname" setting.

What else I noticed. When setting "postname" - the cross in the MINI-BASKET works!! enter image description here

What can I do? How to fix this problem? Maybe there is some code, snippet or something? I will never figure it out myself, little knowledge ...

Any help! Please.

Below I will throw off 2 codes. 1st: a cross for a mini basket 2nd: a cross for a shopping cart (cart page) that doesn't work.

Mini-cart, working cross code enter image description here

Page-cart, dont working cross code (when %postname% setting woocommerce) enter image description here

I think this class should be changed to "class=remove remove_from_cart_button" enter image description here

P. S. For now, I've selected the "simple" setting. And of course the cross works. On the shopping cart page.

But is there a way to make everything work when you select "postname"?? Change the class or some other snippet to make, a crutch, and so on...

Working links - enter image description here

Dont working - enter image description here


Solution

  • My site is perfect. And the problem was not in the cache, not in the plugin, not in the theme. No.

    The problem was hosting. Nginx.

    Everyone can have such a problem (and IT WILL BE!!) if you deploy a site on nginx.

    Get to the point.

    We go into the nginx config and change the line to the following -

     location / {
       try_files $uri $uri/ /index.php?$args;
     }
    

    After that, "permalinks" like - shopping cart, home, my contacts - will work perfectly! Scripts will work perfectly.

    P.S. thanks (no) for helping. I know why everyone didn't give a shit, because the problem is unrealistically complex and not typical. Here stupid advice - reinstall Windows, delete caches, cookies, and so on will not help. There are no errors either, the scripts work perfectly.

    I would probably do the same :)

    P. P. S. I also modified this script. When you delete a product (on a cross) - it is deleted on the cart page. But the mini cart icon is NOT updated. And shows as if there are goods.

    To fix this, you need to modify the jQuery.

    /usr/share/nginx/***************/wp-content/plugins/woocommerce/templates/cart/cart.php
    

    Next, search and change to: <a href="%s" class="remove remove_from_cart_button" aria-label="%s" data-product_id="%s" data-cart_item_key="%s" data-product_sku="% s">&times;</a>',

    And add this one more: esc_attr( $cart_item_key ),

    We change the button class and add an attribute.

    Result: Both the mini cart and the cart page are updated.

    I am over the mind.