Skip to content

Commit d20bf8e

Browse files
yulia-dnistrianpetro97Shaun Maharaj
authored
MT-2843 checkout flow (#59)
* Add Cart modal. Added "Add to cart" button * Add cartItemList component * Add Checkout button * Added Shipping address form * Added Billing address form to the checkout flow * Revert Readme file * add promotions form * add remove and update quantity function * Added Payment form * update sidebar style * Updated @moltin/sdk version * Added payment flow * Related customerId to checkout request. Set customerId as cartId * add total price on cart tab * Added updating purchase history after the order complete. Added email validation * Added the message of completed purchase * display addresses for logged user * Fixed small issues * fix responsive style * update cart button message * Added Cart Identifier on logout customer * Fixed small issues * update address form * Remove Continue button for billing address form. Replace set "mcart" to logout function * Remove shopkitSrc * - update README * Removed @moltin/request. Added random generate CartId * update address selection * update login flow * Updated closing modal function * Updated titles for billing and shipping address * Capital the first letter for address name * update payment validation * Fixed console error * update validation * remove comment Co-authored-by: Petro Dubno <petro.dubno@gmail.com> Co-authored-by: Shaun Maharaj <Shaun.Maharaj@elasticpath.com>
1 parent d6720ec commit d20bf8e

32 files changed

+1834
-67
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
The Elastic Path Commerce Cloud REACT PWA Reference Storefront is a flexible e-commerce website built on Elastic Path’s RESTful e-commerce API. The storefront uses the e-commerce capabilities provided by Elastic Path Commerce Cloud and gets data in a RESTful manner.
1616

17-
The storefront uses the [Elastic Path Commerce Cloud JavaScript SDK](https://github.com/moltin/js-sdk) for all Elastic Path Commerce Cloud API requests. For the cart and checkout experiences, the storefront uses [Elastic Path Commerce Cloud Embeddable Cart + Checkout](https://github.com/moltin/shopkit).
17+
The storefront uses the [Elastic Path Commerce Cloud JavaScript SDK](https://github.com/moltin/js-sdk) for all Elastic Path Commerce Cloud API requests.
1818

1919
You can try out a [live instance of the Reference Storefront](https://epcc-reference.elasticpath.com/).
2020

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
"version": "1.1.0",
44
"private": true,
55
"dependencies": {
6-
"@moltin/sdk": "^4.0.1",
6+
"@moltin/sdk": "^4.0.2",
77
"@types/node": "^12.0.0",
88
"@types/react": "^16.9.0",
99
"@types/react-dom": "^16.9.0",
1010
"@types/react-instantsearch-dom": "^6.3.0",
1111
"@types/react-router-dom": "^5.1.5",
12+
"algolia-places-react": "^1.6.0",
1213
"algoliasearch": "^4.3.0",
1314
"app-localizer": "^1.2.2",
1415
"constate": "^2.0.0",
@@ -26,6 +27,7 @@
2627
"react-router-dom": "^5.2.0",
2728
"react-script-hook": "^1.1.1",
2829
"react-scripts": "3.4.1",
30+
"react-stripe-elements": "^6.1.2",
2931
"serve": "^11.3.1",
3032
"sharethis-reactjs": "^1.5.0",
3133
"typescript": "^3.7.3",

public/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@
3333
s.parentNode.insertBefore(wf, s);
3434
})(document);
3535
</script>
36+
<script src="https://js.stripe.com/v3/"></script>
3637
</body>
3738
</html>

src/AccountDropdown.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

2-
import React, { useState} from 'react';
3-
import {Link, useHistory} from 'react-router-dom';
2+
import React, { useState } from 'react';
3+
import { Link, useHistory } from 'react-router-dom';
44
import useOnclickOutside from 'react-cool-onclickoutside';
5-
import {useCustomerData, useTranslation} from './app-state';
5+
import { useCustomerData, useTranslation } from './app-state';
66
import { createAccountUrl } from './routes';
77
import { LoginDialog } from './LoginDialog';
88
import { ReactComponent as AccountIcon } from './images/icons/ic_account.svg';
@@ -31,7 +31,14 @@ export const AccountDropdown: React.FC = (props) => {
3131
setIsOpen(false);
3232
});
3333

34+
const createCartIdentifier = () => {
35+
return 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'.replace(/[x]/g, () =>
36+
((Math.random() * 16) | 0).toString(16)
37+
)
38+
};
39+
3440
const logout = () => {
41+
localStorage.setItem('mcart', createCartIdentifier());
3542
clearCustomerData();
3643
history.push('/');
3744
};

src/AddressFields.scss

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
2+
@import './theme/common';
3+
4+
.address {
5+
&__main {
6+
margin-bottom: 20px;
7+
}
8+
9+
&__addressbutton {
10+
margin-top: 10px;
11+
text-decoration: underline;
12+
13+
&:hover {
14+
cursor: pointer;
15+
color: #0099DE;
16+
}
17+
}
18+
19+
&__field {
20+
display: flex;
21+
flex-wrap: wrap;
22+
margin-bottom: 10px;
23+
}
24+
25+
&.--styledinput {
26+
width: 50%;
27+
padding: 0 12px;
28+
}
29+
30+
.--addspace {
31+
margin-left: -0.75rem;
32+
margin-right: -0.75rem;
33+
}
34+
35+
.epform {
36+
&__label {
37+
text-transform: none;
38+
}
39+
40+
&__input {
41+
height: 40px;
42+
}
43+
}
44+
45+
.epform {
46+
&__error {
47+
position: unset;
48+
}
49+
}
50+
51+
&__wrap {
52+
display: flex;
53+
flex-wrap: wrap;
54+
padding-top: 20px;
55+
border-top: 1px solid $firstBorderColor;
56+
border-bottom: 1px solid $firstBorderColor;
57+
margin-top: 15px;
58+
margin-bottom: 15px;
59+
60+
.address__container {
61+
display: flex;
62+
}
63+
64+
.address__list {
65+
padding: 0;
66+
}
67+
}
68+
}
69+
70+

0 commit comments

Comments
 (0)