【发布时间】:2016-05-31 08:04:56
【问题描述】:
我想在 woocommerce 的手动管理订单页面中添加一个元框。
这个元框需要是一个复选框,如果选中它会触发一个动作 到目前为止,我已经读过它需要开始这样的事情
function add_meta_boxes()
{
add_meta_box(
'Meta Box', // ID, should be a string.
'woocommerce-action-trigger', // Meta Box Title.
'my_meta_box', // Your call back function, this is where your form field will go.
'shop_order', // The post type you want this to show up on, can be post, page, or custom post type.
'side', // The placement of your meta box, can be normal or side.
'default' // The priority in which this will be displayed.
);
}
然后我需要一个表单,如果管理员选择将触发操作
function triggeraction_meta_box() {
$checkboxMeta = make_action_happen();
}
<input type="checkbox" name="action" id="action" value="yes" <?php if ( isset ( $checkboxMeta['action'] ) ) checked( $checkboxMeta['action'][0], 'yes' ); ?> />make_action_happen<br />
正如您在这一点上所看到的,我希望该复选框仅针对此订单取消 woocommerce 中的某些内容,因此它仅在此会话的此页面中发生。
请任何人帮助我的编码非常非常基础。
【问题讨论】:
标签: wordpress woocommerce