Evolution of technology

I am from an era where the internet did not exist at one point in my lifetime. I have just turned 30, and by no means do I feel old….yet! I even remember listening to a debate over the radio which my parents had put on in the car many years ago, on encyclopedias v internet. Need I say more.

It still amazes me however, how technology and the web based world has evolved in the last three decades. Many of us will remember watching Back to the Future II, and thinking how amazing would it be to have a telephone conversation with someone where you can actually see them at the same time on the screen! Who knew that 28 years later, we would all be making those sort of phone calls on a daily basis and not have to worry about any extra charges for it.

I was also from a generation where the mobile phone was only just coming into popularity for both the old and young folk. I think I was 14 years old when I got my first phone. My 7 year old nephew has his own iPad!

With this advance in technology, it opens the world of possibility to people. It can create knowledge, power and even love. However it can also create a lot of issues that perhaps people never foresaw. As a Mum of two boys, I worry about giving them a facility where the world (good, bad and ugly) is at their fingertips.

For now though I have comfort that they do not know my password for my phone or iPad, and they have never asked for it….yet!

The only one advance in technology that still hasn’t come to fruition, is the expandable pizza that takes two seconds to cook. One can still live in hope.

Rosie Ward

Why HTTPS?

As a start in a 2017 effort to update and revamp TidyDesign.com, we have upgraded to HTTPS, the security-concerned friend of HTTP.

HTTP stands for HyperText Transfer Protocol, and it denotes the set of rules computers use while communicating in HyperText (web pages) over the web. That HTTP’s rules underpin the web can be seen in the typical URL – “http://website.com”. The prefix to that address denotes the protocol in use.

You may have noticed that more and more sites over the past decade are labelled with a different prefix – “https://website.com”. This denotes that the site is accessed over HTTPS; or HyperText Transfer Protocol Secure. HTTPS adds security concerns to HTTP’s base ruleset, ensuring that all transferred data is encrypted, undamaged and travelling to an authenticated recipient (in other words, HTTPS helps ensure that you are actually browsing Amazon.com, not someone pretending to be Amazon).

For the modern web, HTTPS is important. There’s no way around it. HTTP doesn’t concern itself much with secure communication, because the original purpose of the web was just to share textual information. The modern web, by which we trade personal details millions of times a second, requires a more secure underlying ruleset. When you’re sending someone your credit card details to make a purchase, you’re going to want that to be encrypted – it’s as simple as that.

There are reasons other than adapting to industry standards to upgrade to HTTPS, from SEO to simple consumer reassurance. Google ranks secure sites higher than insecure sites by default, so upgrading is a good first-step for getting to page one. Consumers are becoming more aware of security concerns on the web, too – largely thanks to that green padlock you see next to secure web addresses in the browser – and are less likely to provide any details over an insecure connection. The sound theory is that if you provide a secure connection, your customer is much more likely to contribute to your business with confidence.

Implementation of HTTPS for a domain involves purchasing a certificate from a Certificate Authority, and some server configuration. Those certificates verify domains as being owned by the people who claim to own them, facilitating the green padlock your users will see. Here at Tidy, we’re happy to provide this service and set up secure connections, moving the web forward and growing your business – just give us a call, or send us an email.

Jonno

First Day of Spring

As I sit here typing on the 20th March, we have both heaters on in the office, the wind is howling outside and when I look out the window, I can barely see the Isle of Wight because of the mist.

Spring is most definitely not in the air! Tidy Design however is beginning to blossom. New and exciting projects are in their infancy, we are madly trying to recruit someone to join our nest of Tidy workers, and even old projects have come out of hibernation and we are redesigning some old friends.

However, every time I go onto our website, I cringe at how long it has been since we updated any part of the site. We are very good at preaching to our clients to keep updating their sites and keeping it looking fresh, but when it comes down to us doing our own site edits, I am afraid we have neglected our own! Ok, we should not complain, as it means we are doing something well. The time we should be updating our site, is being spent on client updates and projects.

Although the British weather is not yet aware that Spring is officially here, at Tidy Design HQ we are well aware that we are due for a big Spring clean of our Tidy site!! So before projects turn from infancy into fruition, now is our opportunity to work on our own website…

Rosie Ward

A Crazy Few Months…

Evening all, it has been a while! Tonight I thought it a good idea to write a quick blog post, something to say “hi, Tidy Design is still here!” and “thank you clients old and new, you have been keeping us very busy!”

