Post by fiery3 » Thu Oct 21, 2010 9:04 am

I've searched the forum, but haven't found an answer for this yet.

Is there a way to show the end date for a special to the customer on the product page?

Thank You

Newbie

Posts

Joined
Sat Oct 16, 2010 7:43 am

Post by kedgetech » Fri Oct 22, 2010 3:15 pm

Its possible with changes to our countdown timer bundle module. Email - sales@kedgegroup.com

User avatar
Active Member

Posts

Joined
Mon Mar 22, 2010 5:20 pm
Location - USA, Australia, India

Post by fiery3 » Mon Oct 25, 2010 8:37 am

Version 1.4.9.1

So far after much trial and error, I have come up with this:

\catalog\controller\product\product.php
After this:

Code: Select all

			$this->data['text_price'] = $this->language->get('text_price');
Add this:

Code: Select all

			$this->data['text_special_end'] = $this->language->get('text_special_end');
After this:

Code: Select all

					'rating'  		=> $rating,
Add this:

Code: Select all

					'date_end'	   => $special_end,
\catalog\language\english\product\product.php
After this:

Code: Select all

$_['text_price']          = 'Price:';
Add this:

Code: Select all

$_['text_special_end']	  = 'Special Ends';
\catalog\view\default\template\product\product.tpl
After this:

Code: Select all

                <td><?php if (!$special) { ?>
                  <?php echo $price; ?>
                  <?php } else { ?>
                  <span style="text-decoration: line-through;"><?php echo $price; ?></span> <span style="color: #F00;"><?php echo $special; ?></span>
                  <?php } ?></td>
              </tr>
              <?php } ?>
Add this:

Code: Select all

			  <tr>
                <td><?php if (!$special) { ?>
                  <?php } else { ?>
                  <span><b><?php echo $text_special_end; ?></b></span></td>
                <td><span style="color: #F00;"><?php echo $special_end; ?></span>
                  <?php } ?></td>
			  </tr>
\catalog\model\catalog\product.php
After this:

Code: Select all

	public function getProductSpecial($product_id) {
		if ($this->customer->isLogged()) {
			$customer_group_id = $this->customer->getCustomerGroupId();
		} else {
			$customer_group_id = $this->config->get('config_customer_group_id');
		}	
		
		$query = $this->db->query("SELECT price FROM " . DB_PREFIX . "product_special WHERE product_id = '" . (int)$product_id . "' AND customer_group_id = '" . (int)$customer_group_id . "' AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) ORDER BY priority ASC, price ASC LIMIT 1");
		
		if ($query->num_rows) {
			return $query->row['price'];
		} else {
			return FALSE;
		}
	}
Add this:

Code: Select all

	public function getProductSpecialEnd($product_id) {
		if ($this->customer->isLogged()) {
			$customer_group_id = $this->customer->getCustomerGroupId();
		} else {
			$customer_group_id = $this->config->get('config_customer_group_id');
		}	
		
		$query = $this->db->query("SELECT date_end FROM " . DB_PREFIX . "product_special WHERE product_id = '" . (int)$product_id . "' AND customer_group_id = '" . (int)$customer_group_id . "' AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) ORDER BY priority ASC, price ASC LIMIT 1");
		
		if ($query->num_rows) {
			return $query->row['date_end'];
		} else {
			return FALSE;
		}
	}
issue.png

issue.png (4.77 KiB) Viewed 10762 times

I have managed to make this disappear when the product is not on special, but I don't know where to put the code to extract the date_end from product_special. For me this is my first major exploration of php so forgive me if I went about this in an odd way. Any help would be greatly appreciated.

Update: I think I have extracted the date_end now, at least it seems that way. Now I need to figure out how to make it show up on the product page.
Last edited by fiery3 on Fri Feb 18, 2011 10:24 am, edited 2 times in total.

Newbie

Posts

Joined
Sat Oct 16, 2010 7:43 am

Post by fiery3 » Thu Oct 28, 2010 8:53 am

Did I put this in the wrong section?

I would like to figure this out and share it with the rest of the community. I have gone as far as I can with my understanding of php. If someone could at least point me in the right direction.

Newbie

Posts

Joined
Sat Oct 16, 2010 7:43 am

Post by justinv » Fri Oct 29, 2010 3:49 am

You're heading in the right direction from what I can see. I haven't done this myself, but if you have a look at catalog/model/catalog/product.php there is a function called getProductSpecial which is called to get th special info. The start and end date are not returned by the function, only the special price. The start and end date are just used to make sure the special price currently applies.

You will need to create a new function similar to the getProductSpecial function (or modify the existing one) so that it also returns the end date, and then you will be able to use it in your controller.

Hope that helps.

Documentation: OpenCart User Guide
Mods: Total Import PRO | CSV Import PRO | Ecom Tracking | Any Feed | Autosuggest | OpenCart CDN
Image


Active Member

Posts

Joined
Tue Oct 12, 2010 1:24 pm

Post by fiery3 » Sat Oct 30, 2010 9:40 am

Thanks for the input. I tried this and managed to get getProductSpecialEnd to work but then I went and broke the product page so I am starting over again with this code.

I'll post updates if I figure anything out.

Newbie

Posts

Joined
Sat Oct 16, 2010 7:43 am

Post by fiery3 » Sat Oct 30, 2010 10:07 am

I have updated the code in the above post. I feel like I am close to the end but I can't figure out how to link everything so it shows up on the product page.

Newbie

Posts

