function run()
 {
     // Example: Set the page-title dynamically; alternatively, declare a static title in xml/Menu/*.xml
     CRM_Utils_System::setTitle(ts('Purchases'));
     // Example: Assign a variable for use in a template
     $uid = CRM_Utils_Request::retrieve('uid', 'Positive', $this);
     $orders = _woocommercecivicrm_customer_orders($uid);
     $this->assign('orders', $orders);
     //$country = new WC_Countries();
     //$countries = $country->get_countries();
     //print_r ($countries);exit;
     parent::run();
 }
/**
 * Implements hook_civicrm_tabs().
 */
function woocommercecivicrm_civicrm_tabs(&$tabs, $cid)
{
    $uid = CRM_Core_BAO_UFMatch::getUFId($cid);
    if (empty($uid)) {
        return;
    }
    $orders = _woocommercecivicrm_customer_orders($uid);
    //$history = woocommerce_civicrm_contact_transaction($uid, FALSE);
    //$count = count($history['orders']['#rows']);
    $url = CRM_Utils_System::url('civicrm/woocommerce/view/purchases', "reset=1&uid={$uid}&snippet=1&force=1");
    $tabs[] = array('id' => 'woocommerce-orders', 'url' => $url, 'title' => 'Orders', 'count' => count($orders), 'weight' => 99);
}