Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Adding 'specials' to categories


Guest

Recommended Posts

Hi there.

 

I have done a search and didn't find any answers - hopefully this isn't a complex one.

 

I like the specials system in osC having tested it out.

 

How can I put a hyperlink in categories to open specials.php?

 

Cheers! :D

 

C

Link to comment
Share on other sites

Seperately, I am trying to add a picture and integral hyperlink to my phpBB in header.php, just to the left of the three buttons on the right.

 

I have added the following line:

<a href="http://subdomain.mydomain.co.uk">' . '</a>' '">' . tep_image(DIR_WS_IMAGES .

 

'forum.gif', HEADER_TITLE_FORUM) . '</a>  

 

Just before this line:

<a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . tep_image(DIR_WS_IMAGES .

 

'header_account.gif', HEADER_TITLE_MY_ACCOUNT) . '</a>  

 

 

I get the following error:

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/httpd/vhosts/migraineaudio.co.uk/httpdocs/shop/includes/header.php on line 59

 

Can anyone tell me what to do to fix my code? Line 59 is the end of the document...

 

C

Link to comment
Share on other sites

to me it looks like you have to pay more attention to the single quotes surrounding strings that you need to use in php sections together with the echo command to output html.

 

this line

<a href="http://subdomain.mydomain.co.uk">' . '</a>' '">' . tep_image(DIR_WS_IMAGES . 'forum.gif', HEADER_TITLE_FORUM) . '</a>  

 

should probably be something like this:

echo '<a href="http://subdomain.mydomain.co.uk">' . tep_image(DIR_WS_IMAGES . 'forum.gif', HEADER_TITLE_FORUM) . '</a>  ';

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

Many thanks!

 

I'm still having problems.

 

Here is the entirety of my code for the buttons on the right. I can't see a problem with it! All tags close etc.

 

<td align="right" valign="bottom"><?php echo '<a href="http://forum.mydomain.co.uk">' . tep_image(DIR_WS_IMAGES . 'forum.gif', HEADER_TITLE_FORUM) . '</a>  ';

<a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . tep_image(DIR_WS_IMAGES . 'header_account.gif', HEADER_TITLE_MY_ACCOUNT) . '</a>  

<a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '">' . tep_image(DIR_WS_IMAGES . 'header_cart.gif', HEADER_TITLE_CART_CONTENTS) . '</a>  <a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '">' . tep_image(DIR_WS_IMAGES . 'header_checkout.gif', HEADER_TITLE_CHECKOUT) . '</a>'; ?>  </td>

 

 

However, the error given is different this time - it mentions an unexpected '<' so I think were getting closer - (however I haven't been able to find an unexpected <...

Link to comment
Share on other sites

think it's the single quote at the end of the 2 nbsp on the first line - my mistake ... I thought your code ended there ...

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

yes, it all works the same way.

Though if you point to other oscommerce pages, you should use the oscommerce function tep_href_link('mypage.php') to keep the session ids

eg echo '<a href="' . tep_href_link(FILENAME_SPECIALS) . '"> Specials</a>';

Note, there is a text constant defined for the label specials as well. Best to use that to ensure consistency throughout your store should you want to change it to promotions for instance.

 

FILENAME_SPECIALS doesn't need quotes as it is defined as a text constant in catalog/includes/filenames.php

 

HTH

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

Thanks for your help Carine.

 

I've tried adding the code 'echo '<a href='" . tep_........' into categories.php but I've not had much sucess! :)

 

Its not like some of the easier files (like column_left.php which was easy enough to modify).. where should I enter the code in order to get the Specials link within the box?

 

My first try gave me 7 links, each as a 'Specials' hyperlink, but it was outside the box. =)

 

 

Code starts:

<?php

