CodeIgniter Cart class product name restrictions

codeigniter logo
The CodeIgniter cart class has a non immediately apparent feature regarding special characters in the Product Name. Within the Cart library the line
var $product_name_rules = '\.\:\-_ a-z0-9'; // alpha-numeric, dashes, underscores, colons or periods will strip out any non defined special characters. While you could hack this line, the correct way to do this is to extend the library and create an over-ride.

Create a new file application/libraries/MY_Cart.php

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Cart extends CI_Cart {

function __construct() {
parent::__construct();

// Remove limitations in product names
$this->product_name_rules = '\d\D';
}
}

Note this will allow all characters, you may want to limit to specified special characters.