我想在edit属性表单中包含一个简单的内容。 (/wp-admin/edit.php?post_type=product&page=product_attributes&edit=55)
这可能吗?我在SO上找到的所有内容都与在产品或分类法中添加字段有关,如果我没有记错的话,产品属性与分类法并不相同。
我想向“品牌”产品属性添加自定义表单。
这是我尝试过的(有和没有pa_的情况):
+
我只需要获取一些html才能显示在此编辑屏幕上的帮助。我的总体计划是将select标签添加到每个属性中,然后将一部分代码添加到variable.php中,检查属性的显示方式。
非常感谢您的帮助。
答案 0 :(得分:2)
使用以下挂钩,您可以根据自己的意愿在之前或之后添加字段
function action_woocommerce_before_edit_attribute_fields( ) {
?>
<tr class="form-field">
<th valign="top" scope="row">
<label for="display"><?php _e('Display Type', ''); ?></label>
</th>
<td>
<select name="display_type">
<option value="select">Select</option>
<option value="variation_image">Variation Image w/ label</option>
</select>
</td>
</tr>
<?php
}
add_action( 'woocommerce_before_edit_attribute_fields', 'action_woocommerce_before_edit_attribute_fields', 10, 0 );
function action_woocommerce_after_edit_attribute_fields( ) {
?>
<tr class="form-field">
<th valign="top" scope="row">
<label for="display"><?php _e('Display Type', ''); ?></label>
</th>
<td>
<select name="display_type">
<option value="select">Select</option>
<option value="variation_image">Variation Image w/ label</option>
</select>
</td>
</tr>
<?php
}
add_action( 'woocommerce_after_edit_attribute_fields', 'action_woocommerce_after_edit_attribute_fields', 10, 0 );