简体   繁体   English

在“缺货”版本之间切换时,可变产品“添加到购物车”按钮会短暂显示

[英]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.

相关问题 单击按钮将添加到购物车中的选定产品 - Add to cart the selected product when button clicks 如何使用 paypal 智能按钮使产品缺货时无法付款 - How to make payment unavailable when product out of stock with paypal smart button 当我在 asp.net mvc 中使用 javascript 单击按钮时,我无法将产品添加到购物车 - I cannot add a product to cart when I click the button using javascript in asp.net mvc 将产品添加到购物车,prestashop中时,ajax购物车出现错误 - Error with ajax cart when add product to cart, prestashop 基于产品类型的 WooCommerce 的“添加到购物车”按钮旁边的自定义按钮 - Custom Button next to “ADD TO CART” button of WooCommerce based on Product Type 如何检查购物车中每个产品的库存 - How to check the stock for each product in the cart 如何移动产品价格旁边的添加到购物车按钮 - How to move the product price next to add to cart button Shopify 在添加到购物车按钮中添加产品价格 - Shopify adding the product price inside the add to cart button 有没有办法从“添加到购物车”按钮中删除产品的超链接? - Is there a way to remove the hyperlink to a product from “Add to Cart” button? Bigcommerce Stencil / Sticky 添加到购物车按钮未注册产品选项 - Bigcommerce Stencil / Sticky add to cart button not registering product options
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM