Cart Library in CodeIgniter 4

CodeIgniter 4 officially not supporting Cart Library like CI3. but we will use the same cart in CI4. Let’s get Started.

STEP 1 

Create a file ‘Cart.php’ in ‘app/Libraries/’. e.g. (app/Libraries/Cart.php) and Copy Bellow Code to your Codeigniter 4 App/Libraries/Cart.php

 

STEP 2

Copy Bellow Code to your Codeigniter 4 app/Config/Services.php

 

STEP 3

Copy Bellow Code to your Codeigniter 4 app/Common.php

That’s DONE, Now you can use cart() like ci3. example given below

 

Credit : Manoj Bist

Leave a Reply

Your email address will not be published. Required fields are marked *