Home Forums WoodMart support forum Fatal Error when optional plugin not installed

Fatal Error when optional plugin not installed

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #20932

    silla_b
    Participant

    I installed the required plugins, but not the optional plugins (specifically YITH Wishlist and YITH Compare). When checking the site, the page was completely empty with the following fatal error inside the mobile-menu-tab div: Call to undefined function yith_wcwl_object_id() in themes/woodmart/inc/template-tags.php on line 1863

    After installing and activating the optional plugins, the site works. Just thought I’d let you know, if this hasn’t been reported yet.

    #20937

    Artem Temos
    Keymaster

    Hello,

    Thank you for choosing our theme and contacting us.

    Yes, we see that it is an issue with the latest version of theme and it happens when Wishlist plugin is disabled. You can temporarily enable the plugin or apply the following fix.

    1. Create a file woodmart-child/woocommerce/myaccount/navigation.php

    <?php
    /**
     * @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' ) );
    
    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' ) ): ?>
                <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; ?>
            <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' ); ?>

    2. Add the following function to the woodmart-child/functions.php

    function woodmart_get_my_account_menu() {
        $out = '<ul class="sub-menu">';
    
        foreach ( wc_get_account_menu_items() as $endpoint => $label ) {
            $out .= '<li class="' . wc_get_account_menu_item_classes( $endpoint ) . '"><a href="' . esc_url( wc_get_account_endpoint_url( $endpoint ) ) . '"><span>' . esc_html( $label ) . '</span></a></li>';
        }
        if ( class_exists( 'YITH_WCWL' ) ) {
            $wishlist_page_id = yith_wcwl_object_id( get_option( 'yith_wcwl_wishlist_page_id' ) );
            $out .= '<li class="woocommerce-MyAccount-navigation-link woocommerce-MyAccount-navigation-link--wishlist">
                <a href="' . YITH_WCWL()->get_wishlist_url() . '"><span>' . get_the_title( $wishlist_page_id ) . '</span></a>
            </li>';
        }
        $out .= '<li class="woocommerce-MyAccount-navigation-link woocommerce-MyAccount-navigation-link--customer-logout">
           <a href="' . esc_url( wc_get_account_endpoint_url( 'customer-logout' ) ) . '"><span>' . esc_html( 'Logout', 'woocommerce' ) . '</span></a>
         </li>';
    
        return $out . '</ul>';
    }
    
    function woodmart_my_account_links() {
        ?>
        <div class="woodmart-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' ) ): ?>
                <?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; ?>
                <div class="logout-link">
                    <a href="<?php echo wc_get_endpoint_url( 'customer-logout' ); ?>"><?php echo esc_html__( 'Logout', 'woodmart' ); ?></a>
                </div>
        </div>
        <?php
    }
    add_action( 'woocommerce_account_dashboard', 'woodmart_my_account_links', 10 );

    Kind Regards
    XTemos Studio

    #20942

    silla_b
    Participant

    Thanks so much, I will give that a try!

    #20948

    Artem Temos
    Keymaster

    OK, contact us if you will have any additional questions.

Viewing 4 posts - 1 through 4 (of 4 total)