Skip to content

Instantly share code, notes, and snippets.

@glueckpress
Last active January 11, 2016 18:36
Show Gist options
  • Save glueckpress/85a8f086d92462d73d41 to your computer and use it in GitHub Desktop.
Save glueckpress/85a8f086d92462d73d41 to your computer and use it in GitHub Desktop.
[WordPress] Conditional tag for WooCommerce German Market 2.x determining whether the current page is the second checkout page.
<?php
/**
* Plugin: WooCommerce German Market 2.x
* Conditional check whether current page is second checkout
*/
if ( ! function_exists( 'wgm_is_2nd_checkout' ) && ! is_admin() ) :
/**
* Check if page is WGM 2nd checkout
*
* @return bool
*/
function wgm_is_2nd_checkout() {
$second_checkout_id = absint( get_option( 'woocommerce_check_page_id' ) );
return is_page( $second_checkout_id );
}
/* Debug output via plugin/functions.php */
add_action( 'pre_get_posts', function ( $query ) {
if ( $query->is_main_query() ) {
echo '<pre>is 2nd checkout (true/false): ';
var_export( wgm_is_2nd_checkout() );
echo '</pre>';
}
return $query;
});
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment