Post by rootKID » Mon Jul 17, 2017 3:35 pm

Hello peepz, been a while so trying to get back into the game and right now i have 2 webshop customers.. as always i am going for OpenCart (of course :P) "from Denmark btw.."

okay so long of short. My boss at my local pizza already has a webshop, the oldest version of OpenCart (1.x).. the stable version, but the guy that did it ditched him and now the website literally looks.. well, not good.

I spoke it over with boss and he said if i could show him some good new design he would let me re-do the whole website, so guess where i am right now..

Anyhow, since it is a pizza-delivery shop he asked if it would be possible to "close orders" between 9 at night to 10-12 next morning (so basically only be able to order from website within 9 hours a day..)

is this possible? I said i would look into this but not sure since it's been a while since i have updated myself to the latest version of you guys..

Anyways i hope you guys can help a little.

Also on another note, i have been looking for a script online for a printer so that when my boss gets new orders the printer in the shop would make a "beep" sound and then automaticly print the orders. We found a temporary software for this but not sure this is a good one since we have to pay for it :/

Thanks again, hope you guys can help out also sorry for bad english, need to get back into the game again before i learn how to spell i guess hehe :P

All good, thanks again! :D

PS: If i posted this in wrong section, feel free to tell me or move it to the right section.. not sure if this part was support or discussion :P

Thanks again :)

Newbie

Posts

Joined
Mon Apr 02, 2012 5:45 am
Location - Denmark/Copenhagen

Post by paulfeakins » Mon Jul 17, 2017 6:53 pm

rootKID wrote:
Mon Jul 17, 2017 3:35 pm
would be possible to "close orders" between 9 at night to 10-12 next morning (so basically only be able to order from website within 9 hours a day..)
Would be pretty easy, a few lines of PHP. Just check the time with PHP and replace the Add to Cart button with a message saying orders can only be placed between certain hours. Probably use some JavaScript also for the case where a user hasn't refreshed the page for a long time.

rootKID wrote:
Mon Jul 17, 2017 3:35 pm
Also on another note, i have been looking for a script online for a printer so that when my boss gets new orders the printer in the shop would make a "beep" sound and then automaticly print the orders. We found a temporary software for this but not sure this is a good one since we have to pay for it :/
Forget that paid software, you just need a printer that can print what it receives by email - many new models have this. Then configure OpenCart to copy in the printer on order emails and job done.

rootKID wrote:
Mon Jul 17, 2017 3:35 pm
Thanks again, hope you guys can help out also sorry for bad english, need to get back into the game again before i learn how to spell i guess hehe :P
Your English is very good actually and so was your description of the issues :)

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by rootKID » Sat Jul 22, 2017 4:55 am

Hello, thanks for the support and sorry for the delayed answer :P

The PHP part i get... but where should i put this part? Just in the .tmp/template code area? Just add in there like normal PHP code and then run it?

Also i have a new error, not sure why..

http://thai-chinese.dk/

Fatal error: Uncaught exception 'Twig_Error_Loader' with message 'Unable to find template "common/language.twig" (looked into: /home/thaionli/public_html/catalog/view/theme).' in /home/thaionli/public_html/system/library/template/Twig/Loader/Filesystem.php:215 Stack trace: #0 /home/thaionli/public_html/system/library/template/Twig/Loader/Filesystem.php(139): Twig_Loader_Filesystem->findTemplate('common/language...') #1 /home/thaionli/public_html/system/library/template/Twig/Environment.php(312): Twig_Loader_Filesystem->getCacheKey('common/language...') #2 /home/thaionli/public_html/system/library/template/Twig/Environment.php(378): Twig_Environment->getTemplateClass('common/language...', NULL) #3 /home/thaionli/opencart_storage/modification/system/library/template/twig.php(45): Twig_Environment->loadTemplate('common/language...') #4 /home/thaionli/public_html/system/library/template.php(20): Template\Twig->render('common/language', '1') #5 /home/thaionli/opencart_storage/modification/system/engine/loader.php(85): Template in /home/thaionli/public_html/system/library/template/Twig/Loader/Filesystem.php on line 215

any ideas? :/

Thanks for the great help again! :D

EDITED DATE: 22-07-2017

So i just found out today that the error i just posted, wen't away the second i tried to turn off the "Maintenance mode" in the Admin Settings area... trouble with the template system maybe? :P
Anyhow still working on it.. if you find a solution before me, thanks! :P

Also note that this error occurs on another website... not my bosses website, my bosses website is another URL, here:

http://www.allespizza-kiosk.dk/
:D

Newbie

Posts

Joined
Mon Apr 02, 2012 5:45 am
Location - Denmark/Copenhagen

Post by desatascosservice » Sun Oct 14, 2018 3:04 am

Would be pretty easy, a few lines of PHP. Just check the time with PHP and replace the Add to Cart button with a message saying orders can only be placed between certain hours. Probably use some JavaScript also for the case where a user hasn't refreshed the page for a long time.

We use it in https://www.grandform.es/
rootKID wrote:
Sat Jul 22, 2017 4:55 am
Hello, thanks for the support and sorry for the delayed answer :P

The PHP part i get... but where should i put this part? Just in the .tmp/template code area? Just add in there like normal PHP code and then run it?

Also i have a new error, not sure why..

http://thai-chinese.dk/

Fatal error: Uncaught exception 'Twig_Error_Loader' with message 'Unable to find template "common/language.twig" (looked into: /home/thaionli/public_html/catalog/view/theme).' in /home/thaionli/public_html/system/library/template/Twig/Loader/Filesystem.php:215 Stack trace: #0 /home/thaionli/public_html/system/library/template/Twig/Loader/Filesystem.php(139): Twig_Loader_Filesystem->findTemplate('common/language...') #1 /home/thaionli/public_html/system/library/template/Twig/Environment.php(312): Twig_Loader_Filesystem->getCacheKey('common/language...') #2 /home/thaionli/public_html/system/library/template/Twig/Environment.php(378): Twig_Environment->getTemplateClass('common/language...', NULL) #3 /home/thaionli/opencart_storage/modification/system/library/template/twig.php(45): Twig_Environment->loadTemplate('common/language...') #4 /home/thaionli/public_html/system/library/template.php(20): Template\Twig->render('common/language', '1') #5 /home/thaionli/opencart_storage/modification/system/engine/loader.php(85): Template in /home/thaionli/public_html/system/library/template/Twig/Loader/Filesystem.php on line 215

any ideas? :/

Thanks for the great help again! :D

EDITED DATE: 22-07-2017

So i just found out today that the error i just posted, wen't away the second i tried to turn off the "Maintenance mode" in the Admin Settings area... trouble with the template system maybe? :P
Anyhow still working on it.. if you find a solution before me, thanks! :P

Also note that this error occurs on another website... not my bosses website, my bosses website is another URL, here:

http://www.allespizza-kiosk.dk/
:D

Desatascos Sabadell

Image



Posts

Joined
Wed Mar 28, 2018 7:59 pm


Post by rootKID » Mon Oct 15, 2018 2:49 am

okay thanks. Or tho i am a little noob with the time thing. Can anyone guide me as to what or how to do this? Thanks if possible! :D

Newbie

Posts

Joined
Mon Apr 02, 2012 5:45 am
Location - Denmark/Copenhagen

Post by IP_CAM » Mon Oct 15, 2018 7:28 am

This can be of help, since it likely surpasses free 'forum-assistance'. ;)
Ernie
https://www.opencart.com/index.php?rout ... p+at+hours

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by straightlight » Mon Oct 15, 2018 7:38 am

Setting an automated closing time session template may affect your site reputation with Search Engines. Rather disable the add-to-cart buttons during closing times than disabling the views from the categories and products page themselves.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by rootKID » Fri May 24, 2019 5:47 am

straightlight wrote:
Mon Oct 15, 2018 7:38 am
Setting an automated closing time session template may affect your site reputation with Search Engines. Rather disable the add-to-cart buttons during closing times than disabling the views from the categories and products page themselves.
Good idea but how to do this? I am not the best in doing JS :/

Newbie

Posts

Joined
Mon Apr 02, 2012 5:45 am
Location - Denmark/Copenhagen

Post by thekrotek » Fri May 24, 2019 6:08 am

I'm not sure why this is even necessary. Just add a notice with the message in the header, which will pop in a given period of time and say "Hey, I'm fkn sleepy, go away!" or something like that. A basic understanding of MVC and OCMod is required.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by straightlight » Fri May 24, 2019 8:52 am

rootKID wrote:
Fri May 24, 2019 5:47 am
straightlight wrote:
Mon Oct 15, 2018 7:38 am
Setting an automated closing time session template may affect your site reputation with Search Engines. Rather disable the add-to-cart buttons during closing times than disabling the views from the categories and products page themselves.
Good idea but how to do this? I am not the best in doing JS :/
Untested but, idealistically, to start the idea. Ensure to create a backup of the existing files below before proceeding. This has been coded for OC v3.0.3.2 release.

In your catalog/controller/product folder, create the file: product_maintenance.php .

Then, add the following:

Code: Select all

<?php

class ControllerProductProductMaintenance extends Controller {
	public function index() {
		
	}
	
	public function validateMaintenance() {
		$json = array();
		
		if (isset($this->request->post['product_id'])) {
			$this->load->language('product/product_maintenance');
		
			if (!$this->storeIsOpen()) {
				$json['error']['maintenance'] = $this->language->get('error_maintenance');
			}
		}
		
		$this->response->addHeader('Content-Type: application/json');
		$this->response->setOutput(json_encode($json));		
	}
	
