Create a shortcode for displaying Order History on your Cart66 site

I’m a fan of Cart66. It’s easy to integrate and has a fair amount of features that make it a flexible e-commerce and member management solution for WordPress.

However, there’s one pretty big feature that Cart66 is missing: the ability to display the Order History of a logged in user.

What? Really?

Yes. Really.

This doesn’t really require a lot of explanation. It was easy to achieve with a simple SQL query and a custom loop. And all without editing the Cart66 core! So you can keep updating the plugin without worry. 🙂

Websites that sell digital goods will especially find this handy since users will be able to view their past receipts to re-download purchases.

Just insert this code into the functions.php file of your WordPress theme and use the shortcode [order_history] on a member’s only page to show the Order History for that user. Enjoy!

The original code for this idea came from a post by Alison Barrett.

/* Shortcode for displaying Cart66 order history for the current logged in user
 * @return {string} $table
 * @shortcode order_history
function cart66_order_history( $atts, $content = null ) {
	extract( shortcode_atts( array(), $atts ) );
	global $wpdb;
	$results = $wpdb->get_results( "SELECT ouid, ordered_on, trans_id, total, status FROM " . $wpdb->prefix . "cart66_orders WHERE account_id = " . Cart66Session::get( 'Cart66AccountId' ) . ' ORDER BY ordered_on DESC' );
	foreach ( $results as $order ) {
		$data .= sprintf( '%s%s%s%s%s', $order->trans_id, date( 'F j, Y', strtotime( $order->ordered_on ) ), $order->total, ucwords( $order->status ), home_url( '/store/receipt/?ouid=' . $order->ouid ), __( 'Click to view receipt', 'cart66' ), __( 'View Receipt', 'cart66' ) );
	$table = '' . $data . '
Order Number Date Total Order Status Receipt
'; return $table; } add_shortcode( 'order_history', 'cart66_order_history' );

What’s the future of the WordPress iOS app?

I don’t launch the WordPress iOS application very often, and when I do it’s usually to do a quick typo fix on a post, page or comment. Sadly, there is no other reason to use it.

Once, I heard Matt Mullenweg mention in a podcast interview (can’t remember where, sorry) that he really wasn’t happy with the app and agreed there was still a lot to be done. I’m always glad to see Matt pushing for more and it makes me very optimistic about the app’s future.

I don’t intend for this post to be a rant, I just believe that in order for the app to have a successful future, it should be supporting what WordPress is already known for. Otherwise, Tumblr, Posterous and a slew of other platforms who are thinking more “mobile” could gain a significant portion of the WordPress market share.

It seems to me that there are five major components of WordPress that just aren’t supported by the app yet.

1. Custom Post Types
This is a big one. WordPress introduced them in June 2010 with version 3.0 and we still don’t have them supported in the iOS app. This is probably the biggest upset of the five since it has been around for over a year and involves the very core of WordPress: Writing posts.

2. Widgets
Seriously? Yes, seriously. Currently, there is no way to add, modify or remove widgets from your WordPress site using the iOS app. Some may disagree that this belongs on my list, but I think it’s deserving. Widgets were introduced in version 2.2 and are one of the core things that makes WordPress unique and attractive. The mobile app should reflect WordPress’s existing core strengths to differentiate itself from other mobile players.

3. Post Formats
Post formats were introduced in version 3.1 and I think it was an excellent addition. It took the Custom Post Types functionality from version 3.0 and expanded it even further. We even saw the birth of “Tumblogs”, or WordPress themes that function like Tumblr sites, all because of Post Formats. Hell, I can’t even use the default Twentyeleven theme effectively on iOS because support for Post Formats is still missing. This would be a huge improvement.

4. Custom Fields (Post Meta)
Some plugins and advanced themes take advantage of Custom Fields on WordPress posts and pages. Although not always crucial, this is another capability that already makes WordPress unique and is part of core functionality so I believe it should be a part of the mobile strategy.

5. Theme Options
Almost every theme these days has a variety of Theme Options. And I’m not just talking about the “Theme Options” item under the Appearance menu, but also Header, Background, Sidebars and any other options page available for a particular theme. Why is this last on my list? Because Theme Options aren’t exactly critical for delivering content, which is what mobile is really all about: creating and publishing content quickly while on-the-go.

Jump on over to the WordPress iOS App Forum to join the conversation or be part of the solution.