Tidy Design – Guest Speakers at ASSIST-CKD

Testing 1 2 3 – getting ready to present…

Since I last sat down and wrote a blog post so much has happened, it is hard to know where to start. We have designed and launched several new sites, worked with Kidney Research UK to develop some life changing software, taken on a few new NHS projects, recruited, processed hundreds of website updates and celebrated a Christmas / New Years!

Christmas 2016

Finding the time to write new blogs posts and update our website (portfolio page) has been difficult, but this is something we are working on so please stay tuned – thank you for visiting.

Drawing to a close for 2016!

As we are drawing to a close for 2016, Team Tidy is drastically trying to get projects complete, updates signed off and all to-do lists highlighted with ticks.

tidy-business-card

This morning I ordered another 200 Nespresso capsules, only a mere five weeks after I placed the last order. That works out at 4 espressos a day for each of Mike and Jonno. If only the rest of the world could be powered with our version of fuel… coffee!

The more we get signed off however, the more work that keeps coming in. We are by no means complaining, we love how our business has evolved over the years and most especially over the past few months, but things at our HQ in Old Portsmouth are far from winding down. Mike has recently got back into the design elements of the business, and is relishing the opportunity to design something that doesn’t involve creating and drawing scary sea life creatures for our two young children.

sea-monster-illustration

shark-illustration

animal-illustrations

Jonno’s keyboard is in overtime and there is a constant musical tap that can be heard from the other side of the room. I wager that no one can type quicker than him! And for me, well amongst bookkeeping and ordering the coffee, I try to keep an optimistic face on it all. I like to think we have a happy office atmosphere, and for some strange reason we all differ so much from each other, but we just click. Pardon the pun.

We say it every year, but without out our loyal customers, old and new, we would not be in this very fortunate position.

We are still avidly recruiting, and are searching for someone who can contribute to our ever growing empire. If you think you fit the bill, then we would love to see your CV and portfolio, which you can email to jobs@tidydesign.com. It remains to be seen whether our Nespresso intake will increase as well!

Rosie Ward

New Southern HR Website

“A big thankyou to Mike and the team for giving me a brand new website www.southernhr.co.uk with a minimum of fuss but great care and attention to detail. From a very vague and short brief they have more than met my needs. Thanks David Miles”

southern-hr-website-portsmouth

As part of the package we included a free logo design and some branding, all in all this was a fun site to develop – thanks for choosing Tidy Design.

WooCommerce Rental Calculator

woocommerce

A Fully Bespoke Rental Price Calculator

WooCommerce is a hugely popular free plugin for WordPress which can provide an out-of-the-box, totally functional eShop with products of varying complexity, various shipping and payment methods, and a comprehensive checkout process. For a “standard” shop selling Products, ‘vanilla’ WooCommerce is amazing – it can get you up and running insanely fast, with little to none in the way of necessary development work. But when you want WooCommerce to do something it doesn’t do, it’s time to get down and dirty with some code. It should be noted that WooCommerce has a huge community producing and maintaining plugins which provide extra or changed functionality – for the most part, desired custom functionality can be achieved with one or two well-chosen plugins. But when plugins either cost too much, don’t meet your needs, or even overreach your needs and thus become a burden on the system, the only real option is to begin writing some bespoke code to produce your feature.

At Tidy Design, I do a lot of work with WordPress and WooCommerce, and more recently I’ve delved into pushing WooCommerce’s core functionality to produce a new shop for rental products. By default, the extent of WooCommerce’s options surrounding price is being able to set a sale price – but the requirements of this site included Products which have up to four price “brackets” which are used in a custom calculation on Product pages based on a customer’s input rental period. That’s quite a leap from WooCommerce’s default behaviour!

So let’s think of what exactly is required to get this working on a basic technical level:

1: Custom Product Data; the 4 price “brackets”. This must be configurable per-Product by administrators.
2: A “rental period” input on Product pages, representing the number of weeks the customer wants to rent the Product for.
3: A magic background calculator which can return a correct price for a given Product and rental period.
4: The ability to override the price for a Product in the cart, based on what was returned by the calculator.

Adding custom data to Products is a trivial two-stage (or in WordPress terms, a two-hook) process involving adding custom inputs to “edit Product” pages, and saving the values entered when the Administrator updates the post. I won’t cover that here because it’s a very “Googleable” subject – but in case you’re wondering, the first hook (adding custom inputs, specifically to the “Product Data” general tab) is

