Author Archives: Victoria

About Victoria

Website builder, Marketer, Google Analytics enthusiast. See more here : About Victoria & Clare Associates

Too many requests : blocking access to unused Woocommerce features

This entry was posted in Blog on by .

WordPress as a Content Management System with Woocommerce to drive an online shop are two very powerful and useful tools.  We have built and run a number of Woocommerce shops, and we love the power and ease of use it offers.

However, there are some situations where there might actually be just TOO much functionality.  I came across one of these situations recently on the Shop on the Borderlands. This online shop has a very high number of unique products (thousands of them).

By default, Woocommerce creates a shortcut ‘Add to Cart’ link to every product. The advantage of this if you are selling a few simple items is that you can link direct from your blog post or email to the ‘add to cart’ functionality and allow people to buy with one click.

The downsides are that if you have complex products, where you want people to read the full product description, you never want them to do that.   And, because the system is automatically creating a unique ‘add to cart’ link for every product, if your website gets hit by some annoying piece of software that goes through making a lot of requests at once, this will put the all-important site database under a lot of strain.

Add to Cart links can’t be cached, or protected using services like Cloudflare: every Add to Cart action makes the website database do work.  And if you have thousands of products, a program that automatically hits all the ‘add to cart’ links in a couple of seconds can quickly slow the site to a crawl.   No human user will do this.  A human user will hit one product button and make a form request.  Only automated software follows hundreds of links simultaneously.

The answer is to remove all the ‘Add to Cart’ links, and then use the site’s .htaccess file from allowing anyone to access the paths.  You don’t even want those paths to return a ‘404 not found, because even a 404 could put some load on the database, and there’s no reason for those requests to hit the database at all, and slow things down for your all-important real human customers.

OK.  Before I give the code, here’s the obligatory warning.  Before you change your site’s functions.php file or .htaccess file, take a backup copy of the working version. You know that, right?

Here’s the code I added to my theme’s functions.php file to get rid of the visible buttons in Woocommerce that point to the Add to Cart links.  (note that this won’t remove the all important ‘add to cart’ message on the actual product page!  That’s implemented as a form, not a link, so you don’t have to worry about it.)

