diff --git a/includes/admin/settings/class-wc-settings-accounts.php b/includes/admin/settings/class-wc-settings-accounts.php index aa3c3faba77..e8b69c98a0a 100644 --- a/includes/admin/settings/class-wc-settings-accounts.php +++ b/includes/admin/settings/class-wc-settings-accounts.php @@ -102,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' ), diff --git a/includes/class-wc-query.php b/includes/class-wc-query.php index a2479da739c..1a1e368ada8 100644 --- a/includes/class-wc-query.php +++ b/includes/class-wc-query.php @@ -72,6 +72,7 @@ class WC_Query { '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' ), @@ -113,6 +114,9 @@ class WC_Query { 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; diff --git a/includes/wc-account-functions.php b/includes/wc-account-functions.php index 1f8925bc824..eba1df1edac 100644 --- a/includes/wc-account-functions.php +++ b/includes/wc-account-functions.php @@ -81,6 +81,7 @@ function wc_get_account_menu_items() { 'orders' => __( 'Orders', 'woocommerce' ), 'downloads' => __( 'Downloads', 'woocommerce' ), 'edit-address' => __( 'Addresses', 'woocommerce' ), + 'payment-methods' => __( 'Payment Methods', 'woocommerce' ), 'edit-account' => __( 'Account Details', 'woocommerce' ), 'customer-logout' => __( 'Logout', 'woocommerce' ), ) ); @@ -193,3 +194,17 @@ function wc_get_account_downloads_columns() { 'download-actions' => ' ', ) ); } + +/** + * 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' => ' ', + ) ); +} diff --git a/includes/wc-template-functions.php b/includes/wc-template-functions.php index b3d38b04f75..6416d2257fe 100644 --- a/includes/wc-template-functions.php +++ b/includes/wc-template-functions.php @@ -2061,16 +2061,6 @@ if ( ! function_exists( 'woocommerce_account_downloads' ) ) { } } -if ( ! function_exists( 'woocommerce_account_edit_account' ) ) { - - /** - * My Account > Edit account template. - */ - function woocommerce_account_edit_account() { - WC_Shortcode_My_Account::edit_account(); - } -} - if ( ! function_exists( 'woocommerce_account_edit_address' ) ) { /** @@ -2085,6 +2075,15 @@ if ( ! function_exists( 'woocommerce_account_edit_address' ) ) { } } +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' ) ) { @@ -2095,3 +2094,13 @@ if ( ! function_exists( '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(); + } +} diff --git a/includes/wc-template-hooks.php b/includes/wc-template-hooks.php index 8dcc6287beb..409952bc043 100644 --- a/includes/wc-template-hooks.php +++ b/includes/wc-template-hooks.php @@ -246,6 +246,7 @@ add_filter( 'jetpack_comment_form_enabled_for_product', '__return_false' ); 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-account_endpoint', 'woocommerce_account_edit_account' ); 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' ); diff --git a/includes/wc-user-functions.php b/includes/wc-user-functions.php index d3c6436faaf..be06b7799ea 100644 --- a/includes/wc-user-functions.php +++ b/includes/wc-user-functions.php @@ -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 ); +} diff --git a/templates/myaccount/form-add-payment-method.php b/templates/myaccount/form-add-payment-method.php index 21bc47bb98f..acfd3b114f1 100644 --- a/templates/myaccount/form-add-payment-method.php +++ b/templates/myaccount/form-add-payment-method.php @@ -13,46 +13,52 @@ * @see http://docs.woothemes.com/document/template-structure/ * @author WooThemes * @package WooCommerce/Templates - * @version 2.1 + * @version 2.6.0 */ if ( ! defined( 'ABSPATH' ) ) { exit; } -?> -
-
- payment_gateways->get_available_payment_gateways() ) : ?> - + +
+ + + +
- -

- - -
+ + +

+ + diff --git a/templates/myaccount/payment-methods.php b/templates/myaccount/payment-methods.php new file mode 100644 index 00000000000..cae0225b6f4 --- /dev/null +++ b/templates/myaccount/payment-methods.php @@ -0,0 +1,78 @@ + + + + +
+ + + + + + + + + $column_name ) : ?> + + + + + + + $column_name ) : ?> + + + + +
+ $action ) { + echo '' . esc_html( $action['name'] ) . ''; + } + } + ?> +
+ + + +

+ + + + + + + +