Mostly when working with external products in WooCommerce, you may want to not only rename “Add to Cart” into something else… but also opening the link into a new tab. Here’s how I did it!
Continue reading WooCommerce: Add to Cart URL to Open in a New Browser TabSearch Results for: Add to Cart
WooCommerce: Display Content Above Add to Cart @ Single Product Page
A client of mine decided to add a little notice (“30-day return policy offered”) just above the Add to Cart button on the WooCommerce single product page. There is no need to say this will allow her to increase the click-through rate and her sales conversion rate. Continue reading WooCommerce: Display Content Above Add to Cart @ Single Product Page
WooCommerce: Hide Price & Add to Cart for Logged Out Users
You may want to force users to login in order to see prices and add products to cart. That means you must hide add to cart buttons and prices on the Shop and Single Product pages when a user is logged out.
All you need is pasting the following code in your functions.php (please note: your theme may have overwritten some default WooCommerce functions, hence the code below may not work. Contact me if you need custom code). Enjoy!
Continue reading WooCommerce: Hide Price & Add to Cart for Logged Out UsersWooCommerce: Customize The “You cannot add another __ to your cart” Notification
If a WooCommerce product is set to “sold individually” (i.e. the “Limit purchases to 1 item per order” checkbox is checked in the edit product page) and is already in the cart, the “You cannot add another product to your cart.” notification will appear if you try to add it to cart again, which is fair.
This message appears by default in WooCommerce. There is a workaround to disable it completely, but you can also customize the wording (which is what we’re covering next).
In fact, this notification comes with a PHP filter, which means we can override the content and adapt it to our user base and/or brand tone. Enjoy!
Continue reading WooCommerce: Customize The “You cannot add another __ to your cart” NotificationWooCommerce: Add Shipping Rate Description @ Cart & Checkout Page
Each payment method on the WooCommerce Checkout page comes with a description right below the label. What if we could achieve something similar for the shipping rates, so that we can explain to the customer the difference between each method?
This question came up today in our private Slack channel for Woo developers, and we were able to write a quick snippet that does the trick. Here’s the complete code – enjoy!
Continue reading WooCommerce: Add Shipping Rate Description @ Cart & Checkout PageWooCommerce: Disable “You cannot add another __ to your cart” Message
When a WooCommerce product is set to “Sold Individually”, you can only add 1 item to the cart. If you try a second time, you will get the “You cannot add another “%s” to your cart” error message, so that the customer is aware that there is already that product in the cart.
However, you may want to either edit the message wording or completely remove it, especially if you automatically redirect to cart or checkout upon add to cart.
So, let’s study how to do the latter, which is much more complex than using the ‘woocommerce_cart_product_cannot_add_another_message‘ filter for editing the message content. Enjoy!
Continue reading WooCommerce: Disable “You cannot add another __ to your cart” MessageHow to get rid of the “added to cart” message?
Is there a way to get rid of the “added to cart message” that appears after clicking in “add to cart” both on the store main page and all the single product pages?
WooCommerce: Add Hyperlink to Shipping Method Label @ Cart & Checkout
Let’s say you want to help customers understand your shipping rates and benefits right on the WooCommerce Cart and Checkout pages, by adding a link to each shipping option (e.g. “View shipping FAQ“).
As you can see from the first and second screenshot below, if you enter any HTML within the WooCommerce shipping zone -> shipping method settings, this will be stripped out, and HTML tags such as hyperlinks won’t work.
So, how can we add a clickable text link to each shipping method, given that we can’t use the WooCommerce settings? Well, as usual, a quick PHP snippet can help us with that. Enjoy!
Continue reading WooCommerce: Add Hyperlink to Shipping Method Label @ Cart & CheckoutWooCommerce: Hide “Shipping to…” Address @ Cart
Even when the “shipping calculator” is disabled on the WooCommerce Cart page, a “Shipping to…” string will appear in the cart totals if an address has been previously entered or if geolocation is enabled.
Most WooCommerce store owners, however, wish to remove / hide this text, as it can be confusing for the customer. In this quick tutorial, we’ll study two different workarounds to achieve the same result. Enjoy!
Continue reading WooCommerce: Hide “Shipping to…” Address @ CartWooCommerce: Add Product to Cart When Visiting a Specific Page
We’ve already seen how to add a product to cart automatically when a user enters your website. However, I needed a different functionality on this same website, and specifically I wanted a product added to cart only when a user like you visits a specific WordPress page ID.
If you wish to test, go to my free video tutorial page called “How to Customize the WooCommerce Single Product Page“. As soon as the page loads a product is magically added to cart, so that the WooCommerce Checkout on that same page is populated with the hidden item. If you go to my Cart page right after visiting that landing page, you can verify there is a product in there.
So, how did I do it? Continue reading WooCommerce: Add Product to Cart When Visiting a Specific Page
WooCommerce: Add Content to Empty Cart Page
A Business Bloomer fan asked me a great question: “I’m using your visual hook guide to add content above the cart, however I notice that it doesn’t work if the cart is empty. Are there hooks specifically for empty carts?“.
Well, let’s take a look if we have anything available… (hint: of course we do!).
Continue reading WooCommerce: Add Content to Empty Cart PageWooCommerce: Remove Add Cart, Add View Product @ Shop Page
A fan requested an interesting edit on the Shop/Category page (or “loop”). Instead of having the default “Add to Cart” button, they wanted to remove that and substitute with a “View Product” button link to the single product page. Here’s the simple snippet – enjoy!
Continue reading WooCommerce: Remove Add Cart, Add View Product @ Shop PageWooCommerce: Add Product to Cart On Visit Programmatically
Quite an interesting functionality! A WooCommerce client wanted their Cart pre-filled with one product as soon as their customers accessed the website. I don’t remember the exact reason, but this could be useful when you want to give them a free product by default, or you want to send your visitors straight to checkout with a product already in the cart without letting them add anything first.
Adding an item to cart programmatically is the same as “automatically”. Basically, all users will have a default, non-empty Cart filled with an item of your choice. So, let’s see how this snippet works!
Continue reading WooCommerce: Add Product to Cart On Visit ProgrammaticallyWooCommerce: Remove / Edit “Added to Your Cart” Message
A client asked me to completely remove the message that appears after you add a product to the cart from the product page. This is simply done by using a PHP snippet, so here’s the quick fix for you!
Continue reading WooCommerce: Remove / Edit “Added to Your Cart” MessageWooCommerce: Empty Cart Redirect
An empty WooCommerce Cart page can be frustrating for customers, especially if they’ve been browsing and adding items to their cart.
Redirecting them to a relevant page, like the Shop page, can help them continue shopping and potentially complete a purchase.
The redirect page can be used to showcase ongoing sales, promotions, or new products that customers might be interested in. This can help generate interest and encourage customers to make a purchase.
So, let’s see how we can redirect users from the empty Cart page to another page on the same website. Enjoy!
Continue reading WooCommerce: Empty Cart RedirectWooCommerce: Remove “incl. tax” “ex. tax” Labels From Cart / Checkout / Order Totals
Do you want to simplify your WooCommerce prices by removing confusing tax labels?
This code tutorial is your guide to removing the “incl. tax” and “ex. tax” labels from your cart, checkout, and order totals in WooCommerce when your “Prices entered with tax” tax option is set to “Yes, I will enter prices inclusive of tax“.
Whether you find them unnecessary or want to create a cleaner pricing display, this tutorial will walk you through two effective snippets to achieve this customization.
Enjoy!
Continue reading WooCommerce: Remove “incl. tax” “ex. tax” Labels From Cart / Checkout / Order TotalsWooCommerce: Split Cart Into Packages
There are a million plugins out there that allow you to make the most of WooCommerce “cart packages” – this is a short way to say that you have the chance to assign cart items to multiple “packages“, so that the customer can pick different shipping methods for each package.
For example, imagine you sell products that are only available for “pick up in store“, and others that are shippable. By splitting the cart into 2 packages, the customer can place both product types in the same cart, but will be able to choose “Local pickup” for package 1 only, while for package 2 they’ll select one of the available delivery rates.
Splitting the cart into multiple packages is as easy as looping through the cart items, and assigning them to its own package array based on shipping class. Enjoy!
Continue reading WooCommerce: Split Cart Into PackagesCart slide-in?
How can I show a slide-in the appears after the user clicks the “Add to Cart” button, offers two options – Show Cart and Finish Order, and disappears after a specified time interval, let’s say 5 seconds? Somethinf like this: https://share.getcloudapp.com/YEuzmkDp
How to show a cart message based on products in the cart?
I looking for a code snippet that will allow me to add a cart message warning the customer that certain products present in the cart require extra lead time for delivery. Any thoughts or suggestions?
WooCommerce: Apply Discount to Cheapest Cart Item
If you run WooCommerce store promotions, this little snippet will help you with that. For example, how to run a “Buy 2 products, get one half off” or a “Buy 3 products, get the cheapest one for free” campaign?
The trick behind this workaround is to find the cheapest item by looping through the cart, and then to set its price so that it’s lower than the regular price. Enjoy!
Continue reading WooCommerce: Apply Discount to Cheapest Cart Item