Jump to content

toastrom

Member
  • Posts

    5
  • Joined

  • Last visited

Posts posted by toastrom

  1. Can "You" please confirm that this code is OK?

    It do the job but as I said, I'm trying to learn.

       public function RemoveItem($product_id) {
           if (array_key_exists($product_id , $this->items))
               $this->items[$product_id] = $this->items[$product_id] - 1;
           if ($this->items[$product_id] == 0) {
               unset($this->items[$product_id]);
               }
       }

     

    TIA

    toastrom

  2. Hi,

     

    I'm new with this OOP and I try to remove an item quantity from the array.

    I don't know if this way is ok but works with:

    public function RemoveItem($product_id) {
           $this->items[$product_id] = $this->items[$product_id] - 1;
       }

     

    My problem is, how to delete the whole item from the array when the item quantity is 0?

        if $this->items[$product_id] == 0;
           unset($this->items[$product_id]);

    Something like that, or? I can't get it work in the Killer shopping cart!

     

    Thanks

    toastrom

×
×
  • Create New...