Inane Coding Go on, slap that wayward code


Using Piwik OpenCart eCommerce mod with Mijoshop

I recently got a query from Chris Flanagan at Siteease about using my Piwik Opencart eCommerce VQmod with Mijoshop (3rd party shopping cart software based on OpenCart). It seemed an interesting problem so I dived in....

After much too-ing and fro-ing we got it to work - So Im here to pass on the knowledge to anyone who may want a Mijoshop Piwik Ecommerce analytics mod. Mid-way through Chris wrote a blog post with lots of useful info -  - however this is now slightly out of date, but he has pinky promised to write a follow-up! P.S. Dont follow the advice to manually insert the tracking code into the bottom of the page, this was just a mid-diagnosis quick-fix. Once the mod is working correctly it will insert the tracking code itself.

The end result is that you need to modify the 'piwik.xml' file that comes as part of my Piwik Opencart eCommerce VQmod. The modification is very simple and just requires you to replace the following on line 19;

<search position="before" offset="1"><![CDATA[</body>]]></search>


<search position="before" offset="1"><![CDATA[</body>]]></search>

This makes sure the javascript code which is dynamically generated by my mod is correctly inserted into the Mijoshop footer. As Mijoshop has a slightly different footer template file this VQmod search term needs this minor modification.

Thats all there is to it!




First general release – Piwik OpenCart Ecommerce VQmod v0.3

Version 0.3 of my Piwik OpenCart Ecommerce VQmod has just been finished, hurrah!!

This is the first general release and is now available to download. The mod also now has its own github page.

v0.3 - 2013/05/28
First release of admin backend feature.
Arranged source files in an opencart folder structure for easy uploading.
PiwikTracker.php file now included for easier install.

Piwik OpenCart Ecommerce VQmod v0.2

Version 0.2 of my Piwik OpenCart Ecommerce VQmod has just been finished. As before this is a pre-release version with limited functionality and still requires testing. If you would like to trial it and give me feedback then please get in touch!

v0.2 - 2012/11/04
Fixed bug where the ecommerce action would sometimes not get attributed to the correct visitorID.
Improved Installation Instructions.

Announcing Piwik OpenCart Ecommerce VQmod!

I am in the process of writing a full Piwik Ecommerce mod for OpenCart.... this is very much a work in progress and a holding page!

Implements Piwik Ecommerce tracking for Opencart;
> Tracks regular page views
> Tracks Ecommerce product views (category views not yet implemented)
> Tracks Ecommerce cart add/update/delete
> Tracks Ecommerce orders

I have just finished the first draft pre-release version (v0.1) with limited functionality. If you would like to trial it and give me feedback then please get in touch!

v0.1 - 2012/10/20
First pre-release version.
Basic Ecommerce functionality.
No category reporting.
No admin back-end

Converting Excel date to Julian day-of-year number

I recently came across a mini-puzzler while helping a friend with Excel. I needed to convert an Excel 'Date' data type (see below for a recap) to the equivalent day-of-year number. This is sometimes called the 'Julian date', or more strictly correctly, 'ordinal date', as the famous Wikipedia informs me.

Now, this seemed simple - I thought - and I suppose it still is, relatively. But there is no single function where you can just plug in an Excel date and get out the day of the year, as I was expecting there would be. For example, to plug in 2011/08/25 or 25th August 2011 and get out '237' as the day number of that year. (By the way; if you just want to calculate the day of the year for a one-off I found this calculator was good).


Simple user input in batch files

I was recently playing around with batch scripts (*.bat files) - but what I wanted to do with the script snowballed and I found I needed more functionality, the main one being to be able to execute commands based on user input.

Below is an example of the code I used to do this. This is for Windows NT based batch execution (i.e. any recent computer).

SET /P _inputname= Please enter an input:
IF "%_inputname%"=="OMG" GOTO :they_said_omg
ECHO No 'OMG'... frowny face :(
GOTO :end
ECHO You said OMG!

Go on, slap that wayward code

Huzzah, it's alive!

Welcome to this here blog, courtesy of me. I will be bringing you regular articles with examples, snippets of code, and other programming related oddities which I come across during my day-to-day coding.

The articles will be covering a whole range of topics; off the top of my head here are a few areas that I've dealt with very recently which I may cover:

  • C programming
  • PHP, python
  • javascript
  • .htaccess files
  • SQL and interfacing with databases
  • batch scripting
  • VBA and excel
  • CSS and HTML
  • Programming AVR microcontrollers
  • and a whole host of others thrown in for bad measure - essentially whatever I come across.

I aim to make the articles informative and unique, to help you find that useful code example to do that thing you've always wanted to do. You know that thing? Yes that one.

Hopefully a few of the tricks I come across while searching for ways to accomplish things myself will be useful to others, and save you that little bit of time. And... if they do you can always donate!

Take it sleazy,