Welcome Guest, Not a member yet? Register   Sign In
Cart Library - possible problems
#4

[eluser]got 2 doodle[/eluser]
OK, so easy enough to get the rowid from your product ID. Personally I probably won't use the options array since it doesn't really make sense to me.

But, and this is huge! If you want to work that way you can! CodeIgnitor does it again with flexibility in mind.

to get the rowid I extended the Cart library
Code:
class MY_Cart extends CI_Cart {

/* function to return rowid */
    function row_id($id,$options=array())
    {
        if (count($options) > 0)
        {
            $rowid = md5($id.implode('', $options));
        }
        else
        {
            $rowid = md5($id);
        }        

        return $rowid;
    }


}

now I can just send the id to the controller that does the delete (id included in url)

Code:
echo anchor('lmf/product_delete/'.$product_id,'Delete');

and in the controller
Code:
/*******************************************************************************/    
    function product_delete()
/*******************************************************************************/    
    
    {  
$item = array(
               'rowid'      => $this->cart->row_id($this->uri->segment(3)),
               'qty'     => 0,
            );

$this->cart->update($item);    
redirect('/lmf/products', 'refresh');

    }

so all is good in the world ;-)


Messages In This Thread
Cart Library - possible problems - by El Forum - 02-24-2009, 09:11 AM
Cart Library - possible problems - by El Forum - 02-24-2009, 10:14 AM
Cart Library - possible problems - by El Forum - 02-24-2009, 10:40 AM
Cart Library - possible problems - by El Forum - 02-24-2009, 02:43 PM
Cart Library - possible problems - by El Forum - 02-24-2009, 04:32 PM
Cart Library - possible problems - by El Forum - 02-25-2009, 02:36 AM
Cart Library - possible problems - by El Forum - 02-25-2009, 03:26 AM
Cart Library - possible problems - by El Forum - 02-25-2009, 03:40 AM
Cart Library - possible problems - by El Forum - 02-25-2009, 04:21 AM
Cart Library - possible problems - by El Forum - 02-25-2009, 04:25 AM
Cart Library - possible problems - by El Forum - 02-25-2009, 07:35 AM
Cart Library - possible problems - by El Forum - 02-25-2009, 09:16 AM
Cart Library - possible problems - by El Forum - 04-06-2009, 01:15 PM
Cart Library - possible problems - by El Forum - 04-20-2009, 04:40 PM
Cart Library - possible problems - by El Forum - 04-21-2009, 11:47 AM



Theme © iAndrew 2016 - Forum software by © MyBB