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');
Code: Select all
$this->data['text_special_end'] = $this->language->get('text_special_end');
Code: Select all
'rating' => $rating,
Code: Select all
'date_end' => $special_end,
After this:
Code: Select all
$_['text_price'] = 'Price:';
Code: Select all
$_['text_special_end'] = 'Special Ends';
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 } ?>
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>
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;
}
}
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;
}
}
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.
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
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!
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.

Load model for the product to get product_id:
Code: Select all
$this->load->model('catalog/product');
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>';
Code: Select all
<? php echo $specials_range; ?>
https://creadev.org | support@creadev.org - Opencart Extensions, Integrations, & Development. Made in the USA.
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.
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.
all i am looking for is
"offer ends: (date)"
next to or under the special price
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
See viewtopic.php?f=121&t=147359 for more information.
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!
Users browsing this forum: No registered users and 1 guest