Okay
  Public Ticket #3202537
list of orders
Closed

Comments

  •  3
    Trevor Lee started the conversation

    Hi,  after taking ages creating all the events for my customer , I am asked if they can see a list of orders, actually a reasonable question. Woocommerce orders table is not great  and user friendly, 

    I see the url of the order display is;  admin.php?page=stec_menu__tickets&view=orders&ticket_id=3208

    could that not be altered to show them all?

    What would be great a short code / tags  to do this, but I really don't mind using a bit of code,  as they are talking about using something different. :(

    Ideally We want to display order name ( person who ordered it )  Ticket Name - and Venue details ( hopefully a custom field )  that lets us select more than one choice from a drop down.

    I don't mind querying the DB if necessary and then echoing output, unless there is a hook or filter you can show me how to do this much more easily?

    Would be awesome!

  •  877
    Zhivko replied

    Hi,

    This will help you to get started:

    Since we'll place a new admin page in the calendar we'll use only the calendar plugin folder.

    Open the main calendar file stachethemes_event_calendar.php and register new admin menu Orders by adding this line at the very bottom:

    add_action('stec_add_admin_menu', function(){
        $stachethemes_ec_main = \Stachethemes\Stec\Stachethemes_Event_Calendar::get_instance();
        $stachethemes_ec_main->add_submenu('Orders', 'stec_menu__orders');
    });
    7025062157.png

    Then unzip the archive I've attached and place the orders folder in

    7750517322.png

    ---

    6064084456.png

    ---

    Now you will have new submenu STEC -> Orders.

    The orders folder contain two files index.php and list.php .

    The index.php retrieves all orders that contain tickets in them and then displays the list.php file. 

    You will want to start working with list.php .

    It already contains orders loop. I hope you get the idea what's going on there.

    Attached files:  orders.zip


    Stachethemes Developer

  •   Trevor Lee replied privately
  •  877
    Zhivko replied

    For the meta data I'd suggest you to include this function in the list.php file.

    function get_ticket_meta_value($key, $ticket_data) {
        foreach($ticket_data['meta_data'] as $meta) {
    
            if ($meta->__get('key') !== $key) {{
                continue;
            }}         return $meta->__get('value');
        }     return '';
    }

    It's a helper function  to obtain the meta value by key name.

    1377529791.png

    And then inside the loop you get the meta value like this:

    $event_date = get_ticket_meta_value('event_start', $ticket_data);
    8901005282.png

    ---

    Obtaining customer name from the $order:

    $customer_name = sprintf('%s %s', $order->get_billing_first_name(), $order->get_billing_last_name());
    9631065033.png



    Stachethemes Developer

  •  3
    Trevor Lee replied

    Excellent - all done, now  I will apply formatting and an order by button , thanks for your help so far! 

  •   Trevor Lee replied privately