php - Passing WooCommerce Order ID into a hook -
i have recurring issue in woocommerce customizations: how current order id within function.
some hooks can pass $order_id, in context of user's business relationship page specific order, example, below doesn't work.
the problem $order_id
empty, of course. how pass id of order function?
add_action( 'woocommerce_order_items_table', 'xcsn_woocommerce_order_items_table'); function xcsn_woocommerce_order_items_table ( $order_id ) { $order = new wc_order( $order_id ); echo 'the order id is: ' . $order->get_order_number(); // or echo '<br>the order id is: ' . $order->id; }
i tried this, returns user id number, not order:
global $woocommerce; $order = new wc_order($post->id); echo 'the order id: ' . $order->get_order_number();
any suggestions?
this solves particular issue above (though not general question):
add_action( 'woocommerce_order_items_table', 'xcsn_woocommerce_order_items_table'); function xcsn_woocommerce_order_items_table ( $order ) { echo $order->id; //this order id, in user accounts>order page }
php wordpress woocommerce
No comments:
Post a Comment