Post by dmor71 » Wed Jun 06, 2012 2:46 am

How can I display the date the sale/special ends on the product page? Is there a script or something already built in? I'm running V1.5.3.1 - Thanks for any help.

Newbie

Posts

Joined
Mon Jun 04, 2012 8:12 pm

Post by Avvici » Wed Jun 06, 2012 4:15 am

If you follow my lead and don't rush through it this will give you exactly what you want.
Open: catalog/controller/product/product.php and find this code:

Code: Select all

$this->load->model('catalog/product');
		
		$product_info = $this->model_catalog_product->getProduct($product_id);
Below it add this:

Code: Select all

$special_info = $this->db->query("SELECT date_end FROM " . DB_PREFIX . "product_special WHERE product_id = '" . (int)$product_id . "'");
			if ($special_info->num_rows) {
				$date_end = $special_info->row['date_end'];	
		        $this->data['date_end'] = date($this->language->get('date_format_short'), strtotime($date_end));
			}else{
				   $this->data['date_end'] = '';
			}

Now open: catalog/view/theme/default/template/product/product.tpl and find this:

Code: Select all

 <?php if (!$special) { ?>
        <?php echo $price; ?>
        <?php } else { ?>
        <span class="price-old"><?php echo $price; ?></span> <span class="price-new"><?php echo $special; ?></span>
        <?php } ?>
Make it look like this:

Code: Select all

 <?php if (!$special) { ?>
        <?php echo $price; ?>
        <?php } else { ?>
        <span class="price-old"><?php echo $price; ?></span> <span class="price-new"><?php echo $special; ?><br />Special Ends: <?php echo $date_end; ?></span>
        <?php } ?>
And there you have it. I tested on 1.5.2.1 + and works fine.

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by dmor71 » Wed Jun 06, 2012 4:41 am

That was beautiful! Thanks very much. Worked perfectly.

Newbie

Posts

Joined
Mon Jun 04, 2012 8:12 pm

Post by samolesong76 » Thu Jun 07, 2012 5:34 am

Was looking for this. Thanks.

New member

Posts

Joined
Sun Apr 22, 2012 12:39 am
Who is online

Users browsing this forum: No registered users and 47 guests