Fix Mobile Device Detection in ISC

Problem

Some mobile browsers are not detected, e.g. Firefox in Android

Solution

In /lib/general.php

Find

if(stripos($userAgent, 'webkit') !== false) {
	if(stripos($userAgent, 'iphone') !== false) {
		return array(
			'category'	=> 'phone',
			'device'	=> 'iphone'
		);
	}
	else if(stripos($userAgent, 'ipod') !== false) {
		return array(
			'category'	=> 'phone',
			'device'	=> 'ipod'
		);
	}
	else if(stripos($userAgent, 'ipad') !== false) {
		return array(
			'category'	=> 'tablet',
			'device'	=> 'ipad'
		);
	}
	else if(stripos($userAgent, 'android') !== false) {
		return array(
			'category'	=> 'phone',
			'device'	=> 'android'
		);
	}
	else if(stripos($userAgent, 'webos') !== false && stripos($userAgent, 'pre') !== false) {
		return array(
			'category'	=> 'phone',
			'device'	=> 'pre'
		);
	}
}

Replace

if(stripos($userAgent, 'webkit') !== false) {
	if(stripos($userAgent, 'iphone') !== false) {
		return array(
			'category'	=> 'phone',
			'device'	=> 'iphone'
		);
	}
	else if(stripos($userAgent, 'ipod') !== false) {
		return array(
			'category'	=> 'phone',
			'device'	=> 'ipod'
		);
	}
	else if(stripos($userAgent, 'ipad') !== false) {
		return array(
			'category'	=> 'tablet',
			'device'	=> 'ipad'
		);
	}
	else if(stripos($userAgent, 'android') !== false) {
		return array(
			'category'	=> 'phone',
			'device'	=> 'android'
		);
	}
	else if(stripos($userAgent, 'webos') !== false && stripos($userAgent, 'pre') !== false) {
		return array(
			'category'	=> 'phone',
			'device'	=> 'pre'
		);
	}
}else{
	if(stripos($userAgent, 'mobile') !== false) {
		return array(
			'category'	=> 'phone',
			'device'	=> 'android'
		);
	}
}

In /classes/class.checkout.php

Find

// iPhone
if(strpos($agent, 'safari') !== false && strpos($agent, 'mobile') !== false) {
	return false;
}

Replace

// iPhone
if(strpos($agent, 'safari') !== false && strpos($agent, 'mobile') !== false) {
	return false;
}

// Firefox
if(strpos($agent, 'firefox') !== false && strpos($agent, 'mobile') !== false) {
	return false;
}

Leave a Reply

Your email address will not be published. Required fields are marked *