删除WooCommerce中的变体属性下拉列表 [英] Remove variation attribute drop downs in WooCommerce

查看:225
本文介绍了删除WooCommerce中的变体属性下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从单个产品页面中删除变体下拉列表,我已成功使用...删除了摘要。

I am trying to remove the variations dropdown from a single product page, I have successfully removed the summary using...

remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 20 );

但是我一直找不到类似的代码片段来删除下拉列表。有人看到我的例子吗?

But I have been unable to find a similar snippet to remove the dropdown. anyone have an example I can see?

推荐答案

要删除产品摘录,您应该通常使用 woocommerce_template_single_excerpt (优先级为 20 ),例如:

To remove the product excerpt you should normally use woocommerce_template_single_excerpt (with a priority of 20) like:

remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );

要删除(对于可变产品)属性下拉列表,数量字段和添加到购物车按钮,应该使用 woocommerce_template_single_add_to_cart (优先级为 30 ),例如:

To remove (for variable products) the attribute dropdowns, the quantity field and the add to cart button you should use woocommerce_template_single_add_to_cart (with a priority of 30) like:

add_action( 'woocommerce_single_product_summary', 'removing_variable_add_to_cart_template', 3 );
function removing_variable_add_to_cart_template(){
    global $product;

    // Only for variable products
    if( $product->is_type( 'variable' ) ){
        remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
    }
}




如果您只想删除下拉列表而不删除数量字段和添加到购物车按钮,请使用 remove_action()

Is not possible to use remove_action() if you wish to remove just the dropdowns without removing quantity field and add-to-cart button.

如果是这种情况,您将不得不操作/覆盖模板本身……

请参阅此文档:模板结构&通过主题覆盖模板

If it's the case you will be obliged to manipulate/override the template itself…
See this documentation: Template structure & Overriding templates via a theme

可变产品的属性下拉列表位于模板WooCommerce模板单一产品/添加到购物车/variable.php 。

The attribute dropdowns from variable products are located in the template WooCommerce template single-product/add-to-cart/variable.php.

您将必须插入 IF 语句具有满足您的需求的必要条件(在 34 行> ELSE 此模板中的语句)。

You will be oblige to insert an IF statement with the necessary condition that will feet your needs (at line 34 just after the ELSE statement in this template).

这篇关于删除WooCommerce中的变体属性下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