There are no items in your cart - go add some ! (Change Link)

Hi

I need to change the link when I click on the empty shopping cart. It's a long story but I don't want it to default to my shop but a different page.

"There are no items in your cart - go add some !"

Where do I change it?

I also need to remove all product links in the checkout page. I need a continue shopping button instead.

Many Thanks
Kieran

  • Vaughan
    • Support/SLS MockingJay

    Hi Kieran,

    Hope you're well?

    To change the no items link.

    Add the following to your theme functions.php

    add_filter( 'mp_cart/no_items_message', 'custom_no_items_message' );
    function custom_no_items_message() {
        $url = site_url('/your-new-page');
        $message = sprintf( __( 'There are no items in your cart - <a href="%s">go add some</a> !', 'mp' ), $url );
    
        return $message;
    }

    then enter your page you want it to be redirected to where it says /your-new-page

    site_url will automatically create the URL such as http://yoursite.com

    so if you want it redirected to http://yoursite.com/my-new-page

    You simply change it so it read site_url('/my-new-page');

    with regards to the product links, which product links are you referring to and also where do you want a continue shopping button? Could you perhaps take a screenshot, so I know exactly what links you are referring to.

    Hope this helps

  • Kieran
    • The Crimson Coder

    Hi Vaughan,

    Thanks for the tip I'll try it asap. First find attatched some screendshots of

    1) I want to remove any links which redirect people back to the default shop (See Arrows) I'm not using the default shop (long story due to unique url's with Appointments+)

    2) screenshot of a continue shopping button. Although in hindiste I wonder if we need a Go Back button instead. What if I change my mind and want to remove the appointments. Once I'm at this stage it doesn't look like I can?? Maybe we could have a Go Back Button and a Continue Shopping button directly underneath it? Would that work? I know Go Back Buttons aren't great but does seem a problem if I reach this bit in the order and change my mind

    You will notice my layout looks odd too but that's highlighted in another thread

    Kind Regards
    Kieran

  • Kieran
    • The Crimson Coder

    Hi Vaughan

    I put the code into my functions.php file and the message now says

    Looks like you haven't added anything your cart. Let's go shopping!

    Before it did say "Go Add Some" but its still directing me back to the store

    Kind Regards
    Kieran

  • Kieran
    • The Crimson Coder

    Hi I still have an issue with

    1) I want to remove any links which redirect people back to the default shop (See Arrows) I'm not using the default shop (long story due to unique url's with Appointments+)

    Any chance of an update?

    Kind Regards
    Kieran

  • Kieran
    • The Crimson Coder

    Hi Hoang,

    I have that bit working thanks. It's this bit I still need help with please

    1) I want to remove any links which redirect people back to the default shop (See Arrows) I'm not using the default shop (long story due to unique url's with Appointments+)

    Thanks
    Kieran

  • Hoang Ngo
    • Code Slayer

    Hi @Kieran,

    I hope you are well today.
    For hiding the cart appointment URL, please use this code

    add_filter( 'mp_cart/column_html', 'prevent_cart_app_url', 20, 3 );
    function prevent_cart_app_url( $html, $column, $product ) {
    	if ( 'title' !== $column ) {
    		return $html;
    	}
    	if ( MP_Product::get_variations_post_type() !== $product->post_type ) {
    		return $html;
    	}
    	$app_id = MP_Product::get_variation_meta( $product->ID, 'name' );
    	global $appointments;
    	$app = $appointments->get_app( $app_id );
    
    	if ( $app ) {
    		$html = str_replace( get_permalink( $product->post_parent ), '#', $html );
    	}
    
    	return $html;
    }

    For hiding normal product URL, please use this code

    add_filter( 'mp_product/url', 'prevent_cart_item_url' );
    function prevent_cart_item_url( $url ) {
    	global $wp_query;
    	if ( $wp_query->query['pagename'] == get_page_uri( mp_get_setting( 'pages->cart' ) ) ) {
    		$url = '#';
    	}
    
    	return $url;
    }

    The Continue Shopping, I can hide that using css, however, when I check on your site, I couldn't find it. Can you please check?

    Best regards,
    Hoang

  • Kieran
    • The Crimson Coder

    Hi Hoang,

    Thanks for the code I will check that out

    1) I don't want to hide the contine button I want to create 2 buttons which I think should be default on Marketpress

    On http://mysite.com/store/checkout/ I would like a GO BACK button which directs to http://mysite.com/store/cart/

    The on http://mysite.com/store/cart/ I would like a CONTINUE SHOPPING button which directs to my booking page http://mysite.com/bookings

    2) The code

    add_filter( 'mp_cart/no_items_message', 'custom_no_items_message' );
    function custom_no_items_message() {
        $url = site_url('/your-new-page');
        $message = sprintf( __( 'There are no items in your cart - <a href="%s">go add some</a> !', 'mp' ), $url );
    
        return $message;
    }

    correctly directs people to my booking page when they hit http://mysite.com/store/cart/

    unfortunately I also need to change the link on http://mysite.com/store/checkout/ as when a product times out it can direct to this page not my cart page.

    I hope all that makes sense

    Thanks for the help
    Kind Regards
    Kieran

  • Hoang Ngo
    • Code Slayer

    Hi @Kieran,

    I hope you are well today.

    Please replace the file /marketpress/includes/common/class-mp-cart.php with the class-mp-cart, and /marketpress/includes/public/class-mp-checkout.php with the class-mp-checkout.php. Lets see if this works for you :slight_smile:

    Best regards,
    Hoang

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.