├── LICENSE.txt
├── README.md
├── ShoppingCart.sln
└── ShoppingCart
├── Properties
└── AssemblyInfo.cs
├── ShoppingCart.csproj
├── Web.Debug.config
├── Web.Release.config
├── Web.config
├── bin
├── ShoppingCart.dll
└── ShoppingCart.pdb
├── css
└── style.css
├── default.htm
├── img
├── logo.png
├── products
│ ├── APL.jpg
│ ├── AVC.jpg
│ ├── BAN.jpg
│ ├── CTP.jpg
│ ├── FIG.jpg
│ ├── GRF.jpg
│ ├── GRP.jpg
│ ├── GUA.jpg
│ ├── KIW.jpg
│ ├── LYC.jpg
│ ├── MAN.jpg
│ ├── ORG.jpg
│ ├── PAP.jpg
│ ├── PCH.jpg
│ ├── PER.jpg
│ ├── PMG.jpg
│ ├── PNP.jpg
│ ├── PSM.jpg
│ ├── STR.jpg
│ ├── TNG.jpg
│ └── WML.jpg
├── r0.png
├── r1.png
├── r2.png
├── r3.png
└── r4.png
├── js
├── app.js
├── controller.js
├── product.js
├── shoppingCart.js
└── store.js
└── partials
├── product.htm
├── shoppingCart.htm
└── store.htm
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction, and
10 | distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by the copyright
13 | owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all other entities
16 | that control, are controlled by, or are under common control with that entity.
17 | For the purposes of this definition, "control" means (i) the power, direct or
18 | indirect, to cause the direction or management of such entity, whether by
19 | contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
20 | outstanding shares, or (iii) beneficial ownership of such entity.
21 |
22 | "You" (or "Your") shall mean an individual or Legal Entity exercising
23 | permissions granted by this License.
24 |
25 | "Source" form shall mean the preferred form for making modifications, including
26 | but not limited to software source code, documentation source, and configuration
27 | files.
28 |
29 | "Object" form shall mean any form resulting from mechanical transformation or
30 | translation of a Source form, including but not limited to compiled object code,
31 | generated documentation, and conversions to other media types.
32 |
33 | "Work" shall mean the work of authorship, whether in Source or Object form, made
34 | available under the License, as indicated by a copyright notice that is included
35 | in or attached to the work (an example is provided in the Appendix below).
36 |
37 | "Derivative Works" shall mean any work, whether in Source or Object form, that
38 | is based on (or derived from) the Work and for which the editorial revisions,
39 | annotations, elaborations, or other modifications represent, as a whole, an
40 | original work of authorship. For the purposes of this License, Derivative Works
41 | shall not include works that remain separable from, or merely link (or bind by
42 | name) to the interfaces of, the Work and Derivative Works thereof.
43 |
44 | "Contribution" shall mean any work of authorship, including the original version
45 | of the Work and any modifications or additions to that Work or Derivative Works
46 | thereof, that is intentionally submitted to Licensor for inclusion in the Work
47 | by the copyright owner or by an individual or Legal Entity authorized to submit
48 | on behalf of the copyright owner. For the purposes of this definition,
49 | "submitted" means any form of electronic, verbal, or written communication sent
50 | to the Licensor or its representatives, including but not limited to
51 | communication on electronic mailing lists, source code control systems, and
52 | issue tracking systems that are managed by, or on behalf of, the Licensor for
53 | the purpose of discussing and improving the Work, but excluding communication
54 | that is conspicuously marked or otherwise designated in writing by the copyright
55 | owner as "Not a Contribution."
56 |
57 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
58 | of whom a Contribution has been received by Licensor and subsequently
59 | incorporated within the Work.
60 |
61 | 2. Grant of Copyright License.
62 |
63 | Subject to the terms and conditions of this License, each Contributor hereby
64 | grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
65 | irrevocable copyright license to reproduce, prepare Derivative Works of,
66 | publicly display, publicly perform, sublicense, and distribute the Work and such
67 | Derivative Works in Source or Object form.
68 |
69 | 3. Grant of Patent License.
70 |
71 | Subject to the terms and conditions of this License, each Contributor hereby
72 | grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
73 | irrevocable (except as stated in this section) patent license to make, have
74 | made, use, offer to sell, sell, import, and otherwise transfer the Work, where
75 | such license applies only to those patent claims licensable by such Contributor
76 | that are necessarily infringed by their Contribution(s) alone or by combination
77 | of their Contribution(s) with the Work to which such Contribution(s) was
78 | submitted. If You institute patent litigation against any entity (including a
79 | cross-claim or counterclaim in a lawsuit) alleging that the Work or a
80 | Contribution incorporated within the Work constitutes direct or contributory
81 | patent infringement, then any patent licenses granted to You under this License
82 | for that Work shall terminate as of the date such litigation is filed.
83 |
84 | 4. Redistribution.
85 |
86 | You may reproduce and distribute copies of the Work or Derivative Works thereof
87 | in any medium, with or without modifications, and in Source or Object form,
88 | provided that You meet the following conditions:
89 |
90 | You must give any other recipients of the Work or Derivative Works a copy of
91 | this License; and
92 | You must cause any modified files to carry prominent notices stating that You
93 | changed the files; and
94 | You must retain, in the Source form of any Derivative Works that You distribute,
95 | all copyright, patent, trademark, and attribution notices from the Source form
96 | of the Work, excluding those notices that do not pertain to any part of the
97 | Derivative Works; and
98 | If the Work includes a "NOTICE" text file as part of its distribution, then any
99 | Derivative Works that You distribute must include a readable copy of the
100 | attribution notices contained within such NOTICE file, excluding those notices
101 | that do not pertain to any part of the Derivative Works, in at least one of the
102 | following places: within a NOTICE text file distributed as part of the
103 | Derivative Works; within the Source form or documentation, if provided along
104 | with the Derivative Works; or, within a display generated by the Derivative
105 | Works, if and wherever such third-party notices normally appear. The contents of
106 | the NOTICE file are for informational purposes only and do not modify the
107 | License. You may add Your own attribution notices within Derivative Works that
108 | You distribute, alongside or as an addendum to the NOTICE text from the Work,
109 | provided that such additional attribution notices cannot be construed as
110 | modifying the License.
111 | You may add Your own copyright statement to Your modifications and may provide
112 | additional or different license terms and conditions for use, reproduction, or
113 | distribution of Your modifications, or for any such Derivative Works as a whole,
114 | provided Your use, reproduction, and distribution of the Work otherwise complies
115 | with the conditions stated in this License.
116 |
117 | 5. Submission of Contributions.
118 |
119 | Unless You explicitly state otherwise, any Contribution intentionally submitted
120 | for inclusion in the Work by You to the Licensor shall be under the terms and
121 | conditions of this License, without any additional terms or conditions.
122 | Notwithstanding the above, nothing herein shall supersede or modify the terms of
123 | any separate license agreement you may have executed with Licensor regarding
124 | such Contributions.
125 |
126 | 6. Trademarks.
127 |
128 | This License does not grant permission to use the trade names, trademarks,
129 | service marks, or product names of the Licensor, except as required for
130 | reasonable and customary use in describing the origin of the Work and
131 | reproducing the content of the NOTICE file.
132 |
133 | 7. Disclaimer of Warranty.
134 |
135 | Unless required by applicable law or agreed to in writing, Licensor provides the
136 | Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
137 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
138 | including, without limitation, any warranties or conditions of TITLE,
139 | NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
140 | solely responsible for determining the appropriateness of using or
141 | redistributing the Work and assume any risks associated with Your exercise of
142 | permissions under this License.
143 |
144 | 8. Limitation of Liability.
145 |
146 | In no event and under no legal theory, whether in tort (including negligence),
147 | contract, or otherwise, unless required by applicable law (such as deliberate
148 | and grossly negligent acts) or agreed to in writing, shall any Contributor be
149 | liable to You for damages, including any direct, indirect, special, incidental,
150 | or consequential damages of any character arising as a result of this License or
151 | out of the use or inability to use the Work (including but not limited to
152 | damages for loss of goodwill, work stoppage, computer failure or malfunction, or
153 | any and all other commercial damages or losses), even if such Contributor has
154 | been advised of the possibility of such damages.
155 |
156 | 9. Accepting Warranty or Additional Liability.
157 |
158 | While redistributing the Work or Derivative Works thereof, You may choose to
159 | offer, and charge a fee for, acceptance of support, warranty, indemnity, or
160 | other liability obligations and/or rights consistent with this License. However,
161 | in accepting such obligations, You may act only on Your own behalf and on Your
162 | sole responsibility, not on behalf of any other Contributor, and only if You
163 | agree to indemnify, defend, and hold each Contributor harmless for any liability
164 | incurred by, or claims asserted against, such Contributor by reason of your
165 | accepting any such warranty or additional liability.
166 |
167 | END OF TERMS AND CONDITIONS
168 |
169 | APPENDIX: How to apply the Apache License to your work
170 |
171 | To apply the Apache License to your work, attach the following boilerplate
172 | notice, with the fields enclosed by brackets "[]" replaced with your own
173 | identifying information. (Don't include the brackets!) The text should be
174 | enclosed in the appropriate comment syntax for the file format. We also
175 | recommend that a file or class name and description of purpose be included on
176 | the same "printed page" as the copyright notice for easier identification within
177 | third-party archives.
178 |
179 | Copyright [yyyy] [name of copyright owner]
180 |
181 | Licensed under the Apache License, Version 2.0 (the "License");
182 | you may not use this file except in compliance with the License.
183 | You may obtain a copy of the License at
184 |
185 | http://www.apache.org/licenses/LICENSE-2.0
186 |
187 | Unless required by applicable law or agreed to in writing, software
188 | distributed under the License is distributed on an "AS IS" BASIS,
189 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190 | See the License for the specific language governing permissions and
191 | limitations under the License.
192 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | angularjs-cart
2 | ==============
3 |
4 | AngularJS Shopping Cart forked from [Bernado Castilho's sample
5 | on Code Project](http://www.codeproject.com/Articles/576246/A-Shopping-Cart-Application-Built-with-AngularJS) so I could add
6 | Stripe.js support to it.
7 |
8 | Changes
9 | -------
10 | * Switched to Visual Studio 2012
11 | * Added support for Stripe.js
12 |
13 | Blogged about the [changes needed for Stripe support](http://www.keysolutions.com/blogs/kenyee.nsf/d6plinks/KKYE-993K3H).
14 |
15 | Usage
16 | -----
17 | Update app.js with your Paypal/Google/Stripe tokens/IDs to use this in your application.
18 |
19 | For Stripe.js, change the chargeurl parameter so it points to a form processing handler on your web site that [commits the charge](https://stripe.com/docs/tutorials/charges). Stripe is different than Paypal/Google in that it's a two-step process that's similar to an OAuth login.
20 |
21 |
--------------------------------------------------------------------------------
/ShoppingCart.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShoppingCart", "ShoppingCart\ShoppingCart.csproj", "{B26E8218-C412-429E-8C7A-DD50D99CAEFF}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Any CPU = Debug|Any CPU
9 | Release|Any CPU = Release|Any CPU
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {B26E8218-C412-429E-8C7A-DD50D99CAEFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13 | {B26E8218-C412-429E-8C7A-DD50D99CAEFF}.Debug|Any CPU.Build.0 = Debug|Any CPU
14 | {B26E8218-C412-429E-8C7A-DD50D99CAEFF}.Release|Any CPU.ActiveCfg = Release|Any CPU
15 | {B26E8218-C412-429E-8C7A-DD50D99CAEFF}.Release|Any CPU.Build.0 = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/ShoppingCart/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ShoppingCart")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ShoppingCart")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("af0fdacb-0bd4-44a6-8924-c3d6caebddee")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/ShoppingCart/ShoppingCart.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 |
8 |
9 | 2.0
10 | {B26E8218-C412-429E-8C7A-DD50D99CAEFF}
11 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
12 | Library
13 | Properties
14 | ShoppingCart
15 | ShoppingCart
16 | v4.0
17 | false
18 |
19 |
20 |
21 |
22 | 4.0
23 |
24 |
25 | true
26 | full
27 | false
28 | bin\
29 | DEBUG;TRACE
30 | prompt
31 | 4
32 |
33 |
34 | pdbonly
35 | true
36 | bin\
37 | TRACE
38 | prompt
39 | 4
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 | readme.txt
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 | Web.config
103 |
104 |
105 | Web.config
106 |
107 |
108 |
109 |
110 |
111 |
112 | 10.0
113 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 | False
123 | False
124 | 1234
125 | /
126 |
127 |
128 | False
129 | False
130 |
131 |
132 | False
133 |
134 |
135 |
136 |
137 |
144 |
--------------------------------------------------------------------------------
/ShoppingCart/Web.Debug.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/ShoppingCart/Web.Release.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
30 |
31 |
--------------------------------------------------------------------------------
/ShoppingCart/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ShoppingCart/bin/ShoppingCart.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/bin/ShoppingCart.dll
--------------------------------------------------------------------------------
/ShoppingCart/bin/ShoppingCart.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/bin/ShoppingCart.pdb
--------------------------------------------------------------------------------
/ShoppingCart/css/style.css:
--------------------------------------------------------------------------------
1 | /*!
2 | * Extend Bootstrap v2.3.1 to provide cell alignment (doh)
3 | *
4 | */
5 | .table td.tdRight {
6 | text-align: right;
7 | }
8 | .table td.tdCenter {
9 | text-align: center;
10 | }
11 | .table-nonfluid {
12 | width: auto;
13 | }
--------------------------------------------------------------------------------
/ShoppingCart/default.htm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Shopping Cart with AngularJS
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | Angular Store
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/ShoppingCart/img/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/img/logo.png
--------------------------------------------------------------------------------
/ShoppingCart/img/products/APL.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/img/products/APL.jpg
--------------------------------------------------------------------------------
/ShoppingCart/img/products/AVC.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/img/products/AVC.jpg
--------------------------------------------------------------------------------
/ShoppingCart/img/products/BAN.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/img/products/BAN.jpg
--------------------------------------------------------------------------------
/ShoppingCart/img/products/CTP.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/img/products/CTP.jpg
--------------------------------------------------------------------------------
/ShoppingCart/img/products/FIG.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/img/products/FIG.jpg
--------------------------------------------------------------------------------
/ShoppingCart/img/products/GRF.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/img/products/GRF.jpg
--------------------------------------------------------------------------------
/ShoppingCart/img/products/GRP.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/img/products/GRP.jpg
--------------------------------------------------------------------------------
/ShoppingCart/img/products/GUA.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/img/products/GUA.jpg
--------------------------------------------------------------------------------
/ShoppingCart/img/products/KIW.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/img/products/KIW.jpg
--------------------------------------------------------------------------------
/ShoppingCart/img/products/LYC.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/img/products/LYC.jpg
--------------------------------------------------------------------------------
/ShoppingCart/img/products/MAN.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/img/products/MAN.jpg
--------------------------------------------------------------------------------
/ShoppingCart/img/products/ORG.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/img/products/ORG.jpg
--------------------------------------------------------------------------------
/ShoppingCart/img/products/PAP.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/img/products/PAP.jpg
--------------------------------------------------------------------------------
/ShoppingCart/img/products/PCH.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/img/products/PCH.jpg
--------------------------------------------------------------------------------
/ShoppingCart/img/products/PER.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/img/products/PER.jpg
--------------------------------------------------------------------------------
/ShoppingCart/img/products/PMG.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/img/products/PMG.jpg
--------------------------------------------------------------------------------
/ShoppingCart/img/products/PNP.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/img/products/PNP.jpg
--------------------------------------------------------------------------------
/ShoppingCart/img/products/PSM.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/img/products/PSM.jpg
--------------------------------------------------------------------------------
/ShoppingCart/img/products/STR.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/img/products/STR.jpg
--------------------------------------------------------------------------------
/ShoppingCart/img/products/TNG.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/img/products/TNG.jpg
--------------------------------------------------------------------------------
/ShoppingCart/img/products/WML.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/img/products/WML.jpg
--------------------------------------------------------------------------------
/ShoppingCart/img/r0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/img/r0.png
--------------------------------------------------------------------------------
/ShoppingCart/img/r1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/img/r1.png
--------------------------------------------------------------------------------
/ShoppingCart/img/r2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/img/r2.png
--------------------------------------------------------------------------------
/ShoppingCart/img/r3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/img/r3.png
--------------------------------------------------------------------------------
/ShoppingCart/img/r4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kenyee/angularjs-cart/54ac4147a56dea4e1a72fffebeb8eb52eb96493c/ShoppingCart/img/r4.png
--------------------------------------------------------------------------------
/ShoppingCart/js/app.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | // App Module: the name AngularStore matches the ng-app attribute in the main tag
4 | // the route provides parses the URL and injects the appropriate partial page
5 | var storeApp = angular.module('AngularStore', []).
6 | config(['$routeProvider', function($routeProvider) {
7 | $routeProvider.
8 | when('/store', {
9 | templateUrl: 'partials/store.htm',
10 | controller: storeController
11 | }).
12 | when('/products/:productSku', {
13 | templateUrl: 'partials/product.htm',
14 | controller: storeController
15 | }).
16 | when('/cart', {
17 | templateUrl: 'partials/shoppingCart.htm',
18 | controller: storeController
19 | }).
20 | otherwise({
21 | redirectTo: '/store'
22 | });
23 | }]);
24 |
25 | // create a data service that provides a store and a shopping cart that
26 | // will be shared by all views (instead of creating fresh ones for each view).
27 | storeApp.factory("DataService", function () {
28 |
29 | // create store
30 | var myStore = new store();
31 |
32 | // create shopping cart
33 | var myCart = new shoppingCart("AngularStore");
34 |
35 | // enable PayPal checkout
36 | // note: the second parameter identifies the merchant; in order to use the
37 | // shopping cart with PayPal, you have to create a merchant account with
38 | // PayPal. You can do that here:
39 | // https://www.paypal.com/webapps/mpp/merchant
40 | myCart.addCheckoutParameters("PayPal", "paypaluser@youremail.com");
41 |
42 | // enable Google Wallet checkout
43 | // note: the second parameter identifies the merchant; in order to use the
44 | // shopping cart with Google Wallet, you have to create a merchant account with
45 | // Google. You can do that here:
46 | // https://developers.google.com/commerce/wallet/digital/training/getting-started/merchant-setup
47 | myCart.addCheckoutParameters("Google", "xxxxxxx",
48 | {
49 | ship_method_name_1: "UPS Next Day Air",
50 | ship_method_price_1: "20.00",
51 | ship_method_currency_1: "USD",
52 | ship_method_name_2: "UPS Ground",
53 | ship_method_price_2: "15.00",
54 | ship_method_currency_2: "USD"
55 | }
56 | );
57 |
58 | // enable Stripe checkout
59 | // note: the second parameter identifies your publishable key; in order to use the
60 | // shopping cart with Stripe, you have to create a merchant account with
61 | // Stripe. You can do that here:
62 | // https://manage.stripe.com/register
63 | myCart.addCheckoutParameters("Stripe", "pk_test_xxxx",
64 | {
65 | chargeurl: "https://localhost:1234/processStripe.aspx"
66 | }
67 | );
68 |
69 | // return data object with store and cart
70 | return {
71 | store: myStore,
72 | cart: myCart
73 | };
74 | });
--------------------------------------------------------------------------------
/ShoppingCart/js/controller.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | // the storeController contains two objects:
4 | // - store: contains the product list
5 | // - cart: the shopping cart object
6 | function storeController($scope, $routeParams, DataService) {
7 |
8 | // get store and cart from service
9 | $scope.store = DataService.store;
10 | $scope.cart = DataService.cart;
11 |
12 | // use routing to pick the selected product
13 | if ($routeParams.productSku != null) {
14 | $scope.product = $scope.store.getProduct($routeParams.productSku);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/ShoppingCart/js/product.js:
--------------------------------------------------------------------------------
1 | //----------------------------------------------------------------
2 | // product class
3 | function product(sku, name, description, price, cal, carot, vitc, folate, potassium, fiber) {
4 | this.sku = sku; // product code (SKU = stock keeping unit)
5 | this.name = name;
6 | this.description = description;
7 | this.price = price;
8 | this.cal = cal;
9 | this.nutrients = {
10 | "Carotenoid": carot,
11 | "Vitamin C": vitc,
12 | "Folates": folate,
13 | "Potassium": potassium,
14 | "Fiber": fiber
15 | };
16 | }
17 |
--------------------------------------------------------------------------------
/ShoppingCart/js/shoppingCart.js:
--------------------------------------------------------------------------------
1 | //----------------------------------------------------------------
2 | // shopping cart
3 | //
4 | function shoppingCart(cartName) {
5 | this.cartName = cartName;
6 | this.clearCart = false;
7 | this.checkoutParameters = {};
8 | this.items = [];
9 |
10 | // load items from local storage when initializing
11 | this.loadItems();
12 |
13 | // save items to local storage when unloading
14 | var self = this;
15 | $(window).unload(function () {
16 | if (self.clearCart) {
17 | self.clearItems();
18 | }
19 | self.saveItems();
20 | self.clearCart = false;
21 | });
22 | }
23 |
24 | // load items from local storage
25 | shoppingCart.prototype.loadItems = function () {
26 | var items = localStorage != null ? localStorage[this.cartName + "_items"] : null;
27 | if (items != null && JSON != null) {
28 | try {
29 | var items = JSON.parse(items);
30 | for (var i = 0; i < items.length; i++) {
31 | var item = items[i];
32 | if (item.sku != null && item.name != null && item.price != null && item.quantity != null) {
33 | item = new cartItem(item.sku, item.name, item.price, item.quantity);
34 | this.items.push(item);
35 | }
36 | }
37 | }
38 | catch (err) {
39 | // ignore errors while loading...
40 | }
41 | }
42 | }
43 |
44 | // save items to local storage
45 | shoppingCart.prototype.saveItems = function () {
46 | if (localStorage != null && JSON != null) {
47 | localStorage[this.cartName + "_items"] = JSON.stringify(this.items);
48 | }
49 | }
50 |
51 | // adds an item to the cart
52 | shoppingCart.prototype.addItem = function (sku, name, price, quantity) {
53 | quantity = this.toNumber(quantity);
54 | if (quantity != 0) {
55 |
56 | // update quantity for existing item
57 | var found = false;
58 | for (var i = 0; i < this.items.length && !found; i++) {
59 | var item = this.items[i];
60 | if (item.sku == sku) {
61 | found = true;
62 | item.quantity = this.toNumber(item.quantity + quantity);
63 | if (item.quantity <= 0) {
64 | this.items.splice(i, 1);
65 | }
66 | }
67 | }
68 |
69 | // new item, add now
70 | if (!found) {
71 | var item = new cartItem(sku, name, price, quantity);
72 | this.items.push(item);
73 | }
74 |
75 | // save changes
76 | this.saveItems();
77 | }
78 | }
79 |
80 | // get the total price for all items currently in the cart
81 | shoppingCart.prototype.getTotalPrice = function (sku) {
82 | var total = 0;
83 | for (var i = 0; i < this.items.length; i++) {
84 | var item = this.items[i];
85 | if (sku == null || item.sku == sku) {
86 | total += this.toNumber(item.quantity * item.price);
87 | }
88 | }
89 | return total;
90 | }
91 |
92 | // get the total price for all items currently in the cart
93 | shoppingCart.prototype.getTotalCount = function (sku) {
94 | var count = 0;
95 | for (var i = 0; i < this.items.length; i++) {
96 | var item = this.items[i];
97 | if (sku == null || item.sku == sku) {
98 | count += this.toNumber(item.quantity);
99 | }
100 | }
101 | return count;
102 | }
103 |
104 | // clear the cart
105 | shoppingCart.prototype.clearItems = function () {
106 | this.items = [];
107 | this.saveItems();
108 | }
109 |
110 | // define checkout parameters
111 | shoppingCart.prototype.addCheckoutParameters = function (serviceName, merchantID, options) {
112 |
113 | // check parameters
114 | if (serviceName != "PayPal" && serviceName != "Google" && serviceName != "Stripe") {
115 | throw "serviceName must be 'PayPal' or 'Google' or 'Stripe'.";
116 | }
117 | if (merchantID == null) {
118 | throw "A merchantID is required in order to checkout.";
119 | }
120 |
121 | // save parameters
122 | this.checkoutParameters[serviceName] = new checkoutParameters(serviceName, merchantID, options);
123 | }
124 |
125 | // check out
126 | shoppingCart.prototype.checkout = function (serviceName, clearCart) {
127 |
128 | // select serviceName if we have to
129 | if (serviceName == null) {
130 | var p = this.checkoutParameters[Object.keys(this.checkoutParameters)[0]];
131 | serviceName = p.serviceName;
132 | }
133 |
134 | // sanity
135 | if (serviceName == null) {
136 | throw "Use the 'addCheckoutParameters' method to define at least one checkout service.";
137 | }
138 |
139 | // go to work
140 | var parms = this.checkoutParameters[serviceName];
141 | if (parms == null) {
142 | throw "Cannot get checkout parameters for '" + serviceName + "'.";
143 | }
144 | switch (parms.serviceName) {
145 | case "PayPal":
146 | this.checkoutPayPal(parms, clearCart);
147 | break;
148 | case "Google":
149 | this.checkoutGoogle(parms, clearCart);
150 | break;
151 | case "Stripe":
152 | this.checkoutStripe(parms, clearCart);
153 | break;
154 | default:
155 | throw "Unknown checkout service: " + parms.serviceName;
156 | }
157 | }
158 |
159 | // check out using PayPal
160 | // for details see:
161 | // www.paypal.com/cgi-bin/webscr?cmd=p/pdn/howto_checkout-outside
162 | shoppingCart.prototype.checkoutPayPal = function (parms, clearCart) {
163 |
164 | // global data
165 | var data = {
166 | cmd: "_cart",
167 | business: parms.merchantID,
168 | upload: "1",
169 | rm: "2",
170 | charset: "utf-8"
171 | };
172 |
173 | // item data
174 | for (var i = 0; i < this.items.length; i++) {
175 | var item = this.items[i];
176 | var ctr = i + 1;
177 | data["item_number_" + ctr] = item.sku;
178 | data["item_name_" + ctr] = item.name;
179 | data["quantity_" + ctr] = item.quantity;
180 | data["amount_" + ctr] = item.price.toFixed(2);
181 | }
182 |
183 | // build form
184 | var form = $('');
185 | form.attr("action", "https://www.paypal.com/cgi-bin/webscr");
186 | form.attr("method", "POST");
187 | form.attr("style", "display:none;");
188 | this.addFormFields(form, data);
189 | this.addFormFields(form, parms.options);
190 | $("body").append(form);
191 |
192 | // submit form
193 | this.clearCart = clearCart == null || clearCart;
194 | form.submit();
195 | form.remove();
196 | }
197 |
198 | // check out using Google Wallet
199 | // for details see:
200 | // developers.google.com/checkout/developer/Google_Checkout_Custom_Cart_How_To_HTML
201 | // developers.google.com/checkout/developer/interactive_demo
202 | shoppingCart.prototype.checkoutGoogle = function (parms, clearCart) {
203 |
204 | // global data
205 | var data = {};
206 |
207 | // item data
208 | for (var i = 0; i < this.items.length; i++) {
209 | var item = this.items[i];
210 | var ctr = i + 1;
211 | data["item_name_" + ctr] = item.sku;
212 | data["item_description_" + ctr] = item.name;
213 | data["item_price_" + ctr] = item.price.toFixed(2);
214 | data["item_quantity_" + ctr] = item.quantity;
215 | data["item_merchant_id_" + ctr] = parms.merchantID;
216 | }
217 |
218 | // build form
219 | var form = $('');
220 | // NOTE: in production projects, use the checkout.google url below;
221 | // for debugging/testing, use the sandbox.google url instead.
222 | //form.attr("action", "https://checkout.google.com/api/checkout/v2/merchantCheckoutForm/Merchant/" + parms.merchantID);
223 | form.attr("action", "https://sandbox.google.com/checkout/api/checkout/v2/checkoutForm/Merchant/" + parms.merchantID);
224 | form.attr("method", "POST");
225 | form.attr("style", "display:none;");
226 | this.addFormFields(form, data);
227 | this.addFormFields(form, parms.options);
228 | $("body").append(form);
229 |
230 | // submit form
231 | this.clearCart = clearCart == null || clearCart;
232 | form.submit();
233 | form.remove();
234 | }
235 |
236 | // check out using Stripe
237 | // for details see:
238 | // https://stripe.com/docs/checkout
239 | shoppingCart.prototype.checkoutStripe = function (parms, clearCart) {
240 |
241 | // global data
242 | var data = {};
243 |
244 | // item data
245 | for (var i = 0; i < this.items.length; i++) {
246 | var item = this.items[i];
247 | var ctr = i + 1;
248 | data["item_name_" + ctr] = item.sku;
249 | data["item_description_" + ctr] = item.name;
250 | data["item_price_" + ctr] = item.price.toFixed(2);
251 | data["item_quantity_" + ctr] = item.quantity;
252 | }
253 |
254 | // build form
255 | var form = $('.form-stripe');
256 | form.empty();
257 | // NOTE: in production projects, you have to handle the post with a few simple calls to the Stripe API.
258 | // See https://stripe.com/docs/checkout
259 | // You'll get a POST to the address below w/ a stripeToken.
260 | // First, you have to initialize the Stripe API w/ your public/private keys.
261 | // You then call Customer.create() w/ the stripeToken and your email address.
262 | // Then you call Charge.create() w/ the customer ID from the previous call and your charge amount.
263 | form.attr("action", parms.options['chargeurl']);
264 | form.attr("method", "POST");
265 | form.attr("style", "display:none;");
266 | this.addFormFields(form, data);
267 | this.addFormFields(form, parms.options);
268 | $("body").append(form);
269 |
270 | // ajaxify form
271 | form.ajaxForm({
272 | success: function () {
273 | $.unblockUI();
274 | alert('Thanks for your order!');
275 | },
276 | error: function (result) {
277 | $.unblockUI();
278 | alert('Error submitting order: ' + result.statusText);
279 | }
280 | });
281 |
282 | var token = function (res) {
283 | var $input = $(' ').val(res.id);
284 |
285 | // show processing message and block UI until form is submitted and returns
286 | $.blockUI({ message: 'Processing order...' });
287 |
288 | // submit form
289 | form.append($input).submit();
290 | this.clearCart = clearCart == null || clearCart;
291 | form.submit();
292 | };
293 |
294 | StripeCheckout.open({
295 | key: parms.merchantID,
296 | address: false,
297 | amount: this.getTotalPrice() *100, /** expects an integer **/
298 | currency: 'usd',
299 | name: 'Purchase',
300 | description: 'Description',
301 | panelLabel: 'Checkout',
302 | token: token
303 | });
304 | }
305 |
306 | // utility methods
307 | shoppingCart.prototype.addFormFields = function (form, data) {
308 | if (data != null) {
309 | $.each(data, function (name, value) {
310 | if (value != null) {
311 | var input = $(" ").attr("type", "hidden").attr("name", name).val(value);
312 | form.append(input);
313 | }
314 | });
315 | }
316 | }
317 | shoppingCart.prototype.toNumber = function (value) {
318 | value = value * 1;
319 | return isNaN(value) ? 0 : value;
320 | }
321 |
322 | //----------------------------------------------------------------
323 | // checkout parameters (one per supported payment service)
324 | //
325 | function checkoutParameters(serviceName, merchantID, options) {
326 | this.serviceName = serviceName;
327 | this.merchantID = merchantID;
328 | this.options = options;
329 | }
330 |
331 | //----------------------------------------------------------------
332 | // items in the cart
333 | //
334 | function cartItem(sku, name, price, quantity) {
335 | this.sku = sku;
336 | this.name = name;
337 | this.price = price * 1;
338 | this.quantity = quantity * 1;
339 | }
340 |
341 |
--------------------------------------------------------------------------------
/ShoppingCart/js/store.js:
--------------------------------------------------------------------------------
1 | //----------------------------------------------------------------
2 | // store (contains the products)
3 | //
4 | // NOTE: nutritional info from http://www.cspinet.org/images/fruitcha.jpg
5 | // score legend:
6 | // 0: below 5% of daily value (DV)
7 | // 1: 5-10% DV
8 | // 2: 10-20% DV
9 | // 3: 20-40% DV
10 | // 4: above 40% DV
11 | //
12 | function store() {
13 | this.products = [
14 | new product("APL", "Apple", "Eat one every day to keep the doctor away!", 12, 90, 0, 2, 0, 1, 2),
15 | new product("AVC", "Avocado", "Guacamole anyone?", 16, 90, 0, 1, 1, 1, 2),
16 | new product("BAN", "Banana", "These are rich in Potassium and easy to peel.", 4, 120, 0, 2, 1, 2, 2),
17 | new product("CTP", "Cantaloupe", "Delicious and refreshing.", 3, 50, 4, 4, 1, 2, 0),
18 | new product("FIG", "Fig", "OK, not that nutritious, but sooo good!", 10, 100, 0, 0, 0, 1, 2),
19 | new product("GRF", "Grapefruit", "Pink or red, always healthy and delicious.", 11, 50, 4, 4, 1, 1, 1),
20 | new product("GRP", "Grape", "Wine is great, but grapes are even better.", 8, 100, 0, 3, 0, 1, 1),
21 | new product("GUA", "Guava", "Exotic, fragrant, tasty!", 8, 50, 4, 4, 0, 1, 2),
22 | new product("KIW", "Kiwi", "These come from New Zealand.", 14, 90, 1, 4, 0, 2, 2),
23 | new product("LYC", "Lychee", "Unusual and highly addictive!", 18, 125, 1, 4, 0, 2, 2),
24 | new product("MAN", "Mango", "Messy to eat, but well worth it.", 8, 70, 3, 4, 0, 1, 1),
25 | new product("ORG", "Orange", "Vitamin C anyone? Go ahead, make some juice.", 9, 70, 1, 4, 2, 1, 2),
26 | new product("PAP", "Papaya", "Super-popular for breakfast.", 5, 60, 3, 4, 2, 2, 2),
27 | new product("PCH", "Peach", "Add some cream and enjoy.", 19, 70, 1, 2, 0, 1, 2),
28 | new product("PER", "Pear", "Delicious fresh, or cooked in red wine, or distilled.", 8, 100, 0, 2, 0, 1, 2),
29 | new product("PMG", "Pomegranate", "Delicious, healthy, beautiful, and sophisticated!", 19, 110, 0, 2, 0, 2, 0),
30 | new product("PNP", "Pineapple", "Enjoy it (but don't forget to peel first).", 4, 60, 0, 3, 0, 0, 1),
31 | new product("PSM", "Persimmon", "Believe it or not, they are berries!", 6, 120, 4, 3, 0, 1, 3),
32 | new product("STR", "Strawberry", "Beautiful, healthy, and delicious.", 7, 40, 0, 4, 1, 1, 2),
33 | new product("TNG", "Tangerine", "Easier to peel than oranges!", 8, 50, 3, 4, 1, 1, 2),
34 | new product("WML", "Watermelon", "Nothing comes close on those hot summer days.", 4, 90, 4, 4, 0, 1, 1)
35 | ];
36 | this.dvaCaption = [
37 | "Negligible",
38 | "Low",
39 | "Average",
40 | "Good",
41 | "Great"
42 | ];
43 | this.dvaRange = [
44 | "below 5%",
45 | "between 5 and 10%",
46 | "between 10 and 20%",
47 | "between 20 and 40%",
48 | "above 40%"
49 | ];
50 | }
51 | store.prototype.getProduct = function (sku) {
52 | for (var i = 0; i < this.products.length; i++) {
53 | if (this.products[i].sku == sku)
54 | return this.products[i];
55 | }
56 | return null;
57 | }
58 |
--------------------------------------------------------------------------------
/ShoppingCart/partials/product.htm:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{product.name}}: {{product.description}}
4 |
5 |
6 |
7 |
8 |
50 |
51 |
52 |
53 |
56 | add to cart
57 |
58 |
62 | remove from cart
63 |
64 |
67 | back to store
68 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/ShoppingCart/partials/shoppingCart.htm:
--------------------------------------------------------------------------------
1 |
2 | Thanks for shopping at the Angular Store.
3 | This is your shopping cart. Here you can edit the items,
4 | go back to the store, clear the cart, or check out.
5 |
6 |
7 |
8 |
9 |
66 |
67 |
68 |
69 |
70 |
73 | back to store
74 |
75 |
79 | clear cart
80 |
81 |
82 |
83 |
84 |
85 |
86 |
90 | check out using PayPal
91 |
92 |
96 | check out using Google
97 |
98 |
102 | check out using Stripe
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
115 |
116 |
117 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
--------------------------------------------------------------------------------
/ShoppingCart/partials/store.htm:
--------------------------------------------------------------------------------
1 |
2 | Welcome to the Angular Store.
3 | Please select the products you want and add them to your shopping cart.
4 | When you are done, click the shopping cart icon to review your order and check out.
5 |
6 |
7 |
8 | Search:
9 |
10 |
11 |
44 |
--------------------------------------------------------------------------------