feat: add address element for shipping and billing address
Type of Change
- [ ] Bugfix
- [x] New feature
- [ ] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD
Description
I have added address elements for shipping and billing addresses.
Two new elements have been created: ShippingAddressElement and BillingAddressElement.
These elements include a method called getAddress, which is used to fetch the entered details.
By default, all fields are required, but optional fields can also be specified.
Option Supported:
Full name: full_name
Address Line 1: line1
Address Line 2: line2
City: city
State: state
Country: country
Postal Code: postal_code
Phone Number: phone
Email: email
How did you test it?
Clone the repo and then set script src to http://localhost:9050/HyperLoader.js in index.html and the widget name as shippingAddressElement or billingAddressElement in script.js. To make any field optional we need to feed list in the options
const unifiedCheckoutOptions = {
optional: ["phone", "email", "city", "full_name"],
};
const unifiedCheckout = widgets.create(
"shippingAddressElement",
unifiedCheckoutOptions
);
Checklist
- [ ] I ran
npm run re:build - [ ] I reviewed submitted code
- [ ] I added unit tests for my changes where possible
Closing this PR for address element for now. Will open this when needed.
@aritro2002 for reference