I am making a plugin that works in collaboration with woocommerce WordPress plugin. I am getting an error when trying to get items for an order:
“Fatal error: Call to a member function get_items() on a non-object in /home/telesqua/public_html/mehtab/wp-content/plugins/order-grabber/order-grabber.php on line 283”
and this is what is on line 283 and around it:
function post_order()
{
if(isset($order_id))
{
$order = new WC_Order($order_id);
}
$items = $order->get_items();
$number_of_items_in_this_order = $order->get_item_count();
Can anyone help me point out the problem? I can provide the source file if needed.
this is because it an add_action has to be executed after using the above code