Post by seanstorm100 » Sun Dec 01, 2019 12:29 pm

Hello Team - I was wondering, any idea of how to get this greeting Javascript to print out the time of day messages at the top of OC my Account page?
For example, its 2 PM and you log it, and go to your account for some reason, you would be greeted with Good afternoon...
OCv3, Clean Install, Default Theme. Thank you for the continued support!

JS:

Code: Select all

var thehours = new Date().getHours();
	var themessage;
	var morning = ('Good morning');
	var afternoon = ('Good afternoon');
	var evening = ('Good evening');

	if (thehours >= 0 && thehours < 12) {
		themessage = morning; 

	} else if (thehours >= 12 && thehours < 17) {
		themessage = afternoon;

	} else if (thehours >= 17 && thehours < 24) {
		themessage = evening;
	}

	$('.greeting').append(themessage);
	
HTML

Code: Select all

<body>

<div class="greeting"></div>

  <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script><script  src="./script.js"></script>

</body>

Regards,
Sean


New member

Posts

Joined
Tue Nov 05, 2019 11:08 pm

Post by opencartmart » Sun Dec 01, 2019 5:17 pm

1. You don't need to include jquery as it is already out there.
2. You can include the required javascript code just before {{ footer }} in the twig file catalog/view/theme/*/template/account/account.twig
3. Don't forget to place <div class="greeting"></div> in the same twig file where you want to appear the message.

XForm - Opencart Form Builder
Xshippingpro - An advanced Shipping Module
Need Professional support? Skype: opencartmart


Active Member

Posts

Joined
Wed Oct 02, 2013 3:59 am

Post by seanstorm100 » Sun Dec 01, 2019 9:30 pm

Thank you Opencartmart,

I was trying to figure out where to put them seeing that the files are broken up into so many parts. I will try and get back to you.
opencartmart wrote:
Sun Dec 01, 2019 5:17 pm
1. You don't need to include jquery as it is already out there.
2. You can include the required javascript code just before {{ footer }} in the twig file catalog/view/theme/*/template/account/account.twig
3. Don't forget to place <div class="greeting"></div> in the same twig file where you want to appear the message.

Regards,
Sean


New member

Posts

Joined
Tue Nov 05, 2019 11:08 pm

Post by seanstorm100 » Sun Dec 01, 2019 9:39 pm

Thank you Opencartmart, this worked handsomely! I hope this helps someone else as well,
Have a good day!
opencartmart wrote:
Sun Dec 01, 2019 5:17 pm
1. You don't need to include jquery as it is already out there.
2. You can include the required javascript code just before {{ footer }} in the twig file catalog/view/theme/*/template/account/account.twig
3. Don't forget to place <div class="greeting"></div> in the same twig file where you want to appear the message.

Regards,
Sean


New member

Posts

Joined
Tue Nov 05, 2019 11:08 pm

Post by paulfeakins » Mon Dec 02, 2019 7:54 pm

seanstorm100 wrote:
Sun Dec 01, 2019 12:29 pm
I was wondering, any idea of how to get this greeting Javascript to print out the time of day messages at the top of OC my Account page?
Is this really necessary? Will it have a tangible effect on your sales?

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Expert Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom

Post by letxobnav » Tue Dec 03, 2019 4:02 am

always good to be reminded if it is morning, afternoon or evening.
Personally I would add happy-hour.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Active Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by paulfeakins » Tue Dec 03, 2019 5:22 pm

letxobnav wrote:
Tue Dec 03, 2019 4:02 am
always good to be reminded if it is morning, afternoon or evening.
Personally I would add happy-hour.
:laugh: :laugh: :laugh:

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Expert Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom

Post by fegdeed » Wed Dec 04, 2019 9:48 pm

How about greeting + first name?

New member

Posts

Joined
Fri Sep 21, 2018 12:01 am

Post by letxobnav » Thu Dec 05, 2019 5:54 am

You always address your customers by their first name?

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Active Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by fegdeed » Thu Dec 05, 2019 8:49 am

Not really, I guess a more formal way will be to use the lastname.

New member

Posts

Joined
Fri Sep 21, 2018 12:01 am
Who is online

Users browsing this forum: No registered users and 22 guests