Adding product to basket in Ubercart causes checkout bug

As part of a site I’ve recently been developing using Ubercart, I needed the ability to be able to add an item to the basket via a URL. Getting a URL to trigger an event was trivial, using the following code. First, you setup the URL pattern to trigger a callback function: Next, I setup a simple callback function, which would get the Node ID from the URL, and pass it to the uc_cart_add_item function and then redirect the user to the checkout. I tried this, and it seemed to work, however I later realised that the delivery pane had…

Get pages by template in WordPress

I’d originally posted this on the WordPress StackExchange site, but thought I’d share it here as well. If you ever need to get pages which use a certain template, you can use the following query. You can then use the loop as normal to iterate over the pages, as well as expanding on the above query, such as setting the order. It may have once been useful to be able to just specify the page template in the query with an additional parameter, but I feel the widespread need for this is now gone, as many cases which would use…

Better auto updating copyright date

At the start of every year, there always seem to be several blog posts about how to automatically update the copyright date in the footer of your site. These all seem to rely on using the date function in PHP to output the current year. Although this works fine in most cases, it falls apart if in the first year you want it to say just 2012, but next year you want it to say 2012-2013 instead of just 2013. If we wrap this logic up in a function, it will be able to automatically display either just the single,…