Tagged: x
-
AuthorPosts
-
April 6, 2016 at 5:53 pm #870203
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é
April 6, 2016 at 11:32 pm #870543Hello 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.
April 7, 2016 at 2:06 am #870674Sure. 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 themeadd_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é
April 7, 2016 at 6:37 am #870976Hi 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!
April 7, 2016 at 4:34 pm #871934With 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é
April 8, 2016 at 5:09 am #872563Hi 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.
April 8, 2016 at 6:07 am #872633Hello,
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é
April 8, 2016 at 5:42 pm #873435Hi José,
Please provide us with the admin details to your site in a private response so that we could check this further.
Thank you.
April 9, 2016 at 2:03 pm #874418This reply has been marked as private.April 10, 2016 at 2:52 am #874926Hi 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!
April 10, 2016 at 2:30 pm #875483This reply has been marked as private.April 11, 2016 at 1:54 am #876011Hi 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.
April 11, 2016 at 10:26 am #876607That 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é
April 11, 2016 at 3:26 pm #877125Glad we could help 🙂
Cheers!
-
AuthorPosts