my-orders add new Woo function

Replaces code with "wc_get_account_orders_actions" function;
Formatting;

Per new Woo template files;
This commit is contained in:
Unknown 2018-03-22 14:36:34 -06:00 committed by zachary
parent bd3928f396
commit 2b178a5d67
1 changed files with 6 additions and 27 deletions

View File

@ -69,30 +69,9 @@ if ( $customer_orders ) : ?>
<?php elseif ( 'order-actions' === $column_id ) : ?>
<?php
$actions = array(
'pay' => array(
'url' => $order->get_checkout_payment_url(),
'name' => __( 'Pay', 'understrap' )
),
'view' => array(
'url' => $order->get_view_order_url(),
'name' => __( 'View', 'understrap' )
),
'cancel' => array(
'url' => $order->get_cancel_order_url( wc_get_page_permalink( 'myaccount' ) ),
'name' => __( 'Cancel', 'understrap' )
)
);
$actions = wc_get_account_orders_actions( $order );
if ( ! $order->needs_payment() ) {
unset( $actions['pay'] );
}
if ( ! in_array( $order->get_status(), apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) ) ) {
unset( $actions['cancel'] );
}
if ( $actions = apply_filters( 'woocommerce_my_account_my_orders_actions', $actions, $order ) ) {
if ( ! empty( $actions ) ) {
foreach ( $actions as $key => $action ) {
echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-outline-primary ' . sanitize_html_class( $key ) . '">' . esc_html( $action['name'] ) . '</a>';
}