-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
45 lines (39 loc) · 1.81 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
// Add custom Theme Functions here
function wc_get_custom_account_menu_items() {
$endpoints = array(
'orders' => get_option( 'woocommerce_myaccount_orders_endpoint', 'orders' ),
'downloads' => get_option( 'woocommerce_myaccount_downloads_endpoint', 'downloads' ),
'edit-address' => get_option( 'woocommerce_myaccount_edit_address_endpoint', 'edit-address' ),
'payment-methods' => get_option( 'woocommerce_myaccount_payment_methods_endpoint', 'payment-methods' ),
'customer-logout' => get_option( 'woocommerce_logout_endpoint', 'customer-logout' ),
);
$items = array(
'dashboard' => __( 'Dashboard', 'woocommerce' ),
'orders' => __( 'Orders', 'woocommerce' ),
'downloads' => __( 'Downloads', 'woocommerce' ),
'edit-address' => __( 'Addresses', 'woocommerce' ),
'payment-methods' => __( 'Payment methods', 'woocommerce' ),
'customer-logout' => __( 'Logout', 'woocommerce' ),
);
// Remove missing endpoints.
foreach ( $endpoints as $endpoint_id => $endpoint ) {
if ( empty( $endpoint ) ) {
unset( $items[ $endpoint_id ] );
}
}
// Check if payment gateways support add new payment methods.
if ( isset( $items['payment-methods'] ) ) {
$support_payment_methods = false;
foreach ( WC()->payment_gateways->get_available_payment_gateways() as $gateway ) {
if ( $gateway->supports( 'add_payment_method' ) || $gateway->supports( 'tokenization' ) ) {
$support_payment_methods = true;
break;
}
}
if ( ! $support_payment_methods ) {
unset( $items['payment-methods'] );
}
}
return apply_filters( 'wc_get_custom_account_menu_items', $items );
}