如何在WooCommerce中创建具有相同SKU的多个简单产品? [英] How to create multiple simple-products with same SKU in WooCommerce?
问题描述
我想在WooCommerce中创建具有相同SKU的多个简单产品. 我在管理员设置中搜索,但是在这里我找不到任何启用此功能的设置.有没有钩子,所以我可以禁用此功能.
I want to create multiple simple-product with same SKU in WooCommerce. I search in admin settings but there I cannot find any settings to enable this features. Is there any hook so I can disable this features.
推荐答案
如果要完全禁用SKU功能,则必须使用
wc_product_sku_enabled
过滤器.它将同时删除两个的SKU字段 后端和前端.
If you want to completely disable the SKU feature then you have to use
wc_product_sku_enabled
filter. It will remove the SKU field from both backend and frontend.
add_filter( 'wc_product_sku_enabled', '__return_false' );
如果您想保留SKU功能但需要禁用唯一SKU 检查,则必须使用
wc_product_has_unique_sku
过滤器.它 会将SKU字段保留在后端和前端,但允许 您可以添加多个重复的SKU.
If you want to keep the SKU feature but need to disable unique SKU check then you have to use
wc_product_has_unique_sku
filter. It will keep the SKU field in both backend and frontend, but will allow you to add multiple duplicate SKU.
add_filter( 'wc_product_has_unique_sku', '__return_false' );
代码进入您的活动子主题(或主题)的function.php文件中.或在任何插件php文件中.
希望这会有所帮助!
Code goes in function.php file of your active child theme (or theme). Or also in any plugin php files.
Hope this helps!
这篇关于如何在WooCommerce中创建具有相同SKU的多个简单产品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!