简体   繁体   English

删除Woocommerce购物车中的变化

[英]Remove variation in Woocommerce cart

I have a pizza with multiple ingredients. 我有多种食材的比萨。 If the user ticks an "Add Ingredients" box the choices come up as drop downs defaulted at "none". 如果用户在“添加成分”框内打钩,则会出现下拉列表,默认为“无”。 I need to get the "none" selected options to hide in the cart and checkout. 我需要选择“无”选项才能隐藏在购物车中并结帐。

I've got them to hide in the cart page but they still show in the masthead cart and the checkout. 我已经将它们隐藏在购物车页面中,但它们仍显示在标头购物车和结帐中。

Here is some of the code displaying the ingredients: 这是一些显示成分的代码:

  <li>Add Ingredients?</li> </ul> </dd> <dt class="variation-GreenOlives">Green Olives:</dt> <dd class="variation-GreenOlives"> <p>Whole Pizza ($1.00)</p> </dd> <dt class="variation-RipeOlives">Ripe Olives:</dt> <dd class="variation-RipeOlives"> <p>None</p> </dd> <dt class="variation-SlicedTomatoes">Sliced Tomatoes:</dt> <dd class="variation-SlicedTomatoes"> <p>None</p> </dd> <dt class="variation-FreshMushrooms">Fresh Mushrooms:</dt> <dd class="variation-FreshMushrooms"> <p>None</p> </dd> <dt class="variation-ArtichokeHearts">Artichoke Hearts:</dt> <dd class="variation-ArtichokeHearts"> <p>None</p> </dd> <dt class="variation-CannedMushrooms">Canned Mushrooms:</dt> <dd class="variation-CannedMushrooms"> <p>None</p> </dd> <dt class="variation-FreshBasil">Fresh Basil:</dt> <dd class="variation-FreshBasil"> <p>None</p> </dd> <dt class="variation-Spinach">Spinach:</dt> <dd class="variation-Spinach"> <p>None</p> </dd> <dt class="variation-Pepperjack">Pepperjack:</dt> <dd class="variation-Pepperjack"> <p>None</p> </dd> <dt class="variation-ExtraCheese">Extra Cheese:</dt> <dd class="variation-ExtraCheese"> <p>None</p> </dd> <dt class="variation-Cheddar">Cheddar:</dt> <dd class="variation-Cheddar"> <p>None</p> </dd> <dt class="variation-Swiss">Swiss:</dt> <dd class="variation-Swiss"> <p>None</p> </dd> 

And here is the code that is hiding the "none" options on the cart page: 这是隐藏购物车页面上“ none”选项的代码:

 function hideNone(){ $(document).ready(function(){ $("dd>p:contains('None')").hide() && $("dd").prev().hide(); }); } 

So even though the code is the same on all three of the places the order shows, this code is only hiding it on the cart page. 因此,即使订单显示的所有三个地方的代码都相同,该代码也只会将其隐藏在购物车页面上。 I'm using woocommerce and gravity forms on a local install. 我在本地安装上使用woocommerce和重力形式。 Thanks for your help. 谢谢你的帮助。

The problem I think is that you have declared the function hideNone() and haven't called the function. 我认为的问题是,您已经声明了函数hideNone() ,但尚未调用该函数。 $( document ).ready() is actually used for calling a function when the document is loaded, that means that is not need to be a function definition. $( document ).ready()实际上是在加载文档时用于调用函数的,这意味着不必是函数定义。 See the documentation. 请参阅文档。

  $(document).ready(function() { $("dd>p:contains('None')").hide() && $("dd").prev().hide(); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> <dt class="variation-GreenOlives">Green Olives:</dt> <dd class="variation-GreenOlives"> <p>Whole Pizza ($1.00)</p> </dd> <dt class="variation-RipeOlives">Ripe Olives:</dt> <dd class="variation-RipeOlives"> <p>None</p> </dd> <dt class="variation-SlicedTomatoes">Sliced Tomatoes:</dt> <dd class="variation-SlicedTomatoes"> <p>None</p> </dd> <dt class="variation-FreshMushrooms">Fresh Mushrooms:</dt> <dd class="variation-FreshMushrooms"> <p>None</p> </dd> <dt class="variation-ArtichokeHearts">Artichoke Hearts:</dt> <dd class="variation-ArtichokeHearts"> <p>None</p> </dd> <dt class="variation-CannedMushrooms">Canned Mushrooms:</dt> <dd class="variation-CannedMushrooms"> <p>None</p> </dd> <dt class="variation-FreshBasil">Fresh Basil:</dt> <dd class="variation-FreshBasil"> <p>None</p> </dd> <dt class="variation-Spinach">Spinach:</dt> <dd class="variation-Spinach"> <p>None</p> </dd> <dt class="variation-Pepperjack">Pepperjack:</dt> <dd class="variation-Pepperjack"> <p>None</p> </dd> <dt class="variation-ExtraCheese">Extra Cheese:</dt> <dd class="variation-ExtraCheese"> <p>None</p> </dd> <dt class="variation-Cheddar">Cheddar:</dt> <dd class="variation-Cheddar"> <p>None</p> </dd> <dt class="variation-Swiss">Swiss:</dt> <dd class="variation-Swiss"> <p>None</p> </dd> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM