Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #870203

    qualalbatroz
    Participant

    Hi there,

    I am using a text-only logo in my site, and I would like to change the content of the text whenever someone navigates to the woocommerce pages. How can I accomplish this?

    Thanks!

    José

    #870543

    Prasant Rai
    Moderator

    Hello José,

    Thanks for writing in! To assist you with this issue, we’ll first need you to provide us with your URL. This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you with everything.

    Thanks.

    #870674

    qualalbatroz
    Participant

    Sure. Here it is:

    http://www.qualalbatroz.net

    As you will see, I’ve already managed to add a specific nav menu to the woo commerce pages, by adding the following code to the functions.php file of my X child theme

    add_filter( 'wp_nav_menu_args', 'custom_blog_menu' );
    
    function custom_blog_menu( $args ) {
      if ( is_woocommerce() || is_checkout() || is_cart() || is_checkout() || is_account_page() ) {
        $args['theme_location'] = 'primary';
        $args['menu'] = 'QA_menu_loja';
      }
      return $args;
    }

    So now I want to change the logo text “qual albatroz” to “qual loja” on woocommerce pages, i.e. the pages where I also have the specific store menu.

    Thanks!

    José

    #870976

    Zeshan
    Member

    Hi José,

    Thanks for writing back!

    You can use jQuery to change the logo text on WooCommerce pages. To do that, add following code under Custom > JavaScript in the Customizer:

    jQuery('.woocommerce .x-brand.text, .woocommerce-page .x-brand.text, .woocommerce-cart .x-brand.text').text('qual loja');
    

    Thank you!

    #871934

    qualalbatroz
    Participant

    With Firefox it works perfectly, but with Google Chrome, Internet Explorer and Microsoft Edge you can slightly notice the text changing when you access a store page, especially the “my account” or “checkout” pages. And this is a bit annoying. How can one stop this? Would it be better to make the change with CSS?

    Thanks!

    José

    #872563

    Lely
    Moderator

    Hi Jose,

    Please change above code to this:

    jQuery(function($){
    
    	$('.woocommerce .x-brand.text, .woocommerce-page .x-brand.text, .woocommerce-cart .x-brand.text').text('qual loja');
    
    });

    Hope this helps.

    #872633

    qualalbatroz
    Participant

    Hello,

    The new code didn’t solve the problem. With Chrome, Edge and Explorer the change is still noticeable.

    Could you please suggest something else?

    Thank you.

    José

    #873435

    Jade
    Moderator

    Hi José,

    Please provide us with the admin details to your site in a private response so that we could check this further.

    Thank you.

    #874418

    qualalbatroz
    Participant
    This reply has been marked as private.
    #874926

    Rad
    Moderator

    Hi there,

    It’s working on my end. Please check the attached screenshot. Please clear your browser’s cache, maybe what you’re currently getting is just cache.

    Thanks!

    #875483

    qualalbatroz
    Participant
    This reply has been marked as private.
    #876011

    Lely
    Moderator

    Hi Jose,

    That is expected with javascript. Please note that the changes will happen after the page was loaded. So it will load the default value first before it will encounter the javascript code that will change text to something else.

    Another option we can do is by changing the template. I can see that you do have a child theme. Please copy _brand.php from wp-content\themes\x\framework\views\global to this folder wp-content\themes\x-child\framework\views\global. Open the copied file change the code on line 9.
    from this:
    $site_name = get_bloginfo( 'name' );
    to this:
    $site_name = ( is_woocommerce() ) ? "qual loja": get_bloginfo( 'name' );

    The entire code for _brand.php should be like this:

    
    <?php
    
    // =============================================================================
    // VIEWS/GLOBAL/_BRAND.PHP
    // -----------------------------------------------------------------------------
    // Outputs the brand.
    // =============================================================================
    
    $site_name        = get_bloginfo( 'name' );
    $site_description = get_bloginfo( 'description' );
    $logo             = x_make_protocol_relative( x_get_option( 'x_logo' ) );
    $site_logo        = '<img src="' . $logo . '" alt="' . $site_description . '">';
    
    ?>
    
    <?php echo ( is_front_page() ) ? '<h1 class="visually-hidden">' . $site_name . '</h1>' : ''; ?>
    
    <a href="<?php echo home_url( '/' ); ?>" class="<?php x_brand_class(); ?>" title="<?php echo $site_description; ?>">
      <?php echo ( $logo == '' ) ? $site_name : $site_logo; ?>
    </a>

    Hope this helps.

    #876607

    qualalbatroz
    Participant

    That did it! It’s perfect now. I just made the line

    $site_name = ( is_woocommerce() || is_checkout() || is_cart() || is_checkout() || is_account_page() ) ? "qual loja": get_bloginfo( 'name' );

    so the store text would also show in these pages. I don’t know if there is a more elegant way to do it, but it works.

    Thank you for the great support!

    Best

    José

    #877125

    Nabeel A
    Moderator

    Glad we could help 🙂

    Cheers!