Skip to content

Commit 188a6b0

Browse files
author
bruno-g
committed
First commit
0 parents  commit 188a6b0

23 files changed

+9290
-0
lines changed

.gitattributes

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
3+
4+
# Custom for Visual Studio
5+
*.cs diff=csharp
6+
*.sln merge=union
7+
*.csproj merge=union
8+
*.vbproj merge=union
9+
*.fsproj merge=union
10+
*.dbproj merge=union
11+
12+
# Standard to msysgit
13+
*.doc diff=astextplain
14+
*.DOC diff=astextplain
15+
*.docx diff=astextplain
16+
*.DOCX diff=astextplain
17+
*.dot diff=astextplain
18+
*.DOT diff=astextplain
19+
*.pdf diff=astextplain
20+
*.PDF diff=astextplain
21+
*.rtf diff=astextplain
22+
*.RTF diff=astextplain

.gitignore

+163
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
#################
2+
## Eclipse
3+
#################
4+
5+
*.pydevproject
6+
.project
7+
.metadata
8+
bin/
9+
tmp/
10+
*.tmp
11+
*.bak
12+
*.swp
13+
*~.nib
14+
local.properties
15+
.classpath
16+
.settings/
17+
.loadpath
18+
19+
# External tool builders
20+
.externalToolBuilders/
21+
22+
# Locally stored "Eclipse launch configurations"
23+
*.launch
24+
25+
# CDT-specific
26+
.cproject
27+
28+
# PDT-specific
29+
.buildpath
30+
31+
32+
#################
33+
## Visual Studio
34+
#################
35+
36+
## Ignore Visual Studio temporary files, build results, and
37+
## files generated by popular Visual Studio add-ons.
38+
39+
# User-specific files
40+
*.suo
41+
*.user
42+
*.sln.docstates
43+
44+
# Build results
45+
[Dd]ebug/
46+
[Rr]elease/
47+
*_i.c
48+
*_p.c
49+
*.ilk
50+
*.meta
51+
*.obj
52+
*.pch
53+
*.pdb
54+
*.pgc
55+
*.pgd
56+
*.rsp
57+
*.sbr
58+
*.tlb
59+
*.tli
60+
*.tlh
61+
*.tmp
62+
*.vspscc
63+
.builds
64+
*.dotCover
65+
66+
## TODO: If you have NuGet Package Restore enabled, uncomment this
67+
#packages/
68+
69+
# Visual C++ cache files
70+
ipch/
71+
*.aps
72+
*.ncb
73+
*.opensdf
74+
*.sdf
75+
76+
# Visual Studio profiler
77+
*.psess
78+
*.vsp
79+
80+
# ReSharper is a .NET coding add-in
81+
_ReSharper*
82+
83+
# Installshield output folder
84+
[Ee]xpress
85+
86+
# DocProject is a documentation generator add-in
87+
DocProject/buildhelp/
88+
DocProject/Help/*.HxT
89+
DocProject/Help/*.HxC
90+
DocProject/Help/*.hhc
91+
DocProject/Help/*.hhk
92+
DocProject/Help/*.hhp
93+
DocProject/Help/Html2
94+
DocProject/Help/html
95+
96+
# Click-Once directory
97+
publish
98+
99+
# Others
100+
[Bb]in
101+
[Oo]bj
102+
sql
103+
TestResults
104+
*.Cache
105+
ClientBin
106+
stylecop.*
107+
~$*
108+
*.dbmdl
109+
Generated_Code #added for RIA/Silverlight projects
110+
111+
# Backup & report files from converting an old project file to a newer
112+
# Visual Studio version. Backup files are not needed, because we have git ;-)
113+
_UpgradeReport_Files/
114+
Backup*/
115+
UpgradeLog*.XML
116+
117+
118+
119+
############
120+
## Windows
121+
############
122+
123+
# Windows image file caches
124+
Thumbs.db
125+
126+
# Folder config file
127+
Desktop.ini
128+
129+
130+
#############
131+
## Python
132+
#############
133+
134+
*.py[co]
135+
136+
# Packages
137+
*.egg
138+
*.egg-info
139+
dist
140+
build
141+
eggs
142+
parts
143+
bin
144+
var
145+
sdist
146+
develop-eggs
147+
.installed.cfg
148+
149+
# Installer logs
150+
pip-log.txt
151+
152+
# Unit test / coverage reports
153+
.coverage
154+
.tox
155+
156+
#Translations
157+
*.mo
158+
159+
#Mr Developer
160+
.mr.developer.cfg
161+
162+
# Mac crap
163+
.DS_Store

README.md

