wc_get_page_id

Retrieve page ids - used for myaccount, edit_address, shop, cart, checkout, pay, view_order, terms.

Description

(int) wc_get_page_id( (string) $page ); 

returns -1 if no page is found.

Returns (int)

Parameters (1)

0. $page (string)
The page.

Usage

  1. if ( !function_exists( 'wc_get_page_id' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-page-functions.php'; 
  3.  
  4. // The page. 
  5. $page = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wc_get_page_id($page); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-page-functions.php  
  1. function wc_get_page_id( $page ) { 
  2.  
  3. if ( 'pay' == $page || 'thanks' == $page ) { 
  4. wc_deprecated_argument( __FUNCTION__, '2.1', 'The "pay" and "thanks" pages are no-longer used - an endpoint is added to the checkout instead. To get a valid link use the WC_Order::get_checkout_payment_url() or WC_Order::get_checkout_order_received_url() methods instead.' ); 
  5.  
  6. $page = 'checkout'; 
  7. if ( 'change_password' === $page || 'edit_address' === $page || 'lost_password' === $page ) { 
  8. wc_deprecated_argument( __FUNCTION__, '2.1', 'The "change_password", "edit_address" and "lost_password" pages are no-longer used - an endpoint is added to the my-account instead. To get a valid link use the wc_customer_edit_account_url() function instead.' ); 
  9.  
  10. $page = 'myaccount'; 
  11.  
  12. $page = apply_filters( 'woocommerce_get_' . $page . '_page_id', get_option( 'woocommerce_' . $page . '_page_id' ) ); 
  13.  
  14. return $page ? absint( $page ) : -1;