Woocommerce - 添加另一个自定义状态,以便下订单 "editable"
Woocommerce - Add another custom status so it will make the order "editable"
我创建了另一个自定义状态到 wc 状态,我希望这个状态离开订单 "editable",所以我在文件 abstract-wc-order.php
:
中找到了这段代码
public function is_editable() {
return apply_filters( 'wc_order_is_editable', in_array( $this->get_status(), array( 'pending', 'on-hold', 'auto-draft', 'failed' ) ), $this );
}
现在,如果我目前理解,我需要将我的自定义状态添加到上面的数组中,但我不太确定该怎么做 - 通过挂钩过滤器将我的状态添加到上面的数组中 wc_order_is_editable
,非常感谢任何帮助!
可能像这样的东西会起作用:
function so_39193164_is_editable( $editable, $order ) {
if( $order->get_status() == 'your-new-status' ){
$editable = true;
}
return $editable;
}
add_filter( 'wc_order_is_editable', 'so_39193164_is_editable', 10, 2 );
如果订单状态是您的新状态,则 $editable
为真。如果不是,它将是 WooCommerce 在 is_editable()
方法中已经确定的任何内容。
我创建了另一个自定义状态到 wc 状态,我希望这个状态离开订单 "editable",所以我在文件 abstract-wc-order.php
:
public function is_editable() {
return apply_filters( 'wc_order_is_editable', in_array( $this->get_status(), array( 'pending', 'on-hold', 'auto-draft', 'failed' ) ), $this );
}
现在,如果我目前理解,我需要将我的自定义状态添加到上面的数组中,但我不太确定该怎么做 - 通过挂钩过滤器将我的状态添加到上面的数组中 wc_order_is_editable
,非常感谢任何帮助!
可能像这样的东西会起作用:
function so_39193164_is_editable( $editable, $order ) {
if( $order->get_status() == 'your-new-status' ){
$editable = true;
}
return $editable;
}
add_filter( 'wc_order_is_editable', 'so_39193164_is_editable', 10, 2 );
如果订单状态是您的新状态,则 $editable
为真。如果不是,它将是 WooCommerce 在 is_editable()
方法中已经确定的任何内容。