Title: Customizing and adding woocommerce template data
Last modified: November 16, 2016

---

# Customizing and adding woocommerce template data

 *  [jarkin13](https://wordpress.org/support/users/jarkin13/)
 * (@jarkin13)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/customizing-and-adding-woocommerce-template-data/)
 * I am having some trouble customizing the woocommerce templates in my wordpress
   theme. I would like to add additional data as variables in my templates.
 * I want to show active orders on the dashboard or my-account page. I want to do
   this by passing in order data variables to the template to be able to call, like
   how it is done in the `orders.php` template.
 * I know I can override the `wc-template-functions.php` in my theme and then add
   the data in the `wc_get_templates` function for the dashboard or my account. 
   However, I don’t want to do this.
 * What I’ve tried is creating a hook such as:
 * **functions.php**
 *     ```
       function wc_fr_add_orders_to_account( $dashboard_orders, $current_page ) {
         global $account_orders;
         $current_page = empty( $current_page ) ? 1 : absint( $current_page );
   
         $customer_orders = wc_get_orders( apply_filters( 'woocommerce_my_account_my_orders_query', 
           array( 
             'customer' => get_current_user_id(), 
             'page' => $current_page, 
             'paginate' => true,
             'status' => array( 'wc-pending' )
             ) ) );
   
         $fr_account_orders = array(
           'current_page' => absint( $current_page ),
           'customer_orders' => $customer_orders,
           'has_orders' => 0 < $customer_orders->total
         );
   
         return $fr_account_orders;
       }
       add_action( 'woocommerce_account_dashboard', 'wc_fr_add_orders_to_account' );
       ```
   
 * **/theme-directory/woocommerce/templates/myaccount/dashboard.php** (also tried
   in my-account.php)
 *     ```
       do_action( 'woocommerce_account_dashboard', $fr_account_orders);
       var_dump($fr_account_orders);
       ```
   
 * `$fr_account_orders` comes back null. However if I var_dump the array in the 
   hook function, it comes back with data. Any help is appreciated.

Viewing 1 replies (of 1 total)

 *  [con](https://wordpress.org/support/users/conschneider/)
 * (@conschneider)
 * Engineer
 * [9 years, 6 months ago](https://wordpress.org/support/topic/customizing-and-adding-woocommerce-template-data/#post-8447279)
 * You can add array keys to your return values and then use these keys to print
   the array values, like so:
 * 
    function data() { $out[‘a’] = “abc”; $out[‘b’] = “def”; $out[‘c’] = “ghi”; 
   return $out; }
 * $data = data();
    echo $data[‘a’]; echo $data[‘b’]; echo $data[‘c’];
 * Hope this helps a bit. Source: [http://stackoverflow.com/questions/5692568/php-function-return-array](http://stackoverflow.com/questions/5692568/php-function-return-array)

Viewing 1 replies (of 1 total)

The topic ‘Customizing and adding woocommerce template data’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * [template](https://wordpress.org/support/topic-tag/template/)

 * 1 reply
 * 2 participants
 * Last reply from: [con](https://wordpress.org/support/users/conschneider/)
 * Last activity: [9 years, 6 months ago](https://wordpress.org/support/topic/customizing-and-adding-woocommerce-template-data/#post-8447279)
 * Status: not resolved