Joined
Sat Oct 16, 2010 7:43 am

Post by SapporoGuy » Tue Nov 02, 2010 3:21 am

Just copy and past the function, change names, change the call instead of price to date

go to controller and add after the specials section, around line 200 or so:

$this->data['date_start'] = $this->model_catalog_product->getProductSpecialStartDate($this->request->get['product_id']);
$this->data['date_start'] = date($this->language->get('date_format_short'), strtotime($this->data['date_start']));
$this->data['date_end'] = $this->model_catalog_product->getProductSpecialEndDate($this->request->get['product_id']);
$this->data['date_end'] = date($this->language->get('date_format_short'), strtotime($this->data['date_end']));

looks like you got the rest

I did the above dirty hack but would like something more elegant.
Can't you get the same data from getProductSpecials?
I'm pulling array errors.
Can somebody give me a heads up?
lolo, I could never figure out how to do a proper array walk :(

930sc ... because it is fun!


User avatar
Active Member

Posts

Joined
Mon Nov 01, 2010 7:29 pm

Post by fiery3 » Tue Nov 02, 2010 7:54 am

Thanks for your help.

Since I am so green in programming my technique is watch and imitate. As such, no matter what I did with the code you shared I could not get it to do anything. I still get the error listed above. ??? Did you happen to get this to work? If so can you give me a little more detail as to where to put the code. Thank you.

Newbie

Posts

Joined
Sat Oct 16, 2010 7:43 am

Post by fiery3 » Fri Nov 05, 2010 9:36 am

Anybody have an answer?

Newbie

Posts

Joined
Sat Oct 16, 2010 7:43 am

Post by fiery3 » Fri Feb 18, 2011 10:17 am

Anyone come up with a solution?

Newbie

Posts

Joined
Sat Oct 16, 2010 7:43 am

Post by Dhaupin » Wed Jul 02, 2014 10:16 pm

This thread is very old but its the one of the only that comes up in searches. If anyone is interested here is how to add the dates into something like the feed, with fallbacks for the "no timeframe" to revert to starting yesterday and ending a year from now. The product pages have a more streamlined method, but this works elsewhere in simplistic form

Load model for the product to get product_id:

Code: Select all

$this->load->model('catalog/product');
This goes in a controller somewhere...although technically $special_date query should be in a model:

Code: Select all

$special_date = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_special WHERE product_id = '" . $product['product_id'] . "'");
$date_start_safety = str_replace('0000-00-00', date('Y-m-d', strtotime("yesterday")), $special_date->row['date_start']);
$date_end_safety = str_replace('0000-00-00', date('Y-m-d', strtotime("+1 year")), $special_date->row['date_end']);
$this->data['specials_range'] = '<div id="specials-range">From ' . $date_start_safety . 'to ' . $date_end_safety . '</div>';
This goes in a template wherever you want the range to show:

Code: Select all

<? php echo $specials_range; ?>

https://creadev.org | support@creadev.org - Opencart Extensions, Integrations, & Development. Made in the USA.


User avatar
Active Member

Posts

Joined
Tue May 13, 2014 3:45 am
Location - PA

Post by IP_CAM » Wed Jul 02, 2014 10:36 pm

just to mention it, here, you find two solutions to visually display this:

http://www.opencart.com/index.php?route ... on_id=4365

http://www.opencart.com/index.php?route ... on_id=6965

Ernie

ipc.li/shop/

My Github OC Site: https://github.com/IP-CAM
5'600 + 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 Dhaupin » Wed Jul 02, 2014 11:36 pm

True those look neat, but they use javascript so its not so bot-centric. It seems those only work if you set a date range too. This method looks for set, somewhat set, or not set and auto adjusts accordingly, in a simplistic way.

I made it for feed, but can be used product side too. In the case of the feed, it cant be "undefined" or "unlimited". If left undefined date range, the sale will always start yesterday and end a year from now relative to when the bot/human hits it. This is useful for Google PLA feeds since it asks for a timeframe in order to trigger the sale_price attribute.

Why i shared here: Similarly by adjusting the "+1 year" you can use on product page to create a sense of urgency. Lets say you made a special that was set to go forever. Change the +1 year to +1 day. The product page would say the sale started yesterday and ends tomorrow, even though it goes forever.

Sly indeed, and not bulletproof logic by any means, but its a hotfix for feeds useful perhaps maybe product level haha.

https://creadev.org | support@creadev.org - Opencart Extensions, Integrations, & Development. Made in the USA.


User avatar
Active Member

Posts

Joined
Tue May 13, 2014 3:45 am
Location - PA

Post by GoldenTongs » Thu Jun 25, 2015 12:25 am

will any of the above work on 2.0 ?
all i am looking for is
"offer ends: (date)"
next to or under the special price

http://Lilphones.com
Image


Active Member

Posts

Joined
Sun Jul 29, 2012 5:26 pm

Post by straightlight » Sat Jul 04, 2015 8:05 pm

Hi GolderTongs,

these modifications were meant for previous versions of Opencart. The v2.0 release uses template responsive mode which would not correspond to the steps mentioned above. This topic seem to be an old one as it would not be compatible with v2,0x releases nor would it be suggested to.

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 fido-x » Wed Jul 08, 2015 12:25 pm

I've done a "little" bit of work on this after receiving a request via PM from a member of the forum.

See viewtopic.php?f=121&t=147359 for more information.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia
Who is online

Users browsing this forum: No registered users and 7 guests