/*

$Id: categories.php,v 1.25 2003/07/09 01:13:58 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

function tep_show_category($counter) {

global $tree, $categories_string, $cPath_array;

 

for ($i=0; $i<$tree[$counter]['level']; $i++) {

$categories_string .= "  ";

}

 

$categories_string .= '<a href="';

 

if ($tree[$counter]['parent'] == 0) {

$cPath_new = 'cPath=' . $counter;

} else {

$cPath_new = 'cPath=' . $tree[$counter]['path'];

}

 

$categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">';

 

if (isset($cPath_array) && in_array($counter, $cPath_array)) {

$categories_string .= '<b>';

}

 

// display category name

$categories_string .= $tree[$counter]['name'];

 

if (isset($cPath_array) && in_array($counter, $cPath_array)) {

$categories_string .= '</b>';

}

 

if (tep_has_category_subcategories($counter)) {

$categories_string .= '->';

}

 

$categories_string .= '</a>';

 

if (SHOW_COUNTS == 'true') {

$products_in_category = tep_count_products_in_category($counter);

if ($products_in_category > 0) {

$categories_string .= ' (' . $products_in_category . ')';

}

}

 

$categories_string .= '<br>';

 

if ($tree[$counter]['next_id'] != false) {

tep_show_category($tree[$counter]['next_id']);

}

}

?>

<!-- categories //-->

<tr>

<td>

<?php

$info_box_contents = array();

$info_box_contents[] = array('text' => BOX_HEADING_CATEGORIES);

 

new infoBoxHeading($info_box_contents, true, false);

 

$categories_string = '';

$tree = array();

 

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");

while ($categories = tep_db_fetch_array($categories_query)) {

$tree[$categories['categories_id']] = array('name' => $categories['categories_name'],

'parent' => $categories['parent_id'],

'level' => 0,

'path' => $categories['categories_id'],

'next_id' => false);

 

if (isset($parent_id)) {

$tree[$parent_id]['next_id'] = $categories['categories_id'];

}

 

$parent_id = $categories['categories_id'];

 

if (!isset($first_element)) {

$first_element = $categories['categories_id'];

}

}

 

//------------------------

if (tep_not_null($cPath)) {

$new_path = '';

reset($cPath_array);

while (list($key, $value) = each($cPath_array)) {

unset($parent_id);

unset($first_id);

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$value . "' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");

if (tep_db_num_rows($categories_query)) {

$new_path .= $value;

while ($row = tep_db_fetch_array($categories_query)) {

$tree[$row['categories_id']] = array('name' => $row['categories_name'],

'parent' => $row['parent_id'],

'level' => $key+1,

'path' => $new_path . '_' . $row['categories_id'],

'next_id' => false);

 

if (isset($parent_id)) {

$tree[$parent_id]['next_id'] = $row['categories_id'];

}

 

$parent_id = $row['categories_id'];

 

if (!isset($first_id)) {

$first_id = $row['categories_id'];

}

 

$last_id = $row['categories_id'];

}

$tree[$last_id]['next_id'] = $tree[$value]['next_id'];

$tree[$value]['next_id'] = $first_id;

$new_path .= '_';

} else {

break;

}

}

}

tep_show_category($first_element);

 

$info_box_contents = array();

$info_box_contents[] = array('text' => $categories_string);

 

new infoBox($info_box_contents);

?>

</td>

</tr>

<!-- categories_eof //-->

Link to comment
Share on other sites

You can add a link like this near the bottom of the file, you might need to put some additional HTML or CSS class in for the best graphical results ...

 

Change From

$info_box_contents[] = array('text' => $categories_string);

 

To

$extra_info = '<br><a href="' . tep_href_link(FILENAME_SPECIALS) . '"> Specials</a>';

$info_box_contents[] = array('text' => $categories_string . $extra_info);

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

for the specials, I used the following in includes/boxes/categories.php:

 

find this:

  new infoBox($info_box_contents);

 

 

replace by:

  if ($specials = "select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and p.products_id = s.products_id and pd.products_id = s.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' order by s.specials_date_added desc") {
 $info_box_contents[] = array('align' => 'left',
                              'text' => tep_image(DIR_WS_IMAGES . 'custom/arrow_blue.gif', '') . '<a href="' . tep_href_link(FILENAME_SPECIALS, 'Specials') . '"><b>On Sale</b></a>');
 }
 new infoBox($info_box_contents);

 

I use the arrow for all my categories, replace it by any pic you are using or leave the part

tep_image(DIR_WS_IMAGES . 'custom/arrow_blue.gif', '') .

out

 

You can see it online here:

http://www.casin-group.com/kristin/oscommerce

 

You could also add a separator line before the specials link if you wanted to, like the total in the shopping cart is separated by a line. Post again if you need help with that. I didn't do it as I like it better without a line.

 

:-)

Monika

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

Many thanks both of you! :)

 

I'll give you a shout if I want to modify it further.

 

I ended up using Monika's code (thanks!).

 

It does have a seperator line in it, but I think it looks good =)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...