Home › Forums › Basel support forum › Add compare to My account dashboard
Add compare to My account dashboard
- This topic has 3 replies, 2 voices, and was last updated 5 years, 10 months ago by Elise Noromit.
-
AuthorPosts
-
December 28, 2018 at 12:48 am #98774
JackalParticipantHi!
How can I add Compare page link to My account dashboard and to my account end-points?
Regards,
AnasDecember 28, 2018 at 8:26 am #98796
Elise NoromitMemberHello,
1. Add this code to the functions.php file of the child theme:
function basel_my_account_links() { if ( !basel_get_opt( 'my_account_links' ) ) return; ?> <div class="basel-my-account-links"> <?php foreach ( wc_get_account_menu_items() as $endpoint => $label ) : ?> <div class="<?php echo $endpoint; ?>-link"> <a href="<?php echo esc_url( wc_get_account_endpoint_url( $endpoint ) ); ?>"><?php echo esc_html( $label ); ?></a> </div> <?php endforeach; ?> <?php if ( class_exists( 'YITH_WCWL' ) && basel_get_opt( 'my_account_wishlist' ) ): ?> <?php $wishlist_page_id = yith_wcwl_object_id( get_option( 'yith_wcwl_wishlist_page_id' ) ); ?> <div class="wishlist-link"> <a href="<?php echo YITH_WCWL()->get_wishlist_url(); ?>"><?php echo get_the_title( $wishlist_page_id ); ?></a></li> </div> <?php endif; ?> <?php if ( basel_get_opt( 'compare' ) && basel_get_opt( 'compare_page' ) ): ?> <?php $compare_page_id = basel_get_opt( 'compare_page' ); ?> <div class="compare-link"> <a href="<?php echo esc_url( get_permalink( $compare_page_id ) ); ?>"><?php echo esc_html( get_the_title( $compare_page_id ) ); ?></a> </div> <?php endif; ?> <div class="logout-link"> <a href="<?php echo wc_get_account_endpoint_url( 'customer-logout' ); ?>"><?php echo esc_html__( 'Logout', 'basel' ); ?></a> </div> </div> <?php } add_action( 'woocommerce_account_dashboard', 'basel_my_account_links', 10 );
2. Create navigation.php file and put it into woocommerce/myaccount/navigation.php of the child theme as shown here: http://prntscr.com/m0i24l
3. Put this code to the created navigation.php
<?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 https://docs.woocommerce.com/document/template-structure/ * @author WooThemes * @package WooCommerce/Templates * @version 2.6.0 */ if ( ! defined( 'ABSPATH' ) ) { exit; } if ( class_exists( 'YITH_WCWL' ) ) $wishlist_page_id = yith_wcwl_object_id( get_option( 'yith_wcwl_wishlist_page_id' ) ); $user_info = get_userdata( get_current_user_id() ); $user_roles = $user_info->roles; do_action( 'woocommerce_before_account_navigation' ); ?> <nav class="woocommerce-MyAccount-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; ?> <?php if ( class_exists( 'YITH_WCWL' ) && basel_get_opt( 'my_account_wishlist' ) && $wishlist_page_id ): ?> <li class="wishlist-account-element <?php if( is_page( $wishlist_page_id ) ) echo 'is-active'; ?>"> <a href="<?php echo YITH_WCWL()->get_wishlist_url(); ?>"><?php echo get_the_title( $wishlist_page_id ); ?></a> </li> <?php endif; ?> <?php if ( basel_get_opt( 'compare' ) && basel_get_opt( 'compare_page' ) ): ?> <?php $compare_page_id = basel_get_opt( 'compare_page' ); ?> <li class="compare-account-element <?php if( is_page( $compare_page_id ) ) echo 'is-active'; ?>"> <a href="<?php echo esc_url( get_permalink( $compare_page_id ) ); ?>"><?php echo esc_html( get_the_title( $compare_page_id ) ); ?></a> </li> <?php endif; ?> <?php if ( class_exists( 'WeDevs_Dokan' ) && apply_filters( 'basel_dokan_link', true ) && ( in_array( 'seller', $user_roles ) || in_array( 'administrator', $user_roles ) ) ): ?> <li class="dokan-account-element"> <a href="<?php echo dokan_get_navigation_url(); ?>"><?php echo esc_html__( 'Vendor dashboard', 'basel' ); ?></a> </li> <?php endif; ?> <li class="woocommerce-MyAccount-navigation-link woocommerce-MyAccount-navigation-link--customer-logout"> <a href="<?php echo esc_url( wc_get_account_endpoint_url( 'customer-logout' ) ); ?>"><?php echo esc_html__( 'Logout', 'woocommerce' ); ?></a> </li> </ul> </nav> <?php do_action( 'woocommerce_after_account_navigation' ); ?>
Best Regards
December 28, 2018 at 10:44 pm #98936
JackalParticipantHi!
Thank you for your reply!
I have added the code but nothing happens! Is this code for compare plugin or for the build-in compare feature with the theme! I’m using the build-in compare feature.Regards,
AnasDecember 29, 2018 at 7:54 am #98955
Elise NoromitMemberHello,
Please provide your site admin access as well as FTP access to the private area.
Best Regards
-
AuthorPosts
Tagged: compare
- You must be logged in to create new topics. Login / Register