Posts and Pages Tagged ‘opencart’

Opencart Paypal failures/INVALID with foreign characters Last updated:17 September 2012

We’ve had occasional oddities with Paypal (Standard) payments showing as ‘Pending Paypal’ on Opencart, with the Error Log showing an “INVALID” response from the Paypal IPN transaction. However, when we check on Paypal, the transaction has completed without a problem.

Opencart error log

The (seemingly) common factor with the payments that show like this is that originated in a foreign currency, so I’d assumed that was the problem, but in fact some orders from (the same) currencies went through OK. On Saturday I spotted that those that failed all included a ‘non-standard’ character in the customer’s names: é, ø etc. And this suggested an issue with character sets.

So, after a bit of digging, I discovered that Paypal, as a default, sends all IPN responses encoded as win-1252, whereas my website is in utf-8. You can change this, although it isn’t easy to find, via My Profile > My Selling Preferences > Paypal Button Language Encoding (link right at the bottom) and then the ‘More options’ button. Set the encoding used on your website to utf-8 (or whatever you use, obviously…).

Paypal screenshot showing encoding settings

Testing this after making the change means no more failures with non-standard characters.

Creating a mobile theme for Opencart Last updated:5 August 2012

In the past few weeks I’ve been working on a mobile theme for Opencart. This is a summary of what I did. There’s some more information available on these blog posts as well.

  • Rewrote most of the templates to: remove structural tables, ensure the pages function without javascript, and generally simplified into a single column design
  • Created a brand new css file, removing all the background images except those used for the mobile menu
  • Only displaying the Categories and Information modules on the home page, nothing else
  • Created a separate Information page for Contact details, just for the mobile site
  • Removed related products from the product page
  • No search facility
  • Removed popup windows for product images and terms and conditions
  • No sidebar cart, instead a mobile specific version of ajax_add.js which updates the cart and updates an indicator in the heading showing the number of products in the cart

Not that it’s infallible, but the main, non-mobile site scores 3% on the W3C Mobile OK Checker, and the new mobile site scores 99% (the remaining 1% being because I haven’t set the height on the header image to allow it to resize to the screen.

After experimenting with using media queries on the main site to display a link to the mobile site below certain dimensions I’ve instead just followed the BBC’s approach and displayed a link permanently.

Because a couple of people have asked, here’s a zip file containing the template files and javascript, plus a vQmod file containing the necessary amendments to the controller files :

Mobile theme files (49kb).

This contains the mobile theme plus code which I was using already which displays and dynamically updates the quantity of stock available per product. This works with Opencart 1.4.9.5 but won’t work with Opencart 1.5 without some considerable modification – see here for a version for Opencart 1.5.

You’re welcome to feedback comments but I’m not offering to support this theme full time. If you do use it, however, then a “buy me a drink” donation would be appreciated.

You can see the live site here – this uses a very slightly customised version of the mobile theme to support some additional images.

Opencart 1.5 Mobile Theme – 2 Last updated:29 June 2012

I’ve now pretty much finished developing a mobile theme for Opencart. I’d value any constructive feedback – you can find the test site here (best viewed on a mobile or via a mobile emulator I think). Here’s a few screenshots just to get you interested:

Opencart 1.5 Mobile Theme Opencart 1.5 Mobile Theme Opencart 1.5 Mobile Theme

Feel free to create test accounts, buy products etc etc (although don’t expect your orders to be fulfilled…). At the moment I’ve got a couple of payment options enabled, just so you can see the checkout screens, plus the Featured module on the home page. If there’s anything else particular you’d like to see then let me know via a comment.

A little more detail on what changes have been made is here.

Opencart 1.5 Mobile Theme – 1 Last updated:28 June 2012

Following on from earlier efforts to create a mobile theme for my existing Opencart 1.4.9.5 store, I’m currently working on creating a mobile theme that will work with Opencart 1.5.

I’m trying to be a little more comprehensive this time and account for most options. The biggest challenge so far is the Opencart 1.5 checkout page which runs on about 840 lines of jQuery (ugh!) on the default theme. I spent some time last week investigating whether this could be made to work without javascript – and have concluded that while this is possible it’s very very unpleasant, so have accepted that I’ll have to assume javascript in this case (unlike 1.4.9.5 where it is relatively straightforward to make the use of javascript an enhancement rather than a necessity). I spent this morning functionalising the jQuery somewhat – so the five separate pieces of code to display name and address field validation errors are now replaced by a single function. I still have 690 lines of javascript though…

At the moment this exercise is of somewhat academic exercise, but if a mobile theme is of any interest to you, let me know via a comment below.

Creating a mobile version of an Opencart shop – 5 Last updated:16 March 2012

Nearly finished this stage now I think. I’ve now worked through all the pages (I think…) and updated them. This morning I realised that although the site works mostly OK without javascript, without it the zones (counties in the UK) are not populated, so it’s impossible to enter an address. Ugh. Resolving this needs the following adding to /catalog/controller/account/create.php, /catalog/controller/account/address.php, /controller/checkout/address.php and /controller/checkout/guest_step_1.php

$this->load->model('localisation/zone');
		
$this->data['zones'] = $this->model_localisation_zone->getZonesByCountryId($this->data['country_id']);

And the following editing in /catalog/view/theme/[your theme]/template/create.tpl, /catalog/view/theme/[your theme]/template/address.tpl, /catalog/view/theme/[your theme]/template/address.tpl and /catalog/view/theme/[your theme]/template/guest_step_2.tpl:

<select name="zone_id">
   <option value="FALSE"><?php echo $text_select; ?></option>
   <?php foreach ($zones as $zone) { ?>
     <?php if ($zone['zone_id'] == $zone_id) { ?>
     <option value="<?php echo $sone['zone_id']; ?>" selected="selected"><?php echo $zone['name']; ?></option>
     <?php } else { ?>
        <option value="<?php echo $zone['zone_id']; ?>"><?php echo $zone['name']; ?></option>
     <?php } ?>
   <?php } ?>          
</select>

(It would be nice if the code used functions a little more for repeated things like the address form.) This then allows selection of zone even with javascript disabled. There’s still a much more minor problem, which is that if the country is changed, with javascript disabled the zone list is not refreshed. This resolves itself when the form is submitted since the zones are then correctly populated by the posted data, but is less than perfect. We get very few orders from outside the UK anyway, so I’m going to park that one for now. The solution, I think, would be to add a button to let the user manually refresh the page, minus the validation, after changing the country.

Anyway, back to the mobile site specifics. I showed it to the client (to whom, coincidentally, I’m married…) yesterday, and she is happy so far. Hoorah! Next step is to test it with some tame users I think.

Concerns I have at the moment: not sure about scrolling the menu on the home page; I wonder whether clicking through from the category page to the product page is too difficult (although in fact most of our sales come direct from the category page not the product page); think the general text might be a bit small. We’ll see.