	// Source: https://stackoverflow.com/questions/14904864/determine-if-business-is-open-closed-based-on-business-hours
	protected function storeIsOpen() {
		$status = false;
		
		$storeSchedule = array('Mon' => ['08:00 AM' => '05:00 PM'],
							   'Tue' => ['08:00 AM' => '05:00 PM'],
							   'Wed' => ['08:00 AM' => '05:00 PM'],
							   'Thu' => ['08:00 AM' => '05:00 PM'],
							   'Fri' => ['08:00 AM' => '05:00 PM']
							  );

		// Get current East Coast US time
		$timeObject = new DateTime('America/New_York');
		
		$timestamp = $timeObject->getTimeStamp();
		
		$currentTime = $timeObject->setTimestamp($timestamp)->format('H:i A');

		// Loop through time ranges for current day
		foreach ($storeSchedule[date('D', $timestamp)] as $startTime => $endTime) {
			// Create time objects from start/end times and format as string (24hr AM/PM)
			$startTime = DateTime::createFromFormat('h:i A', $startTime)->format('H:i A');
			
			$endTime = DateTime::createFromFormat('h:i A', $endTime)->format('H:i A');

			// Check if current time is within the range
			if (($startTime < $currentTime) && ($currentTime < $endTime)) {
				$status = true;
				
				break;
			}
		}
		
		return $status;
	}
}
From the: $storeSchedule array, you can modify your time periods for each days of the week.

Followed is based on the default theme. You'll have to make the adjustment in your custom theme.

In catalog/view/theme/<your_theme>/template/product/product.twig file,

find:

Code: Select all

<script type="text/javascript"><!--
$('#button-cart').on('click', function() {
	$.ajax({
		url: 'index.php?route=checkout/cart/add',
		type: 'post',
		data: $('#product input[type=\'text\'], #product input[type=\'hidden\'], #product input[type=\'radio\']:checked, #product input[type=\'checkbox\']:checked, #product select, #product textarea'),
		dataType: 'json',
		beforeSend: function() {
			$('#button-cart').button('loading');
		},
		complete: function() {
			$('#button-cart').button('reset');
		},
		success: function(json) {
			$('.alert-dismissible, .text-danger').remove();
			$('.form-group').removeClass('has-error');

			if (json['error']) {
				if (json['error']['option']) {
					for (i in json['error']['option']) {
						var element = $('#input-option' + i.replace('_', '-'));

						if (element.parent().hasClass('input-group')) {
							element.parent().after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
						} else {
							element.after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
						}
					}
				}

				if (json['error']['recurring']) {
					$('select[name=\'recurring_id\']').after('<div class="text-danger">' + json['error']['recurring'] + '</div>');
				}

				// Highlight any found errors
				$('.text-danger').parent().addClass('has-error');
			}

			if (json['success']) {
				$('.breadcrumb').after('<div class="alert alert-success alert-dismissible">' + json['success'] + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>');

				$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');

				$('html, body').animate({ scrollTop: 0 }, 'slow');

				$('#cart > ul').load('index.php?route=common/cart/info ul li');
			}
		},
        error: function(xhr, ajaxOptions, thrownError) {
            alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
        }
	});
});
//--></script> 
Remove it.

Then, find:

Code: Select all

$(document).ready(function() {
add after:

Code: Select all

$.ajax({
		url: 'index.php?route=product/product_maintenance/validateMaintenance',
		type: 'post',
		dataType: 'json',
		data: 'product_id=' + {{ product_id }}',
		beforeSend: function() {
			$('#button-cart').button('loading');
		},
		complete: function() {
			$('#button-cart').button('reset');
		},
		success: function(json) {
			$('.alert-dismissible').remove();

			if (json['error']['maintenance']) {
				$('#button-cart').prop('disabled', true);
			
				$('.breadcrumb').after('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error']['maintenance'] + '</div>');
			} else {
				$('#button-cart').on('click', function() {
					$.ajax({
						url: 'index.php?route=checkout/cart/add',
						type: 'post',
						data: $('#product input[type=\'text\'], #product input[type=\'hidden\'], #product input[type=\'radio\']:checked, #product input[type=\'checkbox\']:checked, #product select, #product textarea'),
						dataType: 'json',
						beforeSend: function() {
							$('#button-cart').button('loading');
						},
						complete: function() {
							$('#button-cart').button('reset');
						},
						success: function(json) {
							$('.alert-dismissible, .text-danger').remove();
							$('.form-group').removeClass('has-error');

							if (json['error']) {
								if (json['error']['option']) {
									for (i in json['error']['option']) {
										var element = $('#input-option' + i.replace('_', '-'));

										if (element.parent().hasClass('input-group')) {
											element.parent().after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
										} else {
											element.after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
										}
									}
								}

								if (json['error']['recurring']) {
									$('select[name=\'recurring_id\']').after('<div class="text-danger">' + json['error']['recurring'] + '</div>');
								}

								// Highlight any found errors
								$('.text-danger').parent().addClass('has-error');
							}

							if (json['success']) {
								$('.breadcrumb').after('<div class="alert alert-success alert-dismissible">' + json['success'] + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>');

								$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');

								$('html, body').animate({ scrollTop: 0 }, 'slow');

								$('#cart > ul').load('index.php?route=common/cart/info ul li');
							}
						},
						error: function(xhr, ajaxOptions, thrownError) {
							alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
						}
					});
				});
			}
		}
	});
Then, in your catalog/language/en-gb/product folder, create a new language file: product_maintenance.php .

Add:

Code: Select all

<?php

$_['error_maintenance'] = 'Our store is currently closed for the day!';
See if that solves the issue.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 188 guests