Digital experiences for all disciplines
New Landing › How can we help? › Atelier › Adding my-account link to the header account icon
New Landing › How can we help? › Atelier › Adding my-account link to the header account icon
- This topic has 11 replies, 2 voices, and was last updated 8 years by Kyle – SUPPORT.
-
Posted in: Atelier
-
August 22, 2016 at 3:51 pm #288711
Hi!
As posted in another topic
I’m trying this solution to achieve a similar request. I would like to have a direct link to sitename.com/my-account in the account icon (tested it on some friend, more than one has clicked on the icon expecting to go to the account page).Modifying the sf-header.php file in parent theme with ‘ . $my_account_link . ‘ it worked fine but I can’t get the same using the function.php in child theme. I’ve copied the whole function as you said but it’s not working.
How can I get using the child theme?
Thank you
AndreaAugust 23, 2016 at 8:15 am #288816Hi
You need to activate the child theme for it to work
– Kyle
August 23, 2016 at 8:24 am #288824Hi Kyle, thank you. I have activated it but as you said right now I checked out and it’s not active. Obviously now is active and the function.php solution in the child theme does not work! As you can see in the attachments copying the whole function show me the header texts instead of the icons. Where am I wrong?
Thanks
AndreaAttachments:
You must be logged in to view attached files.August 23, 2016 at 8:30 am #288826Have you got any other files in your child theme?
– Kyle
August 23, 2016 at 8:33 am #288827No, just edited the function.php
Here it is in the attachments!Attachments:
You must be logged in to view attached files.August 23, 2016 at 8:36 am #288829You’ve copied the whole file to the child theme, you need to copy only the function you’ve edited
– Kyle
August 23, 2016 at 8:49 am #288835Ops! Ok, it sounded a bit strange to copy all the functions and… that’s it! It’s working! many thanks.
Just to complete the topic this is the piece of code added to the functions.php in the child theme:/* ACCOUNT ================================================== */ if ( ! function_exists( 'sf_get_account' ) ) { function sf_get_account( $aux = "" ) { // VARIABLES $login_url = wp_login_url(); $logout_url = wp_logout_url( home_url() ); $my_account_link = get_admin_url(); $myaccount_page_id = get_option( 'woocommerce_myaccount_page_id' ); if ( $myaccount_page_id ) { $my_account_link = get_permalink( $myaccount_page_id ); $logout_url = wp_logout_url( get_permalink( $myaccount_page_id ) ); $login_url = get_permalink( $myaccount_page_id ); if ( get_option( 'woocommerce_force_ssl_checkout' ) == 'yes' ) { $logout_url = str_replace( 'http:', 'https:', $logout_url ); $login_url = str_replace( 'http:', 'https:', $login_url ); } } $login_url = apply_filters( 'sf_header_login_url', $login_url ); $register_url = apply_filters( 'sf_header_register_url', wp_registration_url() ); $my_account_link = apply_filters( 'sf_header_myaccount_url', $my_account_link ); if ( get_option( 'woocommerce_enable_myaccount_registration' ) && $myaccount_page_id ) { $register_url = apply_filters( 'sf_header_register_url', $my_account_link ); } global $sf_options; $show_sub = $sf_options['show_sub']; $show_translation = false; if ( isset($sf_options['show_translation']) ) { $show_translation = $sf_options['show_translation']; } $sub_code = __( $sf_options['sub_code'], 'swiftframework' ); $account_output = ""; // LINKS + SEARCH OUTPUT $account_output .= '<nav class="std-menu">' . "\n"; $account_output .= '<ul class="menu">' . "\n"; $account_output .= '<li class="parent account-item">' . "\n"; if ( $aux == "aux-text" ) { $account_output .= '<a href="#">' . __( "My Account", "swiftframework" ) . '</a>' . "\n"; } else { $account_output .= '<a href="' . $my_account_link . '"><i class="sf-icon-account"></i></a>' . "\n"; } $account_output .= '<ul class="sub-menu">' . "\n"; if ( is_user_logged_in() ) { $account_output .= '<li class="menu-item"><a href="' . $my_account_link . '" class="admin-link">' . __( "My Account", "swiftframework" ) . '</a></li>' . "\n"; $account_output .= '<li class="menu-item"><a href="' . $logout_url . '">' . __( "Sign Out", "swiftframework" ) . '</a></li>' . "\n"; } else { $account_output .= '<li class="menu-item"><a href="' . $login_url . '">' . __( "Login", "swiftframework" ) . '</a></li>' . "\n"; $account_output .= '<li class="menu-item"><a href="' . $register_url . '">' . __( "Sign Up", "swiftframework" ) . '</a></li>' . "\n"; } if ( $show_sub && $sub_code != "" ) { $account_output .= '<li class="parent"><a href="#">' . __( "Subscribe", "swiftframework" ) . '</a>' . "\n"; $account_output .= '<ul class="sub-menu">' . "\n"; $account_output .= '<li><div class="header-subscribe clearfix">' . "\n"; $account_output .= do_shortcode( $sub_code ) . "\n"; $account_output .= '</div></li>' . "\n"; $account_output .= '</ul>' . "\n"; $account_output .= '</li>' . "\n"; } if ( $show_translation ) { $account_output .= '<li class="parent aux-languages"><a href="#">' . __( "Language", "swiftframework" ) . '</a>' . "\n"; $account_output .= '<ul class="header-languages sub-menu">' . "\n"; if ( function_exists( 'sf_language_flags' ) ) { $account_output .= sf_language_flags(); } $account_output .= '</ul>' . "\n"; $account_output .= '</li>' . "\n"; } $account_output .= '</ul>' . "\n"; $account_output .= '</li>' . "\n"; $account_output .= '</ul>' . "\n"; $account_output .= '</nav>' . "\n"; // RETURN return $account_output; } }
August 23, 2016 at 8:52 am #288837Great! No problem
– Kyle
August 23, 2016 at 9:07 am #288839It’s not working good in reality! The function works and the new link in the icon is added but I didn’t notice it is hiding me the wishlist + cart icon!
Attachments:
You must be logged in to view attached files.August 23, 2016 at 9:19 am #288843You didn’t have those icons enabled, check now
– Kyle
August 23, 2016 at 9:46 am #288849Thank you, didn’t checked, I thought it mantained the previous selection!
AndreaAugust 23, 2016 at 9:47 am #288850No problem
– Kyle
-
Posted in: Atelier
You must be logged in and have valid license to reply to this topic.