Back to PhocacartAttribute class

Method setAttributeValue

public static
setAttributeValue
(mixed $type, mixed $value, mixed $encoded = false, mixed $display = false, mixed $typeOption = 0)

Method setAttributeValue - Source code

/*
 * type of attribute
 * value of attribute
 * encoded - is urlencoded yet
 * display - are we asking it for display (we only want to display text attributes value not checkbox or selectboxes which include
 *           numbers (their values are displayed other way
 * type of option
 */
public static function setAttributeValue($type, $value, $encoded = false, $display = false, $typeOption = 0)
{
    switch ($type) {
        case 7:
        case 8:
        case 9:
        case 10:
        case 11:
        case 12:
        case 20:
            if ($encoded || $display) {
                $value = urldecode($value);
            }
            $value = strip_tags($value);
            return urlencode(substr($value, 0, self::getAttributeLength($type, $typeOption)));
            break;
        default:
            if ($display) {
                return '';
            } else {
                return (int) $value;
            }
            break;
    }
    return false;
}