Foros del Web » Programando para Internet » PHP »

Clases en php

Estas en el tema de Clases en php en el foro de PHP en Foros del Web. Hola. tengo que implementar una clase de carrito de compra, pero no sé como. ayuda por favor como la implento??? o si me pueden dar ...
  #1 (permalink)  
Antiguo 12/08/2004, 13:32
 
Fecha de Ingreso: julio-2004
Ubicación: Arg. Neuquén
Mensajes: 44
Antigüedad: 19 años, 8 meses
Puntos: 0
Clases en php

Hola. tengo que implementar una clase de carrito de compra, pero no sé como. ayuda por favor como la implento??? o si me pueden dar algunos tutoriales o algo
Código PHP:
class Basket {
        var 
$basket_count;
        var 
$basket_item_id;
        var 
$basket_item_name;
        var 
$basket_item_quantity;
        var 
$basket_item_data;
        var 
$basket_item_price;

        function 
Basket() {
                
$this->basket_count=0;
        }
        function 
Add_Item($ID,$name,$quantity=1,$price=0,$data='') {
                
$this->basket_item_id[$this->basket_count]=$ID;
                
$this->basket_item_name[$this->basket_count]=$name;
                
$this->basket_item_quantity[$this->basket_count]=$quantity;
                
$this->basket_item_data[$this->basket_count]=$data;
                
$this->basket_item_price[$this->basket_count]=$price;
                
$this->basket_count++;
                return (
$this->basket_count-1);
        }
        function 
Del_Item($pos) {
                
$this->basket_item_id[$pos]='';
                
$indice=$this->basket_count;
                
$contador=$pos;
                while (
$contador<$indice){
                    
$this->basket_item_id[$contador]=$this->basket_item_id[$contador+1];
                    
$this->basket_item_name[$contador]=$this->basket_item_name[$contador+1];
                    
$this->basket_item_quantity[$contador]=$this->basket_item_quantity[$contador+1];
                    
$this->basket_item_data[$contador]=$this->basket_item_data[$contador+1];
                    
$this->basket_item_price[$contador]=$this->basket_item_price[$contador+1];
                    
$contador++;
                }
                
$this->basket_item_id[$contador]=null;
                
$this->basket_item_name[$contador]=null;
                
$this->basket_item_quantity[$contador]=null;
                
$this->basket_item_data[$contador]=null;
                
$this->basket_item_price[$contador]=null;
                
$this->basket_count=$contador-1;
        }
        function 
Get_Item_ID($pos) {
                return 
$this->basket_item_id[$pos];
        }
        function 
Get_Item_Name($pos) {
                return 
$this->basket_item_name[$pos];
        }
        function 
Get_Item_Price($pos) {
                return 
$this->basket_item_price[$pos];
        }
        function 
Get_Item_Quantity($pos) {
                return 
$this->basket_item_quantity[$pos];
        }
        function 
Get_Item_Data($pos) {
                return 
$this->basket_item_data[$pos];
        }
        function 
Set_Item_Quantity($pos,$quantity) {
                
$this->basket_item_quantity[$pos]=$quantity;
        }
        function 
Set_Item_Data($pos,$data) {
                
$this->basket_item_data[$pos]=$data;
        }
        function 
Enum_Items($start=false) {
                static 
$current;
                if (
$current>=$this->basket_count) return -1;
                if (!
$start) {
                        
$current++;
                } else {
                        
$current=0;
                }
                while ((
$this->basket_item_id[$current]=='') && ($current<$this->basket_count)) {
                        
$current++;
                }
                return (
$current<$this->basket_count) ? $current : -1;
        }
        function 
Empty_Basket() {
                
$this->basket_count=0;
        }
        function 
Get_Basket_Count() {
            
$num=0;
            for (
$i=0;$i<$this->basket_count;$i++) {
                        if (
$this->basket_item_id[$i]!=''$num++;
            }
            return 
$num;
        }

  #2 (permalink)  
Antiguo 12/08/2004, 14:43
O_O
 
Fecha de Ingreso: enero-2002
Ubicación: Santiago - Chile
Mensajes: 34.417
Antigüedad: 22 años, 2 meses
Puntos: 129
Si quieres aprender OOP bajo PHP revisa este tutorial:
http://www.zonaphp.com/articulo1.php

Pero si quiers algo ya hecho al respecto (en classe) .. visita:
www.phpclasses.org

Un saludo,
  #3 (permalink)  
Antiguo 12/08/2004, 15:11
 
Fecha de Ingreso: julio-2004
Ubicación: Arg. Neuquén
Mensajes: 44
Antigüedad: 19 años, 8 meses
Puntos: 0
Muchas Gracias Cluster
cualquier cosa te aviso.

Saludos de Arg.!
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:55.