Created
September 3, 2017 14:44
-
-
Save carasmo/f563b5e3e83f40e99bd2c251b043f63d to your computer and use it in GitHub Desktop.
WooCommerce Helper Function -- author: https://faish.al/2014/01/06/check-if-it-is-woocommerce-page/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// don't add again // assumes this is in an include in your child theme usually a helper-functions.php file | |
/** | |
* Check if WooCommerce Page of all kinds | |
* @thanks: https://faish.al/2014/01/06/check-if-it-is-woocommerce-page/ | |
*/ | |
function theme_prefix_is_woocommerce_page() { | |
if( function_exists ( 'is_woocommerce' ) && is_woocommerce() ) : | |
return true; | |
endif; | |
$woocommerce_keys = array ( | |
'woocommerce_shop_page_id' , | |
'woocommerce_terms_page_id' , | |
'woocommerce_cart_page_id' , | |
'woocommerce_checkout_page_id' , | |
'woocommerce_pay_page_id' , | |
'woocommerce_thanks_page_id' , | |
'woocommerce_myaccount_page_id' , | |
'woocommerce_edit_address_page_id' , | |
'woocommerce_view_order_page_id' , | |
'woocommerce_change_password_page_id' , | |
'woocommerce_logout_page_id' , | |
'woocommerce_lost_password_page_id' ) ; | |
foreach ( $woocommerce_keys as $wc_page_id ) : | |
if ( get_the_ID () == get_option ( $wc_page_id , 0 ) ) : | |
return true; | |
endif; | |
endforeach; | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment