I try to give out three divs with three different colors and phrases (each for every order-status: completed(green), pending (red), processing (orange).
<div class="order-actions2">
<?php
$order_status = $order->get_status();
if($order_status=="completed") {
echo "Thank you for the payment" . ' ';
$actions = wc_get_account_orders_actions( $order );
?> <style type=text/css>.order-actions2 {background-color: green;} </style><?php
}
elseif($order_status=="pending") {
echo "Spending money is always a statement" . ' ';
$actions = wc_get_account_orders_actions( $order );
?> <style type=text/css>.order-actions2 {background-color: red;} </style><?php
}
elseif($order_status=="processing") {
echo "Spending money is always a statement" . ' ';
$actions = wc_get_account_orders_actions( $order );
?> <style type=text/css>.order-actions2 {background-color: orange;} </style><?php
}
if ( ! empty( $actions ) ) {
foreach ( $actions as $key => $action ) { // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited
echo '<a href="' . esc_url( $action['url'] ) . '" class="order-action2-button ' . sanitize_html_class( $key ) . '">' . esc_html( $action['name'] ) . ' ' . 'now' . '</a>';
}
}
?>
</div>
At the moment every div shows up green. If I wrap every status in an own div, I need to open and close php all the time. This makes me unable to use elseif. Maybe there is a solution with arrays or something I don't know, yet? Thank you.