Merge pull request #10110 from woothemes/tabbed-my-account

Tabbed my account
This commit is contained in:
Claudio Sanches 2016-02-16 14:07:40 -02:00
commit 60e8432474
26 changed files with 1042 additions and 295 deletions

File diff suppressed because one or more lines are too long

View File

@ -1552,6 +1552,20 @@ p.demo_store {
* Account page
*/
.woocommerce-account {
.woocommerce {
@include clearfix();
}
.my-account-navigation {
float: left;
width: 30%;
}
.my-account-content {
float: right;
width: 68%;
}
.addresses {
.title {
@include clearfix();
@ -1923,7 +1937,7 @@ p.demo_store {
}
/**
* Password strength meter
* Password strength meter
*/
.woocommerce-password-strength {
text-align: center;

View File

@ -57,6 +57,15 @@ class WC_Settings_Accounts extends WC_Settings_Page {
array( 'title' => __( 'My Account Endpoints', 'woocommerce' ), 'type' => 'title', 'desc' => __( 'Endpoints are appended to your page URLs to handle specific actions on the accounts pages. They should be unique.', 'woocommerce' ), 'id' => 'account_endpoint_options' ),
array(
'title' => __( 'Orders', 'woocommerce' ),
'desc' => __( 'Endpoint for the My Account → Orders page', 'woocommerce' ),
'id' => 'woocommerce_myaccount_orders_endpoint',
'type' => 'text',
'default' => 'orders',
'desc_tip' => true,
),
array(
'title' => __( 'View Order', 'woocommerce' ),
'desc' => __( 'Endpoint for the My Account → View Order page', 'woocommerce' ),
@ -66,6 +75,15 @@ class WC_Settings_Accounts extends WC_Settings_Page {
'desc_tip' => true,
),
array(
'title' => __( 'Downloads', 'woocommerce' ),
'desc' => __( 'Endpoint for the My Account → Downloads page', 'woocommerce' ),
'id' => 'woocommerce_myaccount_downloads_endpoint',
'type' => 'text',
'default' => 'downloads',
'desc_tip' => true,
),
array(
'title' => __( 'Edit Account', 'woocommerce' ),
'desc' => __( 'Endpoint for the My Account → Edit Account page', 'woocommerce' ),
@ -84,6 +102,15 @@ class WC_Settings_Accounts extends WC_Settings_Page {
'desc_tip' => true,
),
array(
'title' => __( 'Payment Methods', 'woocommerce' ),
'desc' => __( 'Endpoint for the My Account → Payment Methods page', 'woocommerce' ),
'id' => 'woocommerce_myaccount_payment_methods_endpoint',
'type' => 'text',
'default' => 'payment-methods',
'desc_tip' => true,
),
array(
'title' => __( 'Lost Password', 'woocommerce' ),
'desc' => __( 'Endpoint for the My Account → Lost Password page', 'woocommerce' ),

View File

@ -60,16 +60,19 @@ class WC_Query {
* Init query vars by loading options.
*/
public function init_query_vars() {
// Query vars to add to WP
// Query vars to add to WP.
$this->query_vars = array(
// Checkout actions
// Checkout actions.
'order-pay' => get_option( 'woocommerce_checkout_pay_endpoint', 'order-pay' ),
'order-received' => get_option( 'woocommerce_checkout_order_received_endpoint', 'order-received' ),
// My account actions
// My account actions.
'orders' => get_option( 'woocommerce_myaccount_orders_endpoint', 'orders' ),
'view-order' => get_option( 'woocommerce_myaccount_view_order_endpoint', 'view-order' ),
'downloads' => get_option( 'woocommerce_myaccount_downloads_endpoint', 'downloads' ),
'edit-account' => get_option( 'woocommerce_myaccount_edit_account_endpoint', 'edit-account' ),
'edit-address' => get_option( 'woocommerce_myaccount_edit_address_endpoint', 'edit-address' ),
'payment-methods' => get_option( 'woocommerce_myaccount_payment_methods_endpoint', 'payment-methods' ),
'lost-password' => get_option( 'woocommerce_myaccount_lost_password_endpoint', 'lost-password' ),
'customer-logout' => get_option( 'woocommerce_logout_endpoint', 'customer-logout' ),
'add-payment-method' => get_option( 'woocommerce_myaccount_add_payment_method_endpoint', 'add-payment-method' ),
@ -91,16 +94,29 @@ class WC_Query {
case 'order-received' :
$title = __( 'Order Received', 'woocommerce' );
break;
case 'orders' :
if ( ! empty( $wp->query_vars['orders'] ) ) {
$title = sprintf( __( 'Orders (page %d)', 'woocommerce' ), intval( $wp->query_vars['orders'] ) );
} else {
$title = __( 'Orders', 'woocommerce' );
}
break;
case 'view-order' :
$order = wc_get_order( $wp->query_vars['view-order'] );
$title = ( $order ) ? sprintf( __( 'Order #%s', 'woocommerce' ), $order->get_order_number() ) : '';
break;
case 'downloads' :
$title = __( 'Downloads', 'woocommerce' );
break;
case 'edit-account' :
$title = __( 'Edit Account Details', 'woocommerce' );
break;
case 'edit-address' :
$title = __( 'Edit Address', 'woocommerce' );
break;
case 'payment-methods' :
$title = __( 'Payment Methods', 'woocommerce' );
break;
case 'add-payment-method' :
$title = __( 'Add Payment Method', 'woocommerce' );
break;
@ -108,9 +124,10 @@ class WC_Query {
$title = __( 'Lost Password', 'woocommerce' );
break;
default :
$title = '';
$title = apply_filters( 'woocommerce_endpoint_' . $endpoint . '_title', '' );
break;
}
return $title;
}

View File

@ -35,7 +35,6 @@ class WC_Shortcode_My_Account {
}
if ( ! is_user_logged_in() ) {
$message = apply_filters( 'woocommerce_my_account_message', '' );
if ( ! empty( $message ) ) {
@ -43,37 +42,23 @@ class WC_Shortcode_My_Account {
}
if ( isset( $wp->query_vars['lost-password'] ) ) {
self::lost_password();
} else {
wc_get_template( 'myaccount/form-login.php' );
}
} else if (
isset( $wp->query_vars['page'] ) // Regular page with shortcode.
|| empty( $wp->query_vars ) // When My Account page is the front page.
) {
self::my_account( $atts );
} else {
foreach ( $wp->query_vars as $key => $value ) {
// Ignore pagename param.
if ( 'pagename' === $key ) {
continue;
}
if ( ! empty( $wp->query_vars['view-order'] ) ) {
self::view_order( absint( $wp->query_vars['view-order'] ) );
} elseif ( isset( $wp->query_vars['edit-account'] ) ) {
self::edit_account();
} elseif ( isset( $wp->query_vars['edit-address'] ) ) {
self::edit_address( wc_edit_address_i18n( sanitize_title( $wp->query_vars['edit-address'] ), true ) );
} elseif ( isset( $wp->query_vars['add-payment-method'] ) ) {
self::add_payment_method();
} else {
self::my_account( $atts );
do_action( 'woocommerce_account_' . $key . '_endpoint', $value );
}
}
}
@ -81,28 +66,28 @@ class WC_Shortcode_My_Account {
/**
* My account page.
*
* @param array $atts
* @param array $atts
*/
private static function my_account( $atts ) {
extract( shortcode_atts( array(
'order_count' => 15
'order_count' => 15 // @deprecated 2.6.0. Keep for backward compatibility.
), $atts ) );
wc_get_template( 'myaccount/my-account.php', array(
'current_user' => get_user_by( 'id', get_current_user_id() ),
'order_count' => 'all' == $order_count ? -1 : $order_count
'current_user' => get_user_by( 'id', get_current_user_id() ),
'order_count' => 'all' == $order_count ? -1 : $order_count
) );
}
/**
* View order page.
*
* @param int $order_id
* @param int $order_id
*/
private static function view_order( $order_id ) {
public static function view_order( $order_id ) {
$user_id = get_current_user_id();
$order = wc_get_order( $order_id );
$user_id = get_current_user_id();
$order = wc_get_order( $order_id );
if ( ! current_user_can( 'view_order', $order_id ) ) {
echo '<div class="woocommerce-error">' . __( 'Invalid order.', 'woocommerce' ) . ' <a href="' . wc_get_page_permalink( 'myaccount' ).'" class="wc-forward">'. __( 'My Account', 'woocommerce' ) .'</a>' . '</div>';
@ -123,17 +108,16 @@ class WC_Shortcode_My_Account {
/**
* Edit account details page.
*/
private static function edit_account() {
public static function edit_account() {
wc_get_template( 'myaccount/form-edit-account.php', array( 'user' => get_user_by( 'id', get_current_user_id() ) ) );
}
/**
* Edit address page.
*
* @access public
* @param string $load_address
*/
private static function edit_address( $load_address = 'billing' ) {
public static function edit_address( $load_address = 'billing' ) {
$current_user = wp_get_current_user();
$load_address = sanitize_key( $load_address );
@ -204,7 +188,6 @@ class WC_Shortcode_My_Account {
*
* Based on retrieve_password() in core wp-login.php.
*
* @access public
* @uses $wpdb WordPress Database object
* @return bool True: when finish. False: on error
*/
@ -340,7 +323,7 @@ class WC_Shortcode_My_Account {
/**
* Show the add payment method page.
*/
private static function add_payment_method() {
public static function add_payment_method() {
if ( ! is_user_logged_in() ) {

View File

@ -0,0 +1,210 @@
<?php
/**
* WooCommerce Account Functions
*
* Functions for account specific things.
*
* @author WooThemes
* @category Core
* @package WooCommerce/Functions
* @version 2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Returns the url to the lost password endpoint url.
*
* @access public
* @param string $default_url
* @return string
*/
function wc_lostpassword_url( $default_url = '' ) {
$wc_password_reset_url = wc_get_page_permalink( 'myaccount' );
if ( false !== $wc_password_reset_url ) {
return wc_get_endpoint_url( 'lost-password', '', $wc_password_reset_url );
} else {
return $default_url;
}
}
add_filter( 'lostpassword_url', 'wc_lostpassword_url', 10, 1 );
/**
* Get the link to the edit account details page.
*
* @return string
*/
function wc_customer_edit_account_url() {
$edit_account_url = wc_get_endpoint_url( 'edit-account', '', wc_get_page_permalink( 'myaccount' ) );
return apply_filters( 'woocommerce_customer_edit_account_url', $edit_account_url );
}
/**
* Get the edit address slug translation.
*
* @param string $id Address ID.
* @param bool $flip Flip the array to make it possible to retrieve the values from both sides.
*
* @return string Address slug i18n.
*/
function wc_edit_address_i18n( $id, $flip = false ) {
$slugs = apply_filters( 'woocommerce_edit_address_slugs', array(
'billing' => sanitize_title( _x( 'billing', 'edit-address-slug', 'woocommerce' ) ),
'shipping' => sanitize_title( _x( 'shipping', 'edit-address-slug', 'woocommerce' ) )
) );
if ( $flip ) {
$slugs = array_flip( $slugs );
}
if ( ! isset( $slugs[ $id ] ) ) {
return $id;
}
return $slugs[ $id ];
}
/**
* Get My Account menu items.
*
* @since 2.6.0
* @return array
*/
function wc_get_account_menu_items() {
return apply_filters( 'woocommerce_account_menu_items', array(
'dashboard' => __( 'Dashboard', 'woocommerce' ),
'orders' => __( 'Orders', 'woocommerce' ),
'downloads' => __( 'Downloads', 'woocommerce' ),
'edit-address' => __( 'Addresses', 'woocommerce' ),
'payment-methods' => __( 'Payment Methods', 'woocommerce' ),
'edit-account' => __( 'Account Details', 'woocommerce' ),
'customer-logout' => __( 'Logout', 'woocommerce' ),
) );
}
/**
* Get account menu item classes.
*
* @since 2.6.0
* @param string $endpoint
* @return string
*/
function wc_get_account_menu_item_classes( $endpoint ) {
global $wp;
$classes = array(
'my-account-menu-item-' . $endpoint,
);
// Set current item class.
$current = isset( $wp->query_vars[ $endpoint ] );
if ( 'dashboard' === $endpoint && ( isset( $wp->query_vars['page'] ) || empty( $wp->query_vars ) ) ) {
$current = true; // Dashboard is not an endpoint, so needs a custom check.
}
if ( $current ) {
$classes[] = 'current-item';
}
$classes = apply_filters( 'woocommerce_account_menu_item_classes', $classes, $endpoint );
return implode( ' ', array_map( 'sanitize_html_class', $classes ) );
}
/**
* Get account endpoint URL.
*
* @since 2.6.0
* @param string $endpoint
* @return string
*/
function wc_get_account_endpoint_url( $endpoint ) {
if ( 'dashboard' === $endpoint ) {
return wc_get_page_permalink( 'myaccount' );
}
return wc_get_endpoint_url( $endpoint );
}
/**
* Get My Account > Orders columns.
*
* @since 2.6.0
* @return array
*/
function wc_get_account_orders_columns() {
$columns = apply_filters( 'woocommerce_account_orders_columns', array(
'order-number' => __( 'Order', 'woocommerce' ),
'order-date' => __( 'Date', 'woocommerce' ),
'order-status' => __( 'Status', 'woocommerce' ),
'order-total' => __( 'Total', 'woocommerce' ),
'order-actions' => '&nbsp;',
) );
// Deprecated filter since 2.6.0.
return apply_filters( 'woocommerce_my_account_my_orders_columns', $columns );
}
/**
* Get My Account > Orders query args.
*
* @since 2.6.0
* @param int $current_page
* @return array
*/
function wc_get_account_orders_query_args( $current_page = 1 ) {
$args = array(
'numberposts' => 15,
'meta_key' => '_customer_user',
'meta_value' => get_current_user_id(),
'post_type' => wc_get_order_types( 'view-orders' ),
'post_status' => array_keys( wc_get_order_statuses() ),
);
// @deprecated 2.6.0.
$args = apply_filters( 'woocommerce_my_account_my_orders_query', $args );
// Remove deprecated option.
$args['posts_per_page'] = $args['numberposts'];
unset( $args['numberposts'] );
if ( 1 < $current_page ) {
$args['paged'] = absint( $current_page );
}
return apply_filters( 'woocommerce_account_orders_query', $args );
}
/**
* Get My Account > Downloads columns.
*
* @since 2.6.0
* @return array
*/
function wc_get_account_downloads_columns() {
return apply_filters( 'woocommerce_account_orders_columns', array(
'download-file' => __( 'File', 'woocommerce' ),
'download-remaining' => __( 'Remaining', 'woocommerce' ),
'download-expires' => __( 'Expires', 'woocommerce' ),
'download-actions' => '&nbsp;',
) );
}
/**
* Get My Account > Payment methods columns.
*
* @since 2.6.0
* @return array
*/
function wc_get_account_payment_methods_columns() {
return apply_filters( 'woocommerce_account_orders_columns', array(
'method' => __( 'Method', 'woocommerce' ),
'expires' => __( 'Expires', 'woocommerce' ),
'actions' => '&nbsp;',
) );
}

View File

@ -23,6 +23,7 @@ include( 'wc-formatting-functions.php' );
include( 'wc-order-functions.php' );
include( 'wc-page-functions.php' );
include( 'wc-product-functions.php' );
include( 'wc-account-functions.php' );
include( 'wc-term-functions.php' );
include( 'wc-attribute-functions.php' );

View File

@ -4,10 +4,10 @@
*
* Functions related to pages and menus.
*
* @author WooThemes
* @category Core
* @package WooCommerce/Functions
* @version 2.1.0
* @author WooThemes
* @category Core
* @package WooCommerce/Functions
* @version 2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@ -107,60 +107,6 @@ function wc_get_endpoint_url( $endpoint, $value = '', $permalink = '' ) {
return apply_filters( 'woocommerce_get_endpoint_url', $url, $endpoint, $value, $permalink );
}
/**
* Get the edit address slug translation.
*
* @param string $id Address ID.
* @param bool $flip Flip the array to make it possible to retrieve the values from both sides.
*
* @return string Address slug i18n.
*/
function wc_edit_address_i18n( $id, $flip = false ) {
$slugs = apply_filters( 'woocommerce_edit_address_slugs', array(
'billing' => sanitize_title( _x( 'billing', 'edit-address-slug', 'woocommerce' ) ),
'shipping' => sanitize_title( _x( 'shipping', 'edit-address-slug', 'woocommerce' ) )
) );
if ( $flip ) {
$slugs = array_flip( $slugs );
}
if ( ! isset( $slugs[ $id ] ) ) {
return $id;
}
return $slugs[ $id ];
}
/**
* Returns the url to the lost password endpoint url.
*
* @access public
* @param string $default_url
* @return string
*/
function wc_lostpassword_url( $default_url = '' ) {
$wc_password_reset_url = wc_get_page_permalink( 'myaccount' );
if ( false !== $wc_password_reset_url ) {
return wc_get_endpoint_url( 'lost-password', '', $wc_password_reset_url );
} else {
return $default_url;
}
}
add_filter( 'lostpassword_url', 'wc_lostpassword_url', 10, 1 );
/**
* Get the link to the edit account details page.
*
* @return string
*/
function wc_customer_edit_account_url() {
$edit_account_url = wc_get_endpoint_url( 'edit-account', '', wc_get_page_permalink( 'myaccount' ) );
return apply_filters( 'woocommerce_customer_edit_account_url', $edit_account_url );
}
/**
* Hide menu items conditionally.
*

View File

@ -2023,5 +2023,84 @@ if ( ! function_exists( 'wc_dropdown_variation_attribute_options' ) ) {
echo apply_filters( 'woocommerce_dropdown_variation_attribute_options_html', $html, $args );
}
}
if ( ! function_exists( 'woocommerce_account_orders' ) ) {
/**
* My Account > Orders template.
*
* @param int $current_page Current page number.
*/
function woocommerce_account_orders( $current_page ) {
$current_page = empty( $current_page ) ? 1 : $current_page;
wc_get_template( 'myaccount/orders.php', array( 'current_page' => absint( $current_page ) ) );
}
}
if ( ! function_exists( 'woocommerce_account_view_order' ) ) {
/**
* My Account > View order template.
*
* @param int $order_id Order ID.
*/
function woocommerce_account_view_order( $order_id ) {
WC_Shortcode_My_Account::view_order( absint( $order_id ) );
}
}
if ( ! function_exists( 'woocommerce_account_downloads' ) ) {
/**
* My Account > Downloads template.
*/
function woocommerce_account_downloads() {
wc_get_template( 'myaccount/downloads.php' );
}
}
if ( ! function_exists( 'woocommerce_account_edit_address' ) ) {
/**
* My Account > Edit address template.
*
* @param string $type Address type.
*/
function woocommerce_account_edit_address( $type ) {
$type = wc_edit_address_i18n( sanitize_title( $type ), true );
WC_Shortcode_My_Account::edit_address( $type );
}
}
if ( ! function_exists( 'woocommerce_account_payment_methods' ) ) {
/**
* My Account > Downloads template.
*/
function woocommerce_account_payment_methods() {
wc_get_template( 'myaccount/payment-methods.php' );
}
}
if ( ! function_exists( 'woocommerce_account_add_payment_method' ) ) {
/**
* My Account > Add payment method template.
*/
function woocommerce_account_add_payment_method() {
WC_Shortcode_My_Account::add_payment_method();
}
}
if ( ! function_exists( 'woocommerce_account_edit_account' ) ) {
/**
* My Account > Edit account template.
*/
function woocommerce_account_edit_account() {
WC_Shortcode_My_Account::edit_account();
}
}

View File

@ -239,3 +239,14 @@ add_action( 'woocommerce_auth_page_footer', 'woocommerce_output_auth_footer', 10
* Disable Jetpack comments.
*/
add_filter( 'jetpack_comment_form_enabled_for_product', '__return_false' );
/**
* My Account.
*/
add_action( 'woocommerce_account_orders_endpoint', 'woocommerce_account_orders' );
add_action( 'woocommerce_account_view-order_endpoint', 'woocommerce_account_view_order' );
add_action( 'woocommerce_account_downloads_endpoint', 'woocommerce_account_downloads' );
add_action( 'woocommerce_account_edit-address_endpoint', 'woocommerce_account_edit_address' );
add_action( 'woocommerce_account_payment-methods_endpoint', 'woocommerce_account_payment_methods' );
add_action( 'woocommerce_account_add-payment-method_endpoint', 'woocommerce_account_add_payment_method' );
add_action( 'woocommerce_account_edit-account_endpoint', 'woocommerce_account_edit_account' );

View File

@ -585,9 +585,9 @@ add_action( 'template_redirect', 'wc_disable_author_archives_for_customers' );
/**
* Hooks into the `profile_update` hook to set the user last updated timestamp.
*
* @since 2.6
* @param int $user_id The user that was updated
* @param array $old The profile fields pre-change
* @since 2.6.0
* @param int $user_id The user that was updated.
* @param array $old The profile fields pre-change.
*/
function wc_update_profile_last_update_time( $user_id, $old ) {
wc_set_user_last_update_time( $user_id );
@ -598,11 +598,11 @@ add_action( 'profile_update', 'wc_update_profile_last_update_time', 10, 2 );
/**
* Hooks into the update user meta function to set the user last updated timestamp.
*
* @since 2.6
* @param int $meta_id ID of the meta object that was changed
* @param int $user_id The user that was updated
* @param string $meta_key Name of the meta key that was changed
* @param string $_meta_value Value of the meta that was changed
* @since 2.6.0
* @param int $meta_id ID of the meta object that was changed.
* @param int $user_id The user that was updated.
* @param string $meta_key Name of the meta key that was changed.
* @param string $_meta_value Value of the meta that was changed.
*/
function wc_meta_update_last_update_time( $meta_id, $user_id, $meta_key, $_meta_value ) {
$keys_to_track = apply_filters( 'woocommerce_user_last_update_fields', array( 'first_name', 'last_name' ) );
@ -627,9 +627,20 @@ add_action( 'update_user_meta', 'wc_meta_update_last_update_time', 10, 4 );
/**
* Sets a user's "last update" time to the current timestamp.
*
* @since 2.6
* @param int $user_id The user to set a timestamp for
* @since 2.6.0
* @param int $user_id The user to set a timestamp for.
*/
function wc_set_user_last_update_time( $user_id ) {
update_user_meta( $user_id, 'last_update', time() );
}
/**
* Get customer saved payment methods list.
*
* @since 2.6.0
* @param int $customer_id
* @return array
*/
function wc_get_customer_saved_methods_list( $customer_id ) {
return apply_filters( 'woocommerce_saved_payment_methods_list', array(), $customer_id );
}

View File

@ -0,0 +1,103 @@
<?php
/**
* Downloads
*
* Shows downloads on the account page.
*
* This template can be overridden by copying it to yourtheme/woocommerce/myaccount/downloads.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you (the theme developer).
* will need to copy the new files to your theme to maintain compatibility. We try to do this.
* as little as possible, but it does happen. When this occurs the version of the template file will.
* be bumped and the readme will list any important changes.
*
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$downloads = WC()->customer->get_downloadable_products();
$has_downloads = (bool) $downloads;
wc_print_notices(); ?>
<?php wc_get_template( 'myaccount/navigation.php' ); ?>
<div class="my-account-content">
<?php do_action( 'woocommerce_before_account_downloads', $has_downloads ); ?>
<?php if ( $has_downloads ) : ?>
<?php do_action( 'woocommerce_before_available_downloads' ); ?>
<table class="shop_table shop_table_responsive account-downloads-table">
<thead>
<tr>
<?php foreach ( wc_get_account_downloads_columns() as $column_id => $column_name ) : ?>
<th class="<?php echo esc_attr( $column_id ); ?>"><span class="nobr"><?php echo esc_html( $column_name ); ?></span></th>
<?php endforeach; ?>
</tr>
</thead>
<?php foreach ( $downloads as $download ) : ?>
<tr class="download">
<?php foreach ( wc_get_account_downloads_columns() as $column_id => $column_name ) : ?>
<td class="<?php echo esc_attr( $column_id ); ?>" data-title="<?php echo esc_attr( $column_name ); ?>">
<?php if ( has_action( 'woocommerce_account_downloads_column_' . $column_id ) ) : ?>
<?php do_action( 'woocommerce_account_downloads_column_' . $column_id, $download ); ?>
<?php elseif ( 'download-file' === $column_id ) : ?>
<a href="<?php echo esc_url( get_permalink( $download['product_id'] ) ); ?>">
<?php echo esc_html( $download['download_name'] ); ?>
</a>
<?php elseif ( 'download-remaining' === $column_id ) : ?>
<?php
if ( is_numeric( $download['downloads_remaining'] ) ) {
echo esc_html( $download['downloads_remaining'] );
} else {
_e( '&infin;', 'woocommerce' );
}
?>
<?php elseif ( 'download-expires' === $column_id ) : ?>
<?php if ( ! empty( $download['access_expires'] ) ) : ?>
<time datetime="<?php echo date( 'Y-m-d', strtotime( $download['access_expires'] ) ); ?>" title="<?php echo esc_attr( strtotime( $download['access_expires'] ) ); ?>"><?php echo date_i18n( get_option( 'date_format' ), strtotime( $download['access_expires'] ) ); ?></time>
<?php else : ?>
<?php _e( 'Never', 'woocommerce' ); ?>
<?php endif; ?>
<?php elseif ( 'download-actions' === $column_id ) : ?>
<?php
$actions = array(
'download' => array(
'url' => $download['download_url'],
'name' => __( 'Download', 'woocommerce' )
)
);
if ( $actions = apply_filters( 'woocommerce_account_download_actions', $actions, $download ) ) {
foreach ( $actions as $key => $action ) {
echo '<a href="' . esc_url( $action['url'] ) . '" class="button ' . sanitize_html_class( $key ) . '">' . esc_html( $action['name'] ) . '</a>';
}
}
?>
<?php endif; ?>
</td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</table>
<?php do_action( 'woocommerce_after_available_downloads' ); ?>
<?php endif; ?>
<?php do_action( 'woocommerce_after_account_downloads', $has_downloads ); ?>
</div>

View File

@ -10,49 +10,55 @@
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.1
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<form id="add_payment_method" method="post">
<div id="payment">
<?php if ( $available_gateways = WC()->payment_gateways->get_available_payment_gateways() ) : ?>
<ul class="payment_methods methods"><?php
// Chosen Method
if ( sizeof( $available_gateways ) ) {
current( $available_gateways )->set_current();
}
wc_get_template( 'myaccount/navigation.php' ); ?>
foreach ( $available_gateways as $gateway ) {
?>
<li class="payment_method_<?php echo $gateway->id; ?>">
<input id="payment_method_<?php echo $gateway->id; ?>" type="radio" class="input-radio" name="payment_method" value="<?php echo esc_attr( $gateway->id ); ?>" <?php checked( $gateway->chosen, true ); ?> />
<label for="payment_method_<?php echo $gateway->id; ?>"><?php echo $gateway->get_title(); ?> <?php echo $gateway->get_icon(); ?></label>
<?php
if ( $gateway->has_fields() || $gateway->get_description() ) {
echo '<div class="payment_box payment_method_' . $gateway->id . '" style="display:none;">';
$gateway->payment_fields();
echo '</div>';
}
?>
</li>
<div class="my-account-content">
<?php if ( $available_gateways = WC()->payment_gateways->get_available_payment_gateways() ) : ?>
<form id="add_payment_method" method="post">
<div id="payment">
<ul class="payment_methods methods">
<?php
}
?></ul>
<div class="form-row">
<?php wp_nonce_field( 'woocommerce-add-payment-method' ); ?>
<input type="submit" class="button alt" id="place_order" value="<?php esc_attr_e( 'Add Payment Method', 'woocommerce' ); ?>" />
<input type="hidden" name="woocommerce_add_payment_method" value="1" />
// Chosen Method.
if ( count( $available_gateways ) ) {
current( $available_gateways )->set_current();
}
foreach ( $available_gateways as $gateway ) {
?>
<li class="payment_method_<?php echo $gateway->id; ?>">
<input id="payment_method_<?php echo $gateway->id; ?>" type="radio" class="input-radio" name="payment_method" value="<?php echo esc_attr( $gateway->id ); ?>" <?php checked( $gateway->chosen, true ); ?> />
<label for="payment_method_<?php echo $gateway->id; ?>"><?php echo $gateway->get_title(); ?> <?php echo $gateway->get_icon(); ?></label>
<?php
if ( $gateway->has_fields() || $gateway->get_description() ) {
echo '<div class="payment_box payment_method_' . $gateway->id . '" style="display: none;">';
$gateway->payment_fields();
echo '</div>';
}
?>
</li>
<?php
}
?>
</ul>
<div class="form-row">
<?php wp_nonce_field( 'woocommerce-add-payment-method' ); ?>
<input type="submit" class="button alt" id="place_order" value="<?php esc_attr_e( 'Add Payment Method', 'woocommerce' ); ?>" />
<input type="hidden" name="woocommerce_add_payment_method" value="1" />
</div>
</div>
<?php else : ?>
<p><?php _e( 'Sorry, it seems that there are no payment methods which support adding a new payment method. Please contact us if you require assistance or wish to make alternate arrangements.', 'woocommerce' ); ?></p>
<?php endif; ?>
</div>
</form>
</form>
<?php else : ?>
<p><?php esc_html_e( 'Sorry, it seems that there are no payment methods which support adding a new payment method. Please contact us if you require assistance or wish to make alternate arrangements.', 'woocommerce' ); ?></p>
<?php endif; ?>
</div>

View File

@ -10,64 +10,66 @@
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.5.1
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
exit;
}
?>
<?php wc_print_notices(); ?>
wc_print_notices();
<form class="edit-account" action="" method="post">
wc_get_template( 'myaccount/navigation.php' ); ?>
<?php do_action( 'woocommerce_edit_account_form_start' ); ?>
<div class="my-account-content">
<form class="edit-account" action="" method="post">
<p class="form-row form-row-first">
<label for="account_first_name"><?php _e( 'First name', 'woocommerce' ); ?> <span class="required">*</span></label>
<input type="text" class="input-text" name="account_first_name" id="account_first_name" value="<?php echo esc_attr( $user->first_name ); ?>" />
</p>
<p class="form-row form-row-last">
<label for="account_last_name"><?php _e( 'Last name', 'woocommerce' ); ?> <span class="required">*</span></label>
<input type="text" class="input-text" name="account_last_name" id="account_last_name" value="<?php echo esc_attr( $user->last_name ); ?>" />
</p>
<div class="clear"></div>
<?php do_action( 'woocommerce_edit_account_form_start' ); ?>
<p class="form-row form-row-wide">
<label for="account_email"><?php _e( 'Email address', 'woocommerce' ); ?> <span class="required">*</span></label>
<input type="email" class="input-text" name="account_email" id="account_email" value="<?php echo esc_attr( $user->user_email ); ?>" />
</p>
<fieldset>
<legend><?php _e( 'Password Change', 'woocommerce' ); ?></legend>
<p class="form-row form-row-first">
<label for="account_first_name"><?php _e( 'First name', 'woocommerce' ); ?> <span class="required">*</span></label>
<input type="text" class="input-text" name="account_first_name" id="account_first_name" value="<?php echo esc_attr( $user->first_name ); ?>" />
</p>
<p class="form-row form-row-last">
<label for="account_last_name"><?php _e( 'Last name', 'woocommerce' ); ?> <span class="required">*</span></label>
<input type="text" class="input-text" name="account_last_name" id="account_last_name" value="<?php echo esc_attr( $user->last_name ); ?>" />
</p>
<div class="clear"></div>
<p class="form-row form-row-wide">
<label for="password_current"><?php _e( 'Current Password (leave blank to leave unchanged)', 'woocommerce' ); ?></label>
<input type="password" class="input-text" name="password_current" id="password_current" />
<label for="account_email"><?php _e( 'Email address', 'woocommerce' ); ?> <span class="required">*</span></label>
<input type="email" class="input-text" name="account_email" id="account_email" value="<?php echo esc_attr( $user->user_email ); ?>" />
</p>
<p class="form-row form-row-wide">
<label for="password_1"><?php _e( 'New Password (leave blank to leave unchanged)', 'woocommerce' ); ?></label>
<input type="password" class="input-text" name="password_1" id="password_1" />
<fieldset>
<legend><?php _e( 'Password Change', 'woocommerce' ); ?></legend>
<p class="form-row form-row-wide">
<label for="password_current"><?php _e( 'Current Password (leave blank to leave unchanged)', 'woocommerce' ); ?></label>
<input type="password" class="input-text" name="password_current" id="password_current" />
</p>
<p class="form-row form-row-wide">
<label for="password_1"><?php _e( 'New Password (leave blank to leave unchanged)', 'woocommerce' ); ?></label>
<input type="password" class="input-text" name="password_1" id="password_1" />
</p>
<p class="form-row form-row-wide">
<label for="password_2"><?php _e( 'Confirm New Password', 'woocommerce' ); ?></label>
<input type="password" class="input-text" name="password_2" id="password_2" />
</p>
</fieldset>
<div class="clear"></div>
<?php do_action( 'woocommerce_edit_account_form' ); ?>
<p>
<?php wp_nonce_field( 'save_account_details' ); ?>
<input type="submit" class="button" name="save_account_details" value="<?php esc_attr_e( 'Save changes', 'woocommerce' ); ?>" />
<input type="hidden" name="action" value="save_account_details" />
</p>
<p class="form-row form-row-wide">
<label for="password_2"><?php _e( 'Confirm New Password', 'woocommerce' ); ?></label>
<input type="password" class="input-text" name="password_2" id="password_2" />
</p>
</fieldset>
<div class="clear"></div>
<?php do_action( 'woocommerce_edit_account_form' ); ?>
<p>
<?php wp_nonce_field( 'save_account_details' ); ?>
<input type="submit" class="button" name="save_account_details" value="<?php esc_attr_e( 'Save changes', 'woocommerce' ); ?>" />
<input type="hidden" name="action" value="save_account_details" />
</p>
<?php do_action( 'woocommerce_edit_account_form_end' ); ?>
</form>
<?php do_action( 'woocommerce_edit_account_form_end' ); ?>
</form>
</div>

View File

@ -10,10 +10,10 @@
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.1.0
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@ -25,32 +25,34 @@ $page_title = ( $load_address === 'billing' ) ? __( 'Billing Address', 'woocom
<?php wc_print_notices(); ?>
<?php if ( ! $load_address ) : ?>
<?php wc_get_template( 'myaccount/navigation.php' ); ?>
<?php wc_get_template( 'myaccount/my-address.php' ); ?>
<div class="my-account-content">
<?php if ( ! $load_address ) : ?>
<?php wc_get_template( 'myaccount/my-address.php' ); ?>
<?php else : ?>
<?php else : ?>
<form method="post">
<form method="post">
<h3><?php echo apply_filters( 'woocommerce_my_account_edit_address_title', $page_title ); ?></h3>
<h3><?php echo apply_filters( 'woocommerce_my_account_edit_address_title', $page_title ); ?></h3>
<?php do_action( "woocommerce_before_edit_address_form_{$load_address}" ); ?>
<?php do_action( "woocommerce_before_edit_address_form_{$load_address}" ); ?>
<?php foreach ( $address as $key => $field ) : ?>
<?php foreach ( $address as $key => $field ) : ?>
<?php woocommerce_form_field( $key, $field, ! empty( $_POST[ $key ] ) ? wc_clean( $_POST[ $key ] ) : $field['value'] ); ?>
<?php woocommerce_form_field( $key, $field, ! empty( $_POST[ $key ] ) ? wc_clean( $_POST[ $key ] ) : $field['value'] ); ?>
<?php endforeach; ?>
<?php endforeach; ?>
<?php do_action( "woocommerce_after_edit_address_form_{$load_address}" ); ?>
<?php do_action( "woocommerce_after_edit_address_form_{$load_address}" ); ?>
<p>
<input type="submit" class="button" name="save_address" value="<?php esc_attr_e( 'Save Address', 'woocommerce' ); ?>" />
<?php wp_nonce_field( 'woocommerce-edit_address' ); ?>
<input type="hidden" name="action" value="edit_address" />
</p>
<p>
<input type="submit" class="button" name="save_address" value="<?php esc_attr_e( 'Save Address', 'woocommerce' ); ?>" />
<?php wp_nonce_field( 'woocommerce-edit_address' ); ?>
<input type="hidden" name="action" value="edit_address" />
</p>
</form>
</form>
<?php endif; ?>
<?php endif; ?>
</div>

View File

@ -10,10 +10,10 @@
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.2.6
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.2.6
*/
if ( ! defined( 'ABSPATH' ) ) {

View File

@ -10,7 +10,7 @@
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see http://docs.woothemes.com/document/template-structure/
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.3.0

View File

@ -10,38 +10,55 @@
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.0.0
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
exit;
}
wc_print_notices(); ?>
<p class="myaccount_user">
<?php wc_get_template( 'myaccount/navigation.php' ); ?>
<div class="my-account-content">
<p class="myaccount_user">
<?php
printf(
__( 'Hello <strong>%1$s</strong> (not %1$s? <a href="%2$s">Sign out</a>).', 'woocommerce' ) . ' ',
$current_user->display_name,
wc_get_endpoint_url( 'customer-logout', '', wc_get_page_permalink( 'myaccount' ) )
);
_e( 'From your account dashboard you can view your recent orders, manage your shipping and billing addresses and edit your password and account details.', 'woocommerce' );
?>
</p>
<?php
printf(
__( 'Hello <strong>%1$s</strong> (not %1$s? <a href="%2$s">Sign out</a>).', 'woocommerce' ) . ' ',
$current_user->display_name,
wc_get_endpoint_url( 'customer-logout', '', wc_get_page_permalink( 'myaccount' ) )
);
printf( __( 'From your account dashboard you can view your recent orders, manage your shipping and billing addresses and <a href="%s">edit your password and account details</a>.', 'woocommerce' ),
wc_customer_edit_account_url()
);
/**
* My Account dashboard.
*
* @since 2.6.0
*/
do_action( 'woocommerce_account_dashboard' );
?>
</p>
<?php do_action( 'woocommerce_before_my_account' ); ?>
<?php
/**
* Deprecated woocommerce_before_my_account action.
*
* @deprecated 2.6.0
*/
do_action( 'woocommerce_before_my_account' );
<?php wc_get_template( 'myaccount/my-downloads.php' ); ?>
<?php wc_get_template( 'myaccount/my-orders.php', array( 'order_count' => $order_count ) ); ?>
<?php wc_get_template( 'myaccount/my-address.php' ); ?>
<?php do_action( 'woocommerce_after_my_account' ); ?>
/**
* Deprecated woocommerce_after_my_account action.
*
* @deprecated 2.6.0
*/
do_action( 'woocommerce_after_my_account' );
?>
</div>

View File

@ -10,10 +10,10 @@
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.2.0
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@ -24,13 +24,13 @@ $customer_id = get_current_user_id();
if ( ! wc_ship_to_billing_address_only() && wc_shipping_enabled() ) {
$page_title = apply_filters( 'woocommerce_my_account_my_address_title', __( 'My Addresses', 'woocommerce' ) );
$get_addresses = apply_filters( 'woocommerce_my_account_get_addresses', array(
$get_addresses = apply_filters( 'woocommerce_my_account_get_addresses', array(
'billing' => __( 'Billing Address', 'woocommerce' ),
'shipping' => __( 'Shipping Address', 'woocommerce' )
), $customer_id );
} else {
$page_title = apply_filters( 'woocommerce_my_account_my_address_title', __( 'My Address', 'woocommerce' ) );
$get_addresses = apply_filters( 'woocommerce_my_account_get_addresses', array(
$get_addresses = apply_filters( 'woocommerce_my_account_get_addresses', array(
'billing' => __( 'Billing Address', 'woocommerce' )
), $customer_id );
}
@ -51,7 +51,7 @@ $col = 1;
<div class="col-<?php echo ( ( $col = $col * -1 ) < 0 ) ? 1 : 2; ?> address">
<header class="title">
<h3><?php echo $title; ?></h3>
<a href="<?php echo wc_get_endpoint_url( 'edit-address', $name ); ?>" class="edit"><?php _e( 'Edit', 'woocommerce' ); ?></a>
<a href="<?php echo esc_url( wc_get_endpoint_url( 'edit-address', $name ) ); ?>" class="edit"><?php _e( 'Edit', 'woocommerce' ); ?></a>
</header>
<address>
<?php

View File

@ -1,8 +1,8 @@
<?php
/**
* My Orders
* My Downloads
*
* Shows recent orders on the account page.
* Shows downloads on the account page.
*
* This template can be overridden by copying it to yourtheme/woocommerce/myaccount/my-downloads.php.
*
@ -12,10 +12,11 @@
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.0.0
* @depreacated 2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {

View File

@ -12,10 +12,11 @@
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.5.0
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.5.0
* @depreacated 2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {

View File

@ -0,0 +1,32 @@
<?php
/**
* My Account navigation
*
* This template can be overridden by copying it to yourtheme/woocommerce/myaccount/navigation.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you (the theme developer).
* will need to copy the new files to your theme to maintain compatibility. We try to do this.
* as little as possible, but it does happen. When this occurs the version of the template file will.
* be bumped and the readme will list any important changes.
*
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<nav class="my-account-navigation">
<ul>
<?php foreach ( wc_get_account_menu_items() as $endpoint => $label ) : ?>
<li class="<?php echo wc_get_account_menu_item_classes( $endpoint ); ?>">
<a href="<?php echo esc_url( wc_get_account_endpoint_url( $endpoint ) ); ?>"><?php echo esc_html( $label ); ?></a>
</li>
<?php endforeach; ?>
</ul>
</nav>

View File

@ -0,0 +1,135 @@
<?php
/**
* Orders
*
* Shows orders on the account page.
*
* This template can be overridden by copying it to yourtheme/woocommerce/myaccount/orders.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you (the theme developer).
* will need to copy the new files to your theme to maintain compatibility. We try to do this.
* as little as possible, but it does happen. When this occurs the version of the template file will.
* be bumped and the readme will list any important changes.
*
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$customer_orders = new WP_Query( wc_get_account_orders_query_args( $current_page ) );
$has_orders = $customer_orders->have_posts();
wc_print_notices();
wc_get_template( 'myaccount/navigation.php' ); ?>
<div class="my-account-content">
<?php do_action( 'woocommerce_before_account_orders', $has_orders ); ?>
<?php if ( $has_orders ) : ?>
<table class="shop_table shop_table_responsive my_account_orders account-orders-table">
<thead>
<tr>
<?php foreach ( wc_get_account_orders_columns() as $column_id => $column_name ) : ?>
<th class="<?php echo esc_attr( $column_id ); ?>"><span class="nobr"><?php echo esc_html( $column_name ); ?></span></th>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
<?php foreach ( $customer_orders->posts as $customer_order ) :
$order = wc_get_order( $customer_order );
$item_count = $order->get_item_count();
?>
<tr class="order">
<?php foreach ( wc_get_account_orders_columns() as $column_id => $column_name ) : ?>
<td class="<?php echo esc_attr( $column_id ); ?>" data-title="<?php echo esc_attr( $column_name ); ?>">
<?php if ( has_action( 'woocommerce_my_account_my_orders_column_' . $column_id ) ) : ?>
<?php do_action( 'woocommerce_my_account_my_orders_column_' . $column_id, $order ); ?>
<?php elseif ( 'order-number' === $column_id ) : ?>
<a href="<?php echo esc_url( $order->get_view_order_url() ); ?>">
<?php echo _x( '#', 'hash before order number', 'woocommerce' ) . $order->get_order_number(); ?>
</a>
<?php elseif ( 'order-date' === $column_id ) : ?>
<time datetime="<?php echo date( 'Y-m-d', strtotime( $order->order_date ) ); ?>" title="<?php echo esc_attr( strtotime( $order->order_date ) ); ?>"><?php echo date_i18n( get_option( 'date_format' ), strtotime( $order->order_date ) ); ?></time>
<?php elseif ( 'order-status' === $column_id ) : ?>
<?php echo wc_get_order_status_name( $order->get_status() ); ?>
<?php elseif ( 'order-total' === $column_id ) : ?>
<?php echo sprintf( _n( '%s for %s item', '%s for %s items', $item_count, 'woocommerce' ), $order->get_formatted_order_total(), $item_count ); ?>
<?php elseif ( 'order-actions' === $column_id ) : ?>
<?php
$actions = array(
'pay' => array(
'url' => $order->get_checkout_payment_url(),
'name' => __( 'Pay', 'woocommerce' )
),
'view' => array(
'url' => $order->get_view_order_url(),
'name' => __( 'View', 'woocommerce' )
),
'cancel' => array(
'url' => $order->get_cancel_order_url( wc_get_page_permalink( 'myaccount' ) ),
'name' => __( 'Cancel', 'woocommerce' )
)
);
if ( ! $order->needs_payment() ) {
unset( $actions['pay'] );
}
if ( ! in_array( $order->get_status(), apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) ) ) {
unset( $actions['cancel'] );
}
if ( $actions = apply_filters( 'woocommerce_my_account_my_orders_actions', $actions, $order ) ) {
foreach ( $actions as $key => $action ) {
echo '<a href="' . esc_url( $action['url'] ) . '" class="button ' . sanitize_html_class( $key ) . '">' . esc_html( $action['name'] ) . '</a>';
}
}
?>
<?php endif; ?>
</td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php do_action( 'woocommerce_before_account_orders_pagination' ); ?>
<?php if ( 1 < $customer_orders->max_num_pages ) : ?>
<div class="wc-account-orders-pagination">
<?php if ( 1 !== $current_page ) : ?>
<a class="button" href="<?php echo esc_url( wc_get_endpoint_url( 'orders', $current_page - 1 ) ); ?>"><?php _e( 'Previous', 'woocommerce' ); ?></a>
<?php endif; ?>
<?php if ( $current_page !== intval( $customer_orders->max_num_pages ) ) : ?>
<a class="button" href="<?php echo esc_url( wc_get_endpoint_url( 'orders', $current_page + 1 ) ); ?>"><?php _e( 'Next', 'woocommerce' ); ?></a>
<?php endif; ?>
</div>
<?php endif; ?>
<?php else : ?>
<div class="woocommerce-info">
<a class="button" href="<?php echo esc_url( apply_filters( 'woocommerce_return_to_shop_redirect', wc_get_page_permalink( 'shop' ) ) ); ?>">
<?php _e( 'Go Shop', 'woocommerce' ) ?>
</a>
<?php _e( 'No order has been made yet.', 'woocommerce' ); ?>
</div>
<?php endif; ?>
<?php do_action( 'woocommerce_after_account_orders', $has_orders ); ?>
</div>

View File

@ -0,0 +1,78 @@
<?php
/**
* Payment methods
*
* Shows customer payment methods on the account page.
*
* This template can be overridden by copying it to yourtheme/woocommerce/myaccount/payment-methods.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you (the theme developer).
* will need to copy the new files to your theme to maintain compatibility. We try to do this.
* as little as possible, but it does happen. When this occurs the version of the template file will.
* be bumped and the readme will list any important changes.
*
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$saved_methods = wc_get_customer_saved_methods_list( get_current_user_id() );
$has_methods = (bool) $saved_methods;
wc_print_notices(); ?>
<?php wc_get_template( 'myaccount/navigation.php' ); ?>
<div class="my-account-content">
<?php do_action( 'woocommerce_before_account_payment_methods', $has_methods ); ?>
<?php if ( $has_methods ) : ?>
<table class="shop_table shop_table_responsive account-payment-methods-table">
<thead>
<tr>
<?php foreach ( wc_get_account_payment_methods_columns() as $column_id => $column_name ) : ?>
<th class="payment-method-<?php echo esc_attr( $column_id ); ?>"><span class="nobr"><?php echo esc_html( $column_name ); ?></span></th>
<?php endforeach; ?>
</tr>
</thead>
<?php foreach ( $saved_methods as $method ) : ?>
<tr class="method">
<?php foreach ( wc_get_account_payment_methods_columns() as $column_id => $column_name ) : ?>
<td class="payment-method-<?php echo esc_attr( $column_id ); ?>" data-title="<?php echo esc_attr( $column_name ); ?>">
<?php
if ( has_action( 'woocommerce_account_payment_methods_column_' . $column_id ) ) {
do_action( 'woocommerce_account_payment_methods_column_' . $column_id, $method );
} else if ( 'method' === $column_id ) {
echo esc_html( $method['method'] );
} else if ( 'expires' === $column_id ) {
echo esc_html( $method['expires'] );
} else if ( 'actions' === $column_id ) {
foreach ( $method['actions'] as $key => $action ) {
echo '<a href="' . esc_url( $action['url'] ) . '" class="button ' . sanitize_html_class( $key ) . '">' . esc_html( $action['name'] ) . '</a>';
}
}
?>
</td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</table>
<?php else : ?>
<p><?php esc_html_e( 'No saved method found.', 'woocommerce' ); ?></p>
<?php endif; ?>
<?php do_action( 'woocommerce_after_account_payment_methods', $has_methods ); ?>
<a class="button" href="<?php echo esc_url( wc_get_endpoint_url( 'add-payment-method' ) ); ?>"><?php esc_html_e( 'Add New Payment Method', 'woocommerce' ); ?></a>
</div>

View File

@ -12,42 +12,42 @@
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.2.0
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
exit;
}
?>
wc_print_notices(); ?>
<?php wc_print_notices(); ?>
<?php wc_get_template( 'myaccount/navigation.php' ); ?>
<p class="order-info"><?php printf( __( 'Order #<mark class="order-number">%s</mark> was placed on <mark class="order-date">%s</mark> and is currently <mark class="order-status">%s</mark>.', 'woocommerce' ), $order->get_order_number(), date_i18n( get_option( 'date_format' ), strtotime( $order->order_date ) ), wc_get_order_status_name( $order->get_status() ) ); ?></p>
<div class="my-account-content">
<p class="order-info"><?php printf( __( 'Order #<mark class="order-number">%s</mark> was placed on <mark class="order-date">%s</mark> and is currently <mark class="order-status">%s</mark>.', 'woocommerce' ), $order->get_order_number(), date_i18n( get_option( 'date_format' ), strtotime( $order->order_date ) ), wc_get_order_status_name( $order->get_status() ) ); ?></p>
<?php if ( $notes = $order->get_customer_order_notes() ) :
?>
<h2><?php _e( 'Order Updates', 'woocommerce' ); ?></h2>
<ol class="commentlist notes">
<?php foreach ( $notes as $note ) : ?>
<li class="comment note">
<div class="comment_container">
<div class="comment-text">
<p class="meta"><?php echo date_i18n( __( 'l jS \o\f F Y, h:ia', 'woocommerce' ), strtotime( $note->comment_date ) ); ?></p>
<div class="description">
<?php echo wpautop( wptexturize( $note->comment_content ) ); ?>
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
</li>
<?php endforeach; ?>
</ol>
<?php
endif;
<?php if ( $notes = $order->get_customer_order_notes() ) : ?>
<h2><?php _e( 'Order Updates', 'woocommerce' ); ?></h2>
<ol class="commentlist notes">
<?php foreach ( $notes as $note ) : ?>
<li class="comment note">
<div class="comment_container">
<div class="comment-text">
<p class="meta"><?php echo date_i18n( __( 'l jS \o\f F Y, h:ia', 'woocommerce' ), strtotime( $note->comment_date ) ); ?></p>
<div class="description">
<?php echo wpautop( wptexturize( $note->comment_content ) ); ?>
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
</li>
<?php endforeach; ?>
</ol>
<?php endif; ?>
do_action( 'woocommerce_view_order', $order_id );
<?php do_action( 'woocommerce_view_order', $order_id ); ?>
</div>

View File

@ -0,0 +1,71 @@
<?php
namespace WooCommerce\Tests\Account;
/**
* Class Functions.
* @package WooCommerce\Tests\Account
*/
class Functions extends \WC_Unit_Test_Case {
/**
* Test wc_get_account_menu_items().
*
* @since 2.6.0
*/
public function test_wc_get_account_menu_items() {
$this->assertEquals( array(
'dashboard' => __( 'Dashboard', 'woocommerce' ),
'orders' => __( 'Orders', 'woocommerce' ),
'downloads' => __( 'Downloads', 'woocommerce' ),
'edit-address' => __( 'Addresses', 'woocommerce' ),
'payment-methods' => __( 'Payment Methods', 'woocommerce' ),
'edit-account' => __( 'Account Details', 'woocommerce' ),
'customer-logout' => __( 'Logout', 'woocommerce' ),
), wc_get_account_menu_items() );
}
/**
* Test wc_get_account_orders_columns().
*
* @since 2.6.0
*/
public function test_wc_get_account_orders_columns() {
$this->assertEquals( array(
'order-number' => __( 'Order', 'woocommerce' ),
'order-date' => __( 'Date', 'woocommerce' ),
'order-status' => __( 'Status', 'woocommerce' ),
'order-total' => __( 'Total', 'woocommerce' ),
'order-actions' => '&nbsp;',
), wc_get_account_orders_columns() );
}
/**
* Test wc_get_account_orders_query_args().
*
* @since 2.6.0
*/
public function test_wc_get_account_orders_query_args() {
$this->assertEquals( array(
'posts_per_page' => 15,
'meta_key' => '_customer_user',
'meta_value' => get_current_user_id(),
'post_type' => wc_get_order_types( 'view-orders' ),
'post_status' => array_keys( wc_get_order_statuses() ),
), wc_get_account_orders_query_args() );
}
/**
* Test wc_get_account_downloads_columns().
*
* @since 2.6.0
*/
public function test_wc_get_account_downloads_columns() {
$this->assertEquals( array(
'download-file' => __( 'File', 'woocommerce' ),
'download-remaining' => __( 'Remaining', 'woocommerce' ),
'download-expires' => __( 'Expires', 'woocommerce' ),
'download-actions' => '&nbsp;',
), wc_get_account_downloads_columns() );
}
}