[英]Variable product Add to Cart button displays briefly when switching between 'out of stock' variations
Please take a look at http://www.bestvapestore.com/product/goblin-juice-krazak/ 请查看http://www.bestvapestore.com/product/goblin-juice-krazak/
All variations are out of stock, but as you can see, when switching between them it shows the Add to Cart button briefly - this is not desirable. 所有变体都缺货,但是如您所见,在它们之间切换时,它会短暂显示“添加到购物车”按钮-这是不希望的。 I'm using a theme and can't seem to find the code responsible for this. 我正在使用主题,但似乎找不到负责此目的的代码。
There is also an issue when no variation is selected, and then a user selects an out of stock variation. 当没有选择任何变化,然后用户选择缺货变化时,也会出现问题。 It doesn't quite show the add to cart button, but it displays some content after the 'out of stock' message briefly before displaying correctly. 它并没有完全显示“添加到购物车”按钮,但是会在“缺货”消息后短暂显示一些内容,然后正确显示。
Cany anyone help? 有人可以帮忙吗?
Just check the site and and the issue is clearly visible to me here. 只需检查站点,问题就可以在这里清楚地看到。
As per my analysis it is a theme issue. 根据我的分析,这是一个主题问题。
And yes there is a solution to it. 是的,有解决方案。
Tried the code from my end and done the basic level of testing. 从头开始尝试代码,并完成了基本测试。 Now from here you can go forward with this solution. 现在,您可以从这里开始使用此解决方案。
JQuery code: jQuery代码:
jQuery('.variations_button').change(function() {
if(jQuery('.variations_button').prev().children('.in-stock').length){
jQuery('.variations_button').css('display','block');
}else{
jQuery('.variations_button').css('display','none');
}
});
The procedure here is to add the above code into a js file which load on Single product page or create your own and load the js of the single product pages. 此处的过程是将以上代码添加到js文件中,该文件可加载到“单个产品”页面上,也可以创建您自己的文件并加载单个产品页面的js。
To test the code just open you developer console while viewing your page which has issue. 要测试代码,只需在查看有问题的页面时打开开发人员控制台即可。 Paste this code in console. 将此代码粘贴到控制台中。 Now toggle between the variations and now you can see that the error is gone. 现在在变体之间切换,现在您可以看到错误已消失。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.