“woocommerce_product_options_general_product_data”

, and the second is

“woocommerce_process_product_meta”

– in which you’ll use WordPress’s built-in function “update_post_meta()” to write the values to the Product.

In the same way, adding a custom input to Product pages is trivial. The hook required depends on where you want the input to go. Mine is displayed above the normal Price output, so I used the hook

“woocommerce_single_product_summary”

to output some custom HTML.

The really interesting parts here are requirements three and four – the magic calculator, and overriding the WooCommerce price. Logically, the best option for the calculator was an AJAX function which is triggered by changes in the rental period input. WordPress has a hook-based method for adding AJAX functions that can be secured properly.

The below depicts a function which should receive a Product’s ID and the desired rental period, and return a calculated price.

function calculate_rental_price() {
		$price = 0;

		//get the product price data from the post
		$product_id = $_POST['rental_period'];
		$bracket_1 = floatval(get_post_meta($product_id, 'bracket_1', true)); //bracket 1 - for <1 week rentals
		$bracket_2 = floatval(get_post_meta($product_id, 'bracket_2', true)); //bracket 2 - for rental weeks 1 -> 4
		$bracket_2 = floatval(get_post_meta($product_id, 'bracket_3', true)); //bracket 3 - for rental weeks 5 + 6
		$bracket_4 = floatval(get_post_meta($product_id, 'bracket_4', true)); //bracket 4 - for rental weeks 7+

		$num_weeks = intval($_POST["num_weeks"]); //the input rental period

		if ($num_weeks === 0) {
			$price = $bracket_1;
		}
		else {
			for ($i = 1; $i < $num_weeks + 1; $i++) {
				if ($i <= 4) {
					$price += $bracket_2;
				}
				else if ($i <= 6) {
					$price += $bracket_3;
				}
				else if ($i >= 7) {
					$price += $bracket_4;
				}
			}
		}

		echo $price; //"return" the calculated price

		//write the calculated price to the PHP session
		session_start();
		$_SESSION['weeks'] = $num_weeks;
		$_SESSION['price'] = $price;

		die(); //exit
	}
	add_action('woocommerce_ajax_get_rental_price', 'calculate_rental_price');

So, at this stage, we have custom Product data depicting the various pricing brackets for different lengths of rental, we have a custom input on the Product page which allows a customer to request rental of any length in weeks, and we have a magic AJAX calculator which will return the correct price based on that input. The last stage is to tell WooCommerce “this is the price of the Product” when it is added to the cart.

By default, WooCommerce will take a Product’s regular or sale price as the price to display in the cart (and contribute to cart totals) – so we need a way to replace it. The first consideration might be to overwrite the regular and/or sale prices of the Product so that WooCommerce can just find the calculated price in the normal way. But consider what would happen here if two customers were ordering the same product at roughly the same time – which overwrite of the Product’s price would take precedence?

Luckily, when a Product is added to the cart in WooCommerce, a new “Cart Item” structure is created to represent it. This Cart Item is separate from the original Product object, and contains the price that will be displayed. We can overwrite this to any value we like – in our case, the calculated price.

But where does the calculated price come from? In the above AJAX function, I return the price to the page (where it is displayed by JavaScript where WooCommerce normally displays the price), but I also store it in the PHP session; a place to store variables which are relevant to the current user and which you want to “carry across” different pages.

It’s generally best practise to either not use the PHP session, or make its use as temporary as possible – so before I write the cart price of the product I transfer the values out of the session and into the cart item, utilising some custom array keys so as not to interfere with anything default.

This is achieved with the hook “woocommerce_add_cart_item_data” – which is run after the construction of a Cart Item, allowing the addition or modification of associated data.

	function transfer_rental_data_from_session_to_woocommerce_session($cart_item_data, $product_id) {
		session_start();
		$new_value = array();

		if (isset($_SESSION['weeks'])) {
			//write the value as text - "Three Day Express" for a 0-week rental period, and "x week(s)" for anything else.
			$option = $_SESSION['weeks'] == 0 ? 'Three Day Express' : ($_SESSION['weeks'] . ($_SESSION['weeks'] > 1 ? ' Weeks' : ' Week'));
			$new_value = array_merge($new_value, array('rental_period' => $option));
		}
		if (isset($_SESSION['price'])) {
			$option = $_SESSION['price'];
			$new_value = array_merge($new_value, array('custom_price' => $option));
		}

		//make sure to return the correct data - maintain the original cart item data, and only merge it with the new data if there is new data
		if (empty($new_value)) {
			return $cart_item_data;
		}
		else {
			if (empty($cart_item_data)) {
				return $new_value;
			}
			else {
				return array_merge($cart_item_data, $new_value);
			}
		}

		//get rid of the PHP session data - we don't need it any more
		session_unset();
		session_destroy();
	}
	add_filter('woocommerce_add_cart_item_data','transfer_rental_data_from_session_to_woocommerce_session', 1, 2);

