wordpress - 自定义 woocommerce 产品字段不适用于 CSV 导入
问题描述
我以这种方式为我的产品创建了一个自定义字段:
// The code for displaying WooCommerce Product Custom Fields
add_action( 'woocommerce_product_options_general_product_data', 'woocommerce_product_custom_fields' );
// Following code Saves WooCommerce Product Custom Fields
add_action( 'woocommerce_process_product_meta', 'woocommerce_product_custom_fields_save' );
function woocommerce_product_custom_fields () {
global $woocommerce, $post;
echo '<div class=" product_custom_field ">';
// Custom Product Number Field
woocommerce_wp_text_input(
array(
'id' => '_shipping_days_field',
'placeholder' => 'Días de entrega',
'label' => __('Días estimados de entrega', 'woocommerce'),
'type' => 'number',
'custom_attributes' => array(
'step' => 'any',
'min' => '1'
)
)
);
echo '</div>';
}
function woocommerce_product_custom_fields_save($post_id){
// Custom Product Number Field
$shipping_days = $_POST['_shipping_days_field'];
if (!empty($shipping_days))
update_post_meta($post_id, '_shipping_days_field', esc_attr($shipping_days));
}
这在前端管理员上工作正常,它显示字段并保存它,但它不适用于 CSV 导入,我无法在我的 CSV 映射中指定该字段。有没有一种方法可以创建也适用于 CSV 导入的自定义字段?
解决方案
我实际上解决了它,在映射上您应该选择 Meta Attributes,并且 CSV 列上的标签必须如下:
meta:your_custom_field
推荐阅读
- python - 我正在用 python 乌龟图形制作赛车游戏,但我遇到了问题
- javascript - 即使第一个“if”语句条件为真,赛普拉斯(javascript)“else”块也会执行
- mysql - 使用 GROUP BY 和 INNER JOIN 选择 MIN 值?
- php - Woocommerce 元查询在 product_query 中不起作用
- sql - CROSS JOIN 查询性能问题
- javascript - Javascript:如何在界面中的字符串元素中添加逗号
- azure-devops - Nexus 存储库 - Azure DevOps 发布管道
- dji-sdk - Matrice300 RTK:如何实现“跟随我”行为
- reactjs - 无法读取 null React api json fetch 的属性
- yaml - 路径中具有多个/连续 $ref 元素的 OpenApi 文件给出了重复的映射键