The woocommerce function woocommerce_account_orders($current_page) has 1 parameter called $current_page. The function is called via woocommerce_account_orders_endpoint via the following hook – add_action( 'woocommerce_account_orders_endpoint', 'woocommerce_account_orders' );
However, in the above hook, $current_page is not passed as an argument in the function. How is $current_page passed to woocommerce_account_orders() function?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Action hooks can pass variables do hooked callback functions. For example:
do_action( 'my_custom_action', $a_variable );
For that action, any callback function has access to $a_variable:
add_action( 'my_custom_action', 'my_custom_function' );
function my_custom_function( $a_variable ) {
// etc.
}
The woocommerce_account_orders_endpoint action hook is defined like this:
do_action( 'woocommerce_account_' . $key . '_endpoint', $value );
Where $value would be passed to woocommerce_account_orders() which uses it as the $current_page argument.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0