php - Set cart permalink when cart is not empty -


i have no cart link set in backend of woocommerce. instead have cart redirected checkout page. works fine, end empty urls. when add product cart message 'successfully added cart, see cart here'. 'see cart here' linked wc_get_page_permalink( 'cart' ), not set.

is possible through function set wc_get_page_permalink( 'cart' ) when items in cart?

i tried like:

function custom_continue_shopping_redirect_url ( $product_id ) {     $url = "http://www.url.com"; // add link here     return $url; } add_filter('wc_add_to_cart_message', 'custom_continue_shopping_redirect_url'); 

but replacing whole add cart message.

thanks.

you missed code. try way:

add_filter( 'wc_add_to_cart_message', 'custom_continue_shopping_redirect_url', 10, 2 ); function custom_continue_shopping_redirect_url( $message, $product_id ) {     global $woocommerce;          // $permalink = get_permalink(woocommerce_get_page_id('shop')); // replaced by:         $permalink = get_permalink(woocommerce_get_page_id('cart')); // link here.         $message    = sprintf('<a href="%s" class="button wc-forwards">%s</a> %s', $permalink, __('continue shopping', 'woocommerce'), __('product added cart.', 'woocommerce') );     return $message; } 

you have fine tune replacement link. can change text…

references:


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -