Welcome Guest, Not a member yet? Register   Sign In
Shopping cart library
#1
Brick 

Hello,

I'm new on this forum and don't know if this question is in the right sector.
But I've discovered a few bug/Not made functions in the default cart library

So I made it myself and made functions like:
Update not only "Quantity" but also "Options". This allows you to update the added options like the size of a shirt.

I added a function that allows you to show a product individual with the rowid.

These adds are not spectacular but I don't know if I may "release" this or even may edit stuff like this.

show before I will release anything I want to be sure it's legal.
And maybe you have found some bugs in the cart that need a fix please let me know

Friendly regards,
Stefan Fransen
Sorry for bad english I'm dutch
Reply
#2

Hey,

It's definitely legal and any fixes or improvements would be greatly appreciated. Can you please submit a pull request at: https://github.com/bcit-ci/CodeIgniter
- Ben Edmunds
 CI Counsel Member  |  @benedmunds
 Ion Auth  |  Securing PHP Apps
Reply
#3

Hi,

I don't know why but i can't do a pull request so i post it here so someone who can maybe wil doe this.

Delete single item of cart:
Code:
function destroy($row_id = FALSE)
    {
        if($row_id === FALSE){
            unset($this->_cart_contents);
            $this->_cart_contents['cart_total'] = 0;
            $this->_cart_contents['total_items'] = 0;
            $this->CI->session->unset_userdata('cart_contents');
        }else{
            unset($this->_cart_contents[$row_id]);
            $this->_save_cart();
        }
    }

Update options of cart item:
Code:
if ($this->_cart_contents[$items['rowid']]['qty'] == $items['qty'] && $this->_cart_contents[$items['rowid']]['options'] == $items['options'])
        {
            return FALSE;
        }

        // Is the quantity zero?  If so we will remove the item from the cart.
        // If the quantity is greater than zero we are updating
        if ($items['qty'] == 0)
        {
            unset($this->_cart_contents[$items['rowid']]);
        }
        else
        {
            $this->_cart_contents[$items['rowid']]['qty'] = $items['qty'];
            $this->_cart_contents[$items['rowid']]['options'] = $items['options'];
        }

        if(!$this->_cart_contents[$items['rowid']]['options'] == $items['options']){
            $this->_cart_contents[$items['rowid']]['options'] = $items['options'];
        }

Hoop someone find this useful,
Stefan Fransen
Reply




Theme © iAndrew 2016 - Forum software by © MyBB