// hide the 'add to cart' button on category pages.
add_action('wp', 'hideaddtocart');
function hideaddtocart(){
if (is_archive()) {
// make all items unpurchasable if it's a category
add_filter( 'woocommerce_is_purchasable', '__return_false');

// hide the 'read more' link that appears on unpurchasable items.

if (!function_exists('woocommerce_template_loop_add_to_cart')) {
function woocommerce_template_loop_add_to_cart() {
global $product;
if ( ! $product->is_in_stock() || ! $product->is_purchasable() ) return;

// removes the add to cart on 'related products'

add_filter( 'woocommerce_loop_add_to_cart_link', 'replacing_add_to_cart_button', 10, 2 );
function replacing_add_to_cart_button( $button, $product ) {
// nothing goes here since we don't actually want a button.

OK! so now we can only Add to Cart from the product page, where customers can read all the necessary description, and we no longer have a huge list of ‘add to cart’ links that annoying bots can follow to slow your site down and use up all your site memory.

But if the site has previously been spidered, or if the bot software is particularly annoying, they’ve probably already got a record of where the ‘Add to Cart’ urls were.  So my next step was to edit the site .htaccess file to stop anyone accessing those links at all.

I added this:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} /cat/[^?]*\?add-to-cart=\d+ [NC]
RewriteRule ^ - [F]
RewriteCond %{THE_REQUEST} /product/[^?]*\?add-to-cart=\d+ [NC]
RewriteRule ^ - [F]

The unusual lines are the RewriteCond ones: these give the pattern to match for the two URLs created by  Woocommerce for ‘add to cart’ links.
And then after that, the rewriteRule says: if this rule is matched, FAIL.  IE, do nothing.  Don’t load the page, don’t access the database, just give an error.  No human will be following those links, you don’t need to give a friendly message.  Just fail.

I did this and the site speed roughly trebled and the annoying out of memory errors went away.  What a relief.

Two quick Paypal product shops

This entry was posted in Projects on by .


Both Tamar Valley Tourism and Dartmoor Accommodation had a need to sell a small number of products online – tours, posters and trail guides.   Because there were a small number of products and the value was quite low, a full online shop solution would have been overcomplicated and too expensive for this situation, so instead we set up Paypal payment buttons for these products.  This approach is ideal for using to sell a few low-value items, and is still entirely secure as all the transactions are done using Paypal’s secure server.  You don’t have to have a paypal account to use them, either!    Click on the poster and leaflet images above to see the shop (and buy a poster or a trail guide!)


Villas of the Caribbean: a custom-built site using API

This entry was posted in Projects on by .

Tropic Breeze, our Caribbean tour operator customer, wanted a website to showcase villas in the Caribbean using availability and pricing information from a partner database, but offering the ability to customise the content and display.  We built an importer tool to allow this and a display system to allow the villas to be searched and displayed within a look and feel to match the main website, which we also built and maintain.

New WordPress Website for Labcold

This entry was posted in Projects on by .

Labcold, a manufacturer of laboratory fridges and blood product storage solutions, came to us wanting a WordPress solution for their website, which had been custom built and was proving difficult to maintain reliably. They particularly wanted a look and feel that would echo their existing brand, but would allow greater flexibility, be easier to use on mobile phones and allow them to use the WordPress media management system. They were also keen to have ongoing support for updates and future development.

We build this website, which includes a full product brochure and the ability to create sale products, as well as a blog, case studies and events section, and a system for registering customers for warranties.

New wordpress site for Professor of Behavioural Science at Newcastle University

This entry was posted in Projects on by .

Daniel Nettle contacted us because he wanted to build a new wordpress website to explain his work as Professor of Behavioural Science at Newcastle University, but needed some help with the technicalities.

In particular, he wanted to be able to provide a downloadable library of research papers, which would allow the papers to be listed and retrieved using tags or categories, using a simple easy to maintain template.

Daniel is still working on uploading some of his older content, but you can see the new site growing here :

New Canine Hydrotherapy website

This entry was posted in Projects on by .

Here’s a new little project that we pulled together for an existing customer who is moving into a new area of business :  .  We are huge doglovers at Clare Associates – in fact, we regularly foster dogs for the Oldies Club dog rescue charity, whose website we also look after. So we were very happy to be asked to help with this new project which will bring hydrotherapy services for dogs to Plymouth.

The K9splash Hydrotherapy site uses a variation on WordPress’s default 2015 theme, customised to give it a little more personality and a watery feel suitable to the subject matter!   Content will be developed further as the business becomes more established and photography becomes available.

Hiding All WordPress notifications from those who don’t need to be bothered with them.

This entry was posted in Blog on by .

We love WordPress, it’s grown from the blogging platform we started using way back in 2005 into a really powerful content management system which can be extended in all sorts of exciting ways: either with plugins and themes from the great WordPress community, or by creating custom code.

But occasionally you can see its roots showing, and when you use it as a multi-user system with several users all with different editing permissions is one of those situations.

If your website has users who just have the job of editing a single page or post – for example, if your website is a community site like  where each member has their own page to look after – you probably don’t want them all bothered by nag messages about updating plugins such as Woocommerce,  or WordPress core : your site admins will look after all of that and your users don’t want to know about it.

Fortunately, as long as your wordpress website has its own child theme for customisations, you can simply pop this code into your functions.php file,

function hide_update_notices() {
if ( !current_user_can( ‘manage_options’ ) ) {
remove_all_actions ( ‘admin_notices’);

Hey presto!  admin notices show only to those with the ability to do something about them.

Website relaunch with automatic Twitter & Facebook blog feed

This entry was posted in Projects on by .

We’ve worked with James Silvey at In2Networks, a specialist in IT solutions, networking and support based in South Devon for many years, so we were delighted to be asked recently to pull together a new website for the business.   James is always lovely to work with and we’d definitely recommend him if you are looking for helpful and constructive hardware support.

The website itself is a simple one, but with a few clever tweaks.  For example, it’s fully integrated with Twitter and Facebook, so that each new blog post that is added to the website will automatically tweet & share itself, complete with the right photo!


In the In2networks line of business, it’s essential to be up to speed with the importance of taking backups and ensuring everything is thoroughly virus checked, so as well as our usual automated backups and security tools, we’ve added additional backup functionality so that he can take a one-click backup using Xcloner, and download to store it locally whenever required.


Welcome to Launceston Chamber of Commerce!

This entry was posted in Projects on by .

We’re delighted to announce that the new Launceston Chamber of Commerce website is now ready for use.  We designed a new clean layout based on the WordPress system, with a new logo that works better when displayed at low screen resolutions, using the new Chamber colours.


The site does of course adapt to display nicely on mobile devices.


An important part of the project was creating a system for each chamber member to be able to manage and update their own entry themselves.   We have also set up a simple tool to allow members to enter offers and discounts that they may want to offer other members, and these will be automatically emailled to all Chamber members once a month (unless they opt out, of course!)

Clare Associates are ]proud members of the Launceston Chamber, and if you don’t know Launceston well, we’d definitely encourage you to visit the town.