Hello, after a few requests, I will show you how to go from this
Home -> Login -> Registration -> My account -> Register an address -> Stores
to this
Home -> Registration -> Stores
Watch the result on my demonstration video
BEFORE YOU START: Back up your database
LIMITATION OF THIS CODE: We will pre-register a default address for future users, they will be able to place an order with this address if they do not change it.
Let's start by defining the location you want to use for the default address. Go to this site and enter an address. Then set aside the LATITUDE and LONGITUDE we will need them later.
Now:
- Log in to cPanel
- Access the PhpMyAdmin Panel
- Select your Database
- Click on "SQL"
Add this code inside and modify YOUR LATITUDE and YOUR LONGITUDE by your numbers obtained previously
INSERT INTO addresses
(id
, user_id
, address
, house
, landmark
, tag
, created_at
, updated_at
, latitude
, longitude
) VALUES
(NULL, '1', '⚠ Register your first delivery address here ↗', NULL, NULL, NULL, NULL, NULL, 'YOUR LONGITUDE', 'YOUR LATITUDE');
If the operation was successful, click on your database and go to "addresses". Go to the last page and remember the ID of the address we just created.
For example in my case it is number 4385. Click again on your database and go to "SQL".
Add this code inside and modify YOUR NUMBER ID
ALTER TABLE users
CHANGE default_address_id
default_address_id
INT(11) NULL DEFAULT 'YOUR NUMBER ID';
If the operation was successful, you have completed the first part of this tutorial. We have created a default address and assign this address to all new users.
This operation does not need to be repeated for future updates.
If you want to go back, DO NOT DELETE anything. Go back to "SQL" and add this code:
ALTER TABLE users
CHANGE default_address_id
default_address_id
INT(11) NULL DEFAULT '0';
Now new users will no longer have a default address and will have to create one.
Let's start part two (regular license). We will change the links to get to the store page faster. I am on version 2.9.1 the location of the files will be different on other versions.
Go to static/js/main.a36d52c2.chunk.js (Home page)
At line 2378 paste this code between },
and g.a.createElement("div", {
localStorage.getItem("loginDontHaveAccount"), " ", g.a.createElement(b.a, {
to: "/register",
style: {
color: localStorage.getItem("storeColor")
},
className: "auth-reg-link"
}, localStorage.getItem("firstScreenRegisterBtn"))), this.props.languages && this.props.languages.length > 1 && g.a.createElement("div", {
className: "mt-4 d-flex align-items-center justify-content-center mb-100"
},
Go to static/js/12.b1b14cf7.chunk.js (Login page)
Search /my-account
and replaces with /stores
(2x)
Go to static/js/13.147e71a1.chunk.js (Registration page)
Search /my-account
and replaces with /stores
Done, o go even faster I recommend you to activate the connection by OTP
Now, make sure you clear your cache and normally everything should be fine for you. 🙂