Add link at top of woocommerce shop page

Hello

I would like to add a link to the top of my woocommerce shop page at motherculture.love/shop so that there is always a link to the shopping cart at the top of the page, right now there is a link in the menu however on mobile the menu loads in an accordion so I would like to have the Cart link always visible when you are in the store

Can you please tell me some code that will allow me to place a cart link at the top of the store page near the pink sort menus? I would like the link to be in magenta in the font baloo thambi and I would also like to be able to specify the size of the link

Thank you so much!!

Login info attached below

Hello @whitelobster11,

Thanks for asking. :slight_smile:

Out-of the box there is no option to add cart button in topbar. You can use the solution mentioned in following thread to get started.

Please note that custom code can break the flow of the website and we won’t be able to support in that scenario. Beyond this further customisation will fall outside the scope of support we can offer. You can get in touch with a developer for more specific customization.

Thanks.

Hello

Thank you for your quick reply

Isn’t there some straightforward way I can do it with css just for the Shop page? I do not want it to be a top bar visible on other pages, just one little link at the top of the shop page

Thank you!

Hi There,

You can use the following CSS rule to display your Topbar only on your WooCommerce pages.

.x-topbar {
    display: none;
}

.woocommerce-page .x-topbar {
    display: block;
}

Hope that helps.

Hello

Thank you for this but it does not solve the issue

I would like the top bar to stay as it is, but just add one link that says Cart at the top of the woocommerce shop page, if I add the code you sent it will completely remove the top bar from all pages except the shop.

Is there some code that I can add that will allow me to add a simple link somewhere at the top of the woocommerce shop page? I do not need all of the menu bar links exposed, I only want a Cart link

Thank you!!

Hi There,

While that is outside the scope of support, I could point you in the right direction with the understanding that it would ultimately be your responsibility to take it from here.

First, please setup a child theme, then add the following code on your child theme’s functions.php file.

add_action('woocommerce_before_shop_loop', 'custom_cartlink', 9);
function custom_cartlink() {  ?>
    <div class="x-container mbm" style="clear:both;text-align: right;"><a class="custom-cart-link" href="http://www.motherculture.love/my-cart/" style="outline: none;"><span>Cart</span></a></div>
  <?php
}

Then use this custom CSS to style that link.

a.custom-cart-link {
	font-family: 'Baloo Thambi', cursive;
    font-size: 1.4em;
    color: magenta;
}

Hope it helps,
Cheers!

Amazing thank you so so so so much for helping me with this!!! I really really appreciate it!!

Have a wonderful day!

You’re more than welcome, glad we could help.

Cheers!

Hello

I made the changes described above to my child theme but now I am encountering the errors described below, did I somehow implement them incorrectly? Everything seemed to function perfectly after I pasted the code provided into the functions.php file – any idea how to fix this?

When I save my front page I am suddenly getting the following errors

Warning: Cannot modify header information - headers already sent by (output started at /home3/r8vrjjo8/public_html/motherculture.love/wp-content/themes/x-child/functions.php:1) in /home3/r8vrjjo8/public_html/motherculture.love/wp-admin/includes/misc.php on line 1116

Warning: Cannot modify header information - headers already sent by (output started at /home3/r8vrjjo8/public_html/motherculture.love/wp-content/themes/x-child/functions.php:1) in /home3/r8vrjjo8/public_html/motherculture.love/wp-includes/pluggable.php on line 1216

do you know what this could mean/how to fix it?

Login info attached below

also- here is the contents of my functions.php file currently

<?php

// =============================================================================
// FUNCTIONS.PHP
// -----------------------------------------------------------------------------
// Overwrite or add your own custom functions to X in this file.
// =============================================================================

// =============================================================================
// TABLE OF CONTENTS
// -----------------------------------------------------------------------------
// 01. Enqueue Parent Stylesheet
// 02. Additional Functions
// =============================================================================

// Enqueue Parent Stylesheet
// =============================================================================

add_filter( ‘x_enqueue_parent_stylesheet’, ‘__return_true’ );

// Additional Functions
// =============================================================================

function x_wp_title( $title ) {

if ( is_front_page() ) {
  return get_bloginfo( 'name' );
} elseif ( is_feed() ) {
  return ' | RSS Feed';
} else {
  return trim( $title ) . ' | ' . get_bloginfo( 'name' ); 
}

}
add_filter( ‘wp_title’, ‘x_wp_title’ );

add_filter( ‘wp_image_editors’, ‘change_graphic_lib’ );

function change_graphic_lib($array) {
return array( ‘WP_Image_Editor_GD’, ‘WP_Image_Editor_Imagick’ );
}

add_action(‘woocommerce_before_shop_loop’, ‘custom_cartlink’, 9);
function custom_cartlink() { ?>

SHOPPING CART
<?php }

Hi there,

Please refer to the separate thread that you have posted and kindly avoid posting separate threads of the same topic to avoid confusion.

Thank you.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.