Archived topic
Hide cart in menu for a specific user role
32 replies · Started by Deyson on April 18, 2022
At this time I have been able to get all links to go to checkout. The one that I am not able to get the icon.
Also, if you may share both recommendations to have everything go to checkout please do as I want to be sure I am doing it correctly.
Thank you and have an amazing day! 😊
Try this snippet:
add_filter( 'woocommerce_get_cart_url', 'db_custom_cart_url' );
function db_custom_cart_url() {
return 'your checkout url here';
}
Thank you! 😊
May I use /checkout/ for the "URL here"?
That one would require the full url eg. https://mysite.com/checkout/
Thank you.
Also, it seems if the cart is empty and we get directed to the checkout it creates an endless loop.
Please let me know what you think. 🤔
Do you have any other codes that is changing Cart links to the Checkout ?
I guess I did. I am sorry for that.
Thank you for your patience and have an amazing day! 😊
No need to apologise. Did you get the issue resolved ?
Yes sir! 😊
P.S. I found a great plugin called Query Monitor to help identify the most taxing plugins. 😊
Awesome - glad to hear that!
Hello.
Is it possible to combine your code with this one:
https://stackoverflow.com/questions/63631987/woocommerce-always-redirect-to-checkout-even-if-product-already-exists-in-cart
Since I sell digital downloads individually, I would rather my customer heads to checkout instead of seeing a warning if a product is already in the cart.
Please let me know what you think. 🤔
Thank you and have an amazing day! 😊
So run me by the logic.
What happens if the product isn't already in the cart ?
Hello, David! 😊
If the product is or is not in the cart it all goes to the checkout the same.
Currently, with the code, you had shared with me if the product is in the cart we get a Notification message on the product page that reads "You cannot add another "Produce Name" to your cart. View Cart"
With the code I had linked above, it redirects to the Checkout page, but the Mini Icon takes me to the Cart. I would like everything to go to the checkout page.
Please let me know what you think. 🤔
Thank you and have an amazing day! 😊
If the cart icon only serves the purpose of taking you to the Checkout ( ie. there is not mini cart submenu ). Then it may be easier to disable the Menu Cart, and use a Block Element to insert your own icon with a link to the checkout.
You can use the menu_bar_items hook to position it in the same place.
Is that an acceptable solution?
In the future, I may want to turn it back on.
But, I will try that out. I will go look through your documentation to figure out how to do this.
Thank you and have an amazing day! 😊