losmochos
Forum Replies Created
Viewing 1 replies (of 1 total)
-
Until the new version is released, it can be resolved by changing a function in a file
bp-custom-order-status-for-woocommerce/src/Status.php
I have updated the function so that, in this case, the custom order status does not appear if it is marked as completed.
/**
* Add custom status to order actions buttons.
*
* @param array $actions - array of actions.
* @param object $order - order object.
* @return array
*/
public function add_custom_status_actions_buttons( $actions, $order ) {
// Obtener la lista de estados personalizados que el usuario quiere agregar en la columna de acciones de pedidos
$statuses = $this->wcbvCustomStatusFiltermetaActive( '_enable_action_status', true );
$order_id = $order->get_id();
// Verificar si el pedido no está ya completado antes de agregar la acción 'complete'
if ( ! $order->has_status( 'completed' ) && ! array_key_exists( 'complete', $actions ) ) {
$actions['complete'] = array(
'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status=completed&order_id=' . $order_id ), 'woocommerce-mark-order-status' ),
'name' => __( 'Complete', 'woocommerce' ),
'action' => 'complete',
);
}
// Solo agregar acciones de estado personalizado si el pedido NO está completado
if ( ! $order->has_status( 'completed' ) ) {
foreach ( $statuses as $slug => $label ) {
$custom_order_status = sanitize_title( $slug ); // Asegurarse de que el slug esté limpio
if ( ! $order->has_status( $custom_order_status ) ) { // Si el pedido no tiene el estado personalizado
$status_post = get_posts(
array(
'post_type' => 'order_status',
'title' => $label,
'numberposts' => 1, // Limitar a un solo post
)
);
if ( ! empty( $status_post ) ) {
$custom_order_status_obj = $status_post[0];
$custom_order_status_id = $custom_order_status_obj->ID;
$custom_status_icon = get_post_meta( $custom_order_status_id, 'status_icon', true );
// Solo agregar el ícono si existe
if ( ! empty( $custom_status_icon ) ) {
$icon_html = '<i class="' . esc_attr( $custom_status_icon ) . '"></i> ';
} else {
$icon_html = '';
}
$actions[ $custom_order_status ] = array(
'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status=' . $custom_order_status . '&order_id=' . $order_id ), 'woocommerce-mark-order-status' ),
'name' => $icon_html . esc_html__( $label, 'woocommerce' ),
'action' => 'view ' . sanitize_title( $custom_order_status ),
);
}
}
}
}
return $actions;
}
Viewing 1 replies (of 1 total)