Clean up my-account template

This patch moves Available Downloads into it's own separate template
file, and moves the titles for Recent Orders and My Addresses into
their respective templates as well. This patch also adds a couple of
new hooks and filters for making templating even easier.
This commit is contained in:
Brian Richards 2012-12-20 11:34:39 -05:00
parent dec06d8d40
commit 3b9b100356
4 changed files with 48 additions and 28 deletions

View File

@ -17,38 +17,13 @@ $woocommerce->show_messages(); ?>
<?php do_action( 'woocommerce_before_my_account' ); ?>
<?php if ( $downloads = $woocommerce->customer->get_downloadable_products() ) : ?>
<?php woocommerce_get_template( 'myaccount/my-downloads.php' ); ?>
<h2><?php _e( 'Available downloads', 'woocommerce' ); ?></h2>
<ul class="digital-downloads">
<?php foreach ( $downloads as $download ) : ?>
<li>
<?php
do_action( 'woocommerce_available_download_start', $download );
if ( is_numeric( $download['downloads_remaining'] ) )
echo apply_filters( 'woocommerce_available_download_count', '<span class="count">' . sprintf( _n( '%s download remaining', '%s downloads remaining', $download['downloads_remaining'], 'woocommerce' ), $download['downloads_remaining'] ) . '</span> ', $download );
echo apply_filters( 'woocommerce_available_download_link', '<a href="' . esc_url( $download['download_url'] ) . '">' . $download['download_name'] . '</a>', $download );
do_action( 'woocommerce_available_download_end', $download );
?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<h2><?php _e( 'Recent Orders', 'woocommerce' ); ?></h2>
<?php do_action( 'woocommerce_between_my_account_downloads_and_orders' ); ?>
<?php woocommerce_get_template( 'myaccount/my-orders.php', array( 'recent_orders' => $recent_orders ) ); ?>
<h2><?php _e( 'My Address', 'woocommerce' ); ?></h2>
<p class="myaccount_address"><?php _e( 'The following addresses will be used on the checkout page by default.', 'woocommerce' ); ?></p>
<?php do_action( 'woocommerce_between_my_account_orders_and_address' ); ?>
<?php woocommerce_get_template( 'myaccount/my-address.php' ); ?>

View File

@ -14,6 +14,10 @@ global $woocommerce;
$customer_id = get_current_user_id();
?>
<h2><?php echo apply_filters( 'woocommerce_my_address_title', __( 'My Address', 'woocommerce' ) ); ?></h2>
<p class="myaccount_address"><?php echo apply_filters( 'woocommerce_my_address_description', __( 'The following addresses will be used on the checkout page by default.', 'woocommerce' ) ); ?></p>
<?php if (get_option('woocommerce_ship_to_billing_address_only')=='no') : ?>
<div class="col2-set addresses">

View File

@ -0,0 +1,39 @@
<?php
/**
* My Orders
*
* Shows recent orders on the account page
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 1.6.4
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
global $woocommerce;
if ( $downloads = $woocommerce->customer->get_downloadable_products() ) : ?>
<h2><?php echo apply_filters( 'woocommerce_available_downloads_title', __( 'Available downloads', 'woocommerce' ) ); ?></h2>
<ul class="digital-downloads">
<?php foreach ( $downloads as $download ) : ?>
<li>
<?php
do_action( 'woocommerce_available_download_start', $download );
if ( is_numeric( $download['downloads_remaining'] ) )
echo apply_filters( 'woocommerce_available_download_count', '<span class="count">' . sprintf( _n( '%s download remaining', '%s downloads remaining', $download['downloads_remaining'], 'woocommerce' ), $download['downloads_remaining'] ) . '</span> ', $download );
echo apply_filters( 'woocommerce_available_download_link', '<a href="' . esc_url( $download['download_url'] ) . '">' . $download['download_name'] . '</a>', $download );
do_action( 'woocommerce_available_download_end', $download );
?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>

View File

@ -24,6 +24,8 @@ $args = array(
);
$customer_orders = get_posts($args);
echo '<h2>' . apply_filters( 'woocommerce_recent_orders_title', __( 'Recent Orders', 'woocommerce' ) ) . '</h2>';
if ($customer_orders) :
?>
<table class="shop_table my_account_orders">