Category: WordPress

This came up recently while working on a site that had a bunch of target markets selected in Shopp. The country dropdown list on the Checkout page was in a somewhat random order, and I realized that it was displaying them in the order they were selected or saved. When I checked 3 new countries, they showed up at the bottom of the list. So, knowing that, we decided it would be better for everyone if we sorted the list alphabetically. The code is below:

You’ll note the comment about Åland Islands; ideally we want it to be listed with the other A countries, but I don’t know if there’s a way to sort special characters as their originating character in PHP. So, we pop it off the end of the array and push it back to the top.

I just released a new version of my Minimum Order Amounts plugin for Shopp today. This new version finally supports version 1.3 of Shopp, and allows merchants to set a minimum quantity for each product in the catalog. The product minimums are separate from the storewide minimums, and both are checked before the customer checks out.

Most of us who use web browsers understand that the web UI only requires a single click on links, form buttons, and input fields. However, there are people who are used to double-clicking everything in the same way you double-click icons in an OS GUI. Sometimes this causes problems, specifically with shopping carts, where double-clicking can lead to the checkout form being submitted twice which results in duplicate orders.

I ran into this problem with Shopp, in a very specific situation where the server was responding slowly. Normally this kind of thing doesn’t happen, and I couldn’t reproduce the problem myself, but a few customers over a couple of days had managed to place duplicate orders. After checking the database I noticed that the transactions were usually 2-15 seconds apart, so I thought I’d disable the “Submit Order” button on the checkout form after it had been clicked once. Easier said than done.

Unfortunately, this isn’t as simple as using the disabled attribute on the button. Since there is some Javascript input validation, I needed to make sure that the form was validating first before disabling the button. Fortunately, I had spoken to the lead developer of Shopp about this a while back, so I knew that I needed to check `shopp.validate` which fires when the Submit Order button is clicked. If it validates correctly, then it submits the form data to the server. After some digging in the JS, I found the validation method and wrote some code to disable it after the button has been clicked once. Here’s the code:

All you have to do is drop this code into the bottom of the checkout.php file in your theme/shopp directory.

The code runs when the “Submit Order” button is clicked, and it checks to make sure the form is valid. If it is, it disables the validate function, which posts the data to the server, and then it changes the button text to “Processing…” so the customer knows something is happening. In the event that something doesn’t happen after 30 seconds, the `setTimeout()` function will display a message below the button that says the order hasn’t gone through, and shows a link to reload the page.

This code has stopped the duplicate transaction issue I was seeing, and it offers a better user experience especially on slow sites where a customer might click on the submit button because it doesn’t look like anything is happening.

This week I’ve been working on a new website for Lava Rock Realty to promote their property management services by showing their vacation rentals on their site. My first instinct was to use custom post types to create something custom that would do exactly what we needed. I figured it wouldn’t take very long and would be better than evaluating a bunch of 3rd party plugins to find one that did everything my clients needed.

Fortunately, as I was writing the code to setup the custom post type, I thought I’d do a quick Google search to see what was out there for showing listings and properties. Other WP devs must have written something, right?

One of the first plugins I found was WP-Property, and it looked like it would do everything I needed. After installing it and spending a few minutes playing with it and familiarizing myself with how it works, I knew I didn’t need to look any further. This plugin is great for showing listings, and has some premium addons that may be useful in other projects (I’m looking at you MLS/RETS/XML importer).

That said, there are some tweaks that need to be made to the base templates, which I’ll cover in an article later. Otherwise, this plugin is great!

It’s not uncommon to want to change the email sender that WordPress sets automatically, especially in e-commerce situations. It’s actually really easy to do by adding a couple of filters in your theme’s functions.php file:

By default WordPress displays […] at the end of an excerpt, which doesn’t look good. Instead, I use this functions on blogs that I build, which changes it to something that looks better. Just add the following to your active theme’s functions.php: