Ejemplo n.º 1
0
    }
} else {
    if ($action == 'clear') {
        $key = isset($key) ? trim($key) : '';
        if (preg_match("/^[0-9]{1,}-[0-9]{1,}-[0-9]{1,}-[0-9]{1,}\$/", $key)) {
            $cart = str_replace(',' . $key . ',', ',', $cart . ',');
            if (substr($cart, -1) == ',') {
                $cart = substr($cart, 0, -1);
            }
            $do->set($cart);
            if (isset($ajax)) {
                exit('1');
            }
            message('', 'cart.php?tm=' . $DT_TIME);
        } else {
            $do->del();
            message('', 'cart.php?tm=' . $DT_TIME);
        }
    } else {
        $reset = false;
        if ($itemid) {
            if (is_array($itemid)) {
                foreach ($itemid as $id) {
                    $id = intval($id);
                    $id = $id . '-0-0-0';
                    if (strpos($cart . ',', ',' . $id . ',') === false) {
                        $reset = true;
                        $cart = ',' . $id . $cart;
                    }
                }
            } else {