Skip to content

Instantly share code, notes, and snippets.

@swoboda
Created June 19, 2020 07:48
Show Gist options
  • Save swoboda/337b7146116a6c8daa035dbaac75f77d to your computer and use it in GitHub Desktop.
Save swoboda/337b7146116a6c8daa035dbaac75f77d to your computer and use it in GitHub Desktop.
Checkout steps in WP Desk Theme
<?php
add_action( 'genesis_after_header', 'wpdesk_checkout_steps', 25 );
/**
* Checkout Steps
*
*/
function wpdesk_checkout_steps() {
global $wp;
if ( is_cart() || is_checkout() || is_wc_endpoint_url( 'order-received' ) ) {
$order_status = '';
if ( is_wc_endpoint_url( 'order-received' ) ) {
$order_id = get_query_var('order-received');
$order = wc_get_order( $order_id );
$order_status = $order->get_status();
}
$step_4_text = apply_filters( 'wpdesk_checkout_step_4_text', __( '4. Download plugins', 'wpdesk' ) );
?>
<div class="wrap">
<div class="steps">
<span class="step <?php if ( is_cart() ): ?>step-active<?php endif; ?>"><?php _e( '1. Cart', 'wpdesk' ); ?></span>
<span class="step <?php if ( is_checkout() && ! isset( $wp->query_vars['order-received'] ) && ! is_wc_endpoint_url( 'order-pay' ) ): ?>step-active<?php endif; ?>"><?php _e( '2. Enter details and confirm', 'wpdesk' ); ?></span>
<span class="step <?php if ( in_array( $order_status, array( 'on-hold', 'failed' ) ) || is_wc_endpoint_url( 'order-pay' ) ): ?>step-active<?php endif; ?>"><?php _e( '3. Pay', 'wpdesk' ); ?></span>
<span class="step <?php if ( is_wc_endpoint_url( 'order-received' ) && in_array( $order_status, array( 'processing', 'completed' ) ) ): ?>step-active<?php endif; ?>"><?php echo $step_4_text; ?></span>
</div>
</div>
<?php
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment