英文:
Ajax remove item from WooCommerce cart issue in a custom theme
问题
以下是翻译好的部分:
在我的网站上有一个问题的链接 问题
所以朋友们,大家好。
我几乎完全修复了所有的错误,并完善了 Botig 主题(WordPress 主题链接)
当然是在你们的帮助下。
只剩下一个坏的时刻。项目删除交叉不起作用。
交叉不起作用 - 当我在 Wookomers 设置中选择 "postname" 而不是 "simple" 时。
我不能使用 "simple" 设置。我更喜欢使用 "postname" 设置。
我还注意到的是,当设置为 "postname" 时,迷你购物篮中的交叉起作用!
我该怎么办?如何解决这个问题?也许有一些代码、片段或其他东西吗?
我永远不会自己搞清楚,知识有限...
任何帮助!请。
下面我将放置两个代码。第一个是迷你购物篮的交叉
第二个是购物车(购物车页面)上不起作用的交叉。
购物车页面,不起作用的交叉代码(当 %postname% 设置 WooCommerce 时)
我认为这个类应该改成 "class=remove remove_from_cart_button"
附注:目前,我选择了 "simple" 设置。当然,交叉起作用。在购物车页面上。
但是有没有办法在选择 "postname" 时使一切都起作用?
更改类或其他一些代码片段来制作支架等等...
<!-- 购物车页面上的 JavaScript 错误 -->
英文:
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.
The cross DOES NOT WORK - when I select "postname" instead of "simple" in the Wookomers settings.
But, the cross WORKS - when I choose this setting ("simple")
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!!
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.
Page-cart, dont working cross code (when %postname% setting woocommerce)
I think this class should be changed to "class=remove remove_from_cart_button"
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...
<!-- javascript errors on cart page -->
答案1
得分: 0
我的网站很完美。问题不在缓存、插件或主题。
不。
问题出在主机上。Nginx。
每个人在使用Nginx部署网站时都可能遇到这样的问题(而且肯定会遇到!)。
言归正传。
我们进入Nginx配置文件,将以下行更改为:
location / {
try_files $uri $uri/ /index.php?$args;
}
之后,“永久链接”(如购物车、主页、我的联系方式)将正常工作!脚本也会正常运行。
附言:谢谢(不用谢)帮助。
我知道为什么每个人都不在意,因为这个问题难以置信地复杂,不是典型的。重新安装Windows、删除缓存、cookies等都不会有帮助。
也没有错误,脚本完美运行。
我可能也会这样做:)
附言:我还修改了这个脚本。
当你删除一个产品(点击叉号)时,它在购物车页面上被删除。
但是小购物车图标没有更新。显示得好像有商品。
要修复这个问题,你需要修改jQuery。
/usr/share/nginx/***************/wp-content/plugins/woocommerce/templates/cart/cart.php
然后搜索并更改为:<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>',
并添加一个更改:esc_attr( $cart_item_key ),
我们更改按钮类并添加一个属性。
结果:小购物车和购物车页面都会更新。
我欣喜若狂。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论