+182
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
## Lara Cart
2+
**Version: 1.0**
3+
4+
A Shopping Cart Bundle for Laravel, based on the Cart library from CodeIgniter.
5+
6+
## Installation
7+
Clone the project into **bundles/lara-cart**
8+
9+
Then, update your bundles.php to auto-start the bundle.
10+
11+
return array(
12+
'lara-cart' => array( 'auto' => true )
13+
);
14+
15+
Then move the **public** folder outside the **bundles/lara-cart** folder.
16+
17+
## Viewing the Example
18+
Just navigate to the page **cart**, example
19+
20+
http://laravel.local/public/cart
21+
22+
## Adding an Item to The Cart
23+
To add an item to the shopping cart, simply pass an array with the product information to the Cart::add() method, as shown below:
24+
25+
$item = array(
26+
'id' => 'sku_123ABC',
27+
'qty' => 1,
28+
'price' => 39.95,
29+
'name' => 'T-Shirt',
30+
'options' => array(
31+
'Size' => 'L',
32+
'Color' => 'Red'
33+
)
34+
);
35+
36+
Cart::add( $item );
37+
38+
39+
####Important:
40+
The first four array indexes above (id, qty, price, and name) are required.
41+
If you omit any of them the data will not be saved to the cart.
42+
The fifth index (options) is optional.
43+
It is intended to be used in cases where your product has options associated with it.
44+
Use an array for options, as shown above.
45+
46+
**The five reserved indexes are:**
47+
- **id** - Each product in your store must have a unique identifier. Typically this will be an "sku" or other such identifier.
48+
- **qty** - The quantity being purchased.
49+
- **price** - The price of the item.
50+
- **name** - The name of the item.
51+
- **options** - Any additional attributes that are needed to identify the product. These must be passed via an array.
52+
53+
In addition to the five indexes above, there are two reserved words: **rowid** and **subtotal**. These are used internally by the Cart class, so please do NOT use those words as index names when inserting data into the cart.
54+
55+
Your array may contain additional data. Anything you include in your array will be stored in the session. However, it is best to standardize your data among all your products in order to make displaying the information in a table easier.
56+
57+
The add() method will return the $rowid if you successfully insert a single item.
58+
59+
## Adding Multiple Items to The Cart
60+
By using a multi-dimensional array, as shown below, it is possible to add multiple products to the cart in one action. This is useful in cases where you wish to allow people to select from among several items on the same page.
61+
62+
$items = array(
63+
array(
64+
'id' => 'sku_123ABC',
65+
'qty' => 1,
66+
'price' => 39.95,
67+
'name' => 'T-Shirt',
68+
'options' => array(
69+
'Size' => 'L',
70+
'Color' => 'Red'
71+
)
72+
),
73+
array(
74+
'id' => 'sku_567ZYX',
75+
'qty' => 1,
76+
'price' => 9.95,
77+
'name' => 'Coffee Mug'
78+
),
79+
array(
80+
'id' => 'sku_965QRS',
81+
'qty' => 1,
82+
'price' => 29.95,
83+
'name' => 'Shot Glass'
84+
)
85+
);
86+
87+
Cart::add( $items );
88+
89+
90+
## Updating the Cart
91+
To update the information in your cart, you must pass an array containing the Row ID and quantity to the Cart::update() method:
92+
93+
####Note:
94+
If the quantity is set to zero, the item will be removed from the cart.
95+
96+
**Updating a single item:**
97+
98+
$item = array(
99+
'rowid' => 'b99ccdf16028f015540f341130b6d8ec',
100+
'qty' => 3
101+
);
102+
103+
Cart::update( $item );
104+
105+
106+
**Updating multiple items:**
107+
108+
$items = array(
109+
array(
110+
'rowid' => 'b99ccdf16028f015540f341130b6d8ec',
111+
'qty' => 3
112+
),
113+
array(
114+
'rowid' => 'xw82g9q3r495893iajdh473990rikw23',
115+
'qty' => 4
116+
),
117+
array(
118+
'rowid' => 'fh4kdkkkaoe30njgoe92rkdkkobec333',
119+
'qty' => 2
120+
)
121+
);
122+
123+
Cart::update( $items );
124+
125+
126+
####What is a Row ID?
127+
The row ID is a unique identifier that is generated by the cart code when an item is added to the cart. The reason a unique ID is created is so that identical products with different options can be managed by the cart.
128+
129+
For example, let's say someone buys two identical t-shirts (same product ID), but in different sizes. The product ID (and other attributes) will be identical for both sizes because it's the same shirt. The only difference will be the size. The cart must therefore have a means of identifying this difference so that the two sizes of shirts can be managed independently. It does so by creating a unique "row ID" based on the product ID and any options associated with it.
130+
131+
In nearly all cases, updating the cart will be something the user does via the "view cart" page, so as a developer, it is unlikely that you will ever have to concern yourself with the "row ID", other then making sure your "view cart" page contains this information in a hidden form field, and making sure it gets passed to the update function when the update form is submitted. Please examine the construction of the "view cart" page above for more information.
132+
133+
134+
135+
## Removing items from the Cart
136+
To remove an item from your cart, you must pass the Row ID to the Cart::remove() method:
137+
138+
Cart::remove('fh4kdkkkaoe30njgoe92rkdkkobec333');
139+
140+
141+
## Displaying the Cart
142+
To display the cart you will create a view file with code similar to the one shown below.
143+
144+
TODO..
145+
146+
147+
## Function Reference
148+
149+
Cart::add();
150+
Permits you to add items to the shopping cart.
151+
152+
Cart::update();
153+
Permits you to update items in the shopping cart.
154+
155+
Cart::remove(rowid);
156+
Permits you to remove an item from the shopping cart.
157+
158+
Cart::total();
159+
Displays the total amount in the cart.
160+
161+
Cart::total_items();
162+
Displays the total number of items in the cart.
163+
164+
Cart::contents();
165+
Returns an array containing everything in the cart.
166+
167+
Cart:has_options(rowid);
168+
Returns TRUE (boolean) if a particular row in the cart contains options. This function is designed to be used in a loop with Cart::contents(), since you must pass the rowid to this function, as shown in the Displaying the Cart example above.
169+
170+
Cart::product_options(rowid);
171+
Returns an array of options for a particular product. This function is designed to be used in a loop with Cart::contents(), since you must pass the rowid to this function, as shown in the Displaying the Cart example above.
172+
173+
Cart::destroy();
174+
Permits you to destroy the cart. This function will likely be called when you are finished processing the customer's order.
175+
176+
177+
## Credits
178+
CodeIgniter for writing this Library.
179+
Twitter for the awesome Bootstrap framework.
180+
181+
182+

0 commit comments

Comments
 (0)