So now, when a Product reaches the cart, its Cart Item has two new properties containing our custom data; ‘custom_price’ and ‘rental_period’. Data stored on the Cart Item allows for default WooCommerce functionality will continue to work – for example, the “undo” button after removing an item from the cart will restore the Cart Item, any custom data included. If the values were still hanging around in the PHP session, I’d have to do some clever logic to delete and recover it. As-is, no extra work is required to maintain the custom data.

Now for actually writing the cart price, using the hook “woocommerce_before_calculate_totals”.

	function overwrite_cart_price_for_rental_products($cart_object) {
		foreach ($cart_object->cart_contents as $cart_item_key => $cart_item) {
			if (array_key_exists('custom_price', $cart_item)) {
				$cart_item['data']->price = $cart_item['custom_price'];
			}
		}
	}
	add_action('woocommerce_before_calculate_totals', 'overwrite_cart_price_for_rental_products');

Quite simple, eh? All it does is take the previously-written custom price and copies it to the Cart Item’s price property. This is where WooCommerce looks to find the price to be displayed on the cart and to be considered in the cart totals.

So that’s it! All four technical requirements are met. We have our custom Product data, a rental period input on the Product page, a magic AJAX function and a mechanism for overwriting the cart price. In practice, this allows an Administrator to set up rental products which get cheaper the longer you rent them for, and it allows the customer to specify their desired rental period for every Product they order. Utilising the hook “woocommerce_cart_item_name”, I write out the rental period for each Product in the cart.

rental-period-cart

In essence, this is such a large functional change to WooCommerce that it could very well become its own plugin. I made careful considerations through all of the customisation (beyond what you see above) to ensure that only Products tagged as “Rental” adopt these changes, so this site can still set up and sell normal Products with set prices if desired.

The fact that I was able to implement this type of change goes to credit the incredible extensibility of WordPress and WooCommerce. Naturally, WooCommerce’s developers did not consider Products that work like these in their design process – but what they did do is make the system flexible enough that the remote developer has the opportunity to make them work.

It’s this extensibility and flexibility that have made me vow to never install a WooCommerce plugin. Anything that clients want is possible to achieve with a little bit of elbow grease and some well-placed hooks – though maybe one day I’ll produce my own set of plugins to re-use my custom functionality anywhere.

Happy customising!

Jonno

We Are Recruiting!

Attention all web designers / developers based in Portsmouth, we are looking to recruit a full-time individual to join Team Tidy!

tidy-design-portsmouth-naval-club

Our office is located at the Royal Naval Club in Old Portsmouth. Here we create bespoke websites for amazing clients.

Over the past couple of months our business has evolved, we therefore need someone enthusiastic and motivated to help us take Tidy Design to the next level – Does this sound like you?

If you are a competent web design / web developer with good knowledge of CSS, HTML, JS, jQuery, PHP and MySQL then we want to hear from you this summer – please send rosie@tidydesign.com your CV / cover letter / portfolio today!

A Six-Month Review

As Rosie deals with month-end, I can’t help but look at our office white board listing 30+ tasks for us to tackle in July 2016 – Yup, its going to be a busy few weeks!

website-designer-portsmouth-mike

This year (to-date) has been pretty interesting, highly productive and also challenging for us as a company. Overall Tidy Design is seeing a good level of growth however it is very important that we maintain a certain level of quality/support during these busier periods…

I guess we all have to grow with our business/brand; we are all responsible for its evolution and must react to planned or unplanned change…

All in all it has been a fantastic six months here at Tidy Design, a massive “thank you” must go out to our clients (old and new) for making this tidy adventure possible! Another big thanks must go to Blayne, Jonathan and Rosie – team tidy rocks!