Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Dynamic jQuery product tabs?


jaymz77

Recommended Posts

Is there a way i could use if/else statements with jQuery product tabs? Like if I was to add the product attributes to a tab, yet if there wasnt any attributes, that tab disappears.

 

Many thanks in advanced!

 

~ James

Link to comment
Share on other sites

if you put the logic to fetch the attributes before you generate the tabs, you could only show the tab if there are attributes, once you have generated tabs, it is possible to manipulate them afterwards, but it gets trickier

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

so you do the first bit I mentioned ...

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

so you do the first bit I mentioned ...

I'm sorry, I don't follow.

 

I really am just figuring out all this new 2.3.1 stuff, really was hoping that it would be an easy script.

Link to comment
Share on other sites

why don't you post your product_info.php as it currently is with the product tabs that are shown even if you don't have any attributes (if I understand correctly, that is what you have)

Make sure to include it in code tags so it remains readable.

Then some good samarithan on the forum here might be able to help you better, without seeing any code it is difficult to see the issue and how to correct it ...

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

  • 2 weeks later...

Here is my product_info code,

 

 <?php
/*
 $Id$

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2010 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCT_INFO);

 $product_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
 $product_check = tep_db_fetch_array($product_check_query);

 require(DIR_WS_INCLUDES . 'template_top.php');

 if ($product_check['total'] < 1) {
?>

<div class="contentContainer">
 <div class="contentText">
   <?php echo TEXT_PRODUCT_NOT_FOUND; ?>
 </div>

 <div style="float: right;">
   <?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'triangle-1-e', tep_href_link(FILENAME_DEFAULT)); ?>
 </div>
</div>

<?php
 } else {
   $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
   $product_info = tep_db_fetch_array($product_info_query);

   tep_db_query("update " . TABLE_PRODUCTS_DESCRIPTION . " set products_viewed = products_viewed+1 where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and language_id = '" . (int)$languages_id . "'");

   if (tep_not_null($product_info['products_model'])) {
     $products_name = $product_info['products_name'] . '<br /><span class="smallText">[' . $product_info['products_model'] . ']</span>';
   } else {
     $products_name = $product_info['products_name'];
   }

    if ($new_price = tep_get_products_special_price($product_info['products_id'])) {
     $products_price = '<del>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</del> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>';
   } else {
     $products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
   }
?>

<?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product')); ?>
<div class="contentContainer">
 <div class="contentText">

<?php
   if (tep_not_null($product_info['products_image'])) {
     $pi_query = tep_db_query("select image, htmlcontent from " . TABLE_PRODUCTS_IMAGES . " where products_id = '" . (int)$product_info['products_id'] . "' order by sort_order");

     if (tep_db_num_rows($pi_query) > 0) {
?>

   <div id="piGal" style="float: left;">
     <ul>

<?php
       $pi_counter = 0;
       while ($pi = tep_db_fetch_array($pi_query)) {
         $pi_counter++;

         $pi_entry = '        <li><a href="';

         if (tep_not_null($pi['htmlcontent'])) {
           $pi_entry .= '#piGalimg_' . $pi_counter;
         } else {
           $pi_entry .= tep_href_link(DIR_WS_IMAGES . $pi['image']);
         }

         $pi_entry .= '" target="_blank" rel="fancybox">' . tep_image( DIR_WS_IMAGES . $pi['image'] ) . '</a>';

         if (tep_not_null($pi['htmlcontent'])) {
           $pi_entry .= '<div style="display: none;"><div id="piGalimg_' . $pi_counter . '">' . $pi['htmlcontent'] . '</div></div>';
         }

         $pi_entry .= '</li>';

         echo $pi_entry;
       }
?>

     </ul>
   </div>
<script type="text/javascript">
$('#piGal ul').bxGallery({
 maxwidth: 300,
 maxheight: 200,
 thumbwidth: <?php echo (($pi_counter > 1) ? '66' : '0'); ?>,
 thumbcontainer: 300,
 load_image: 'ext/jquery/bxGallery/spinner.gif'
});
</script>

<?php
     } else {
?>

   <div id="piGal" style="float: left;">
     <?php echo '<a href="' . tep_href_link( DIR_WS_IMAGES . $product_info['products_image']) . '" target="_blank" rel="fancybox">' . tep_image( DIR_WS_IMAGES . $product_info['products_image'] , addslashes($product_info['products_name']), null, null, 'hspace="5" vspace="5"') . '</a>'; ?>
   </div>
<?php
     }
?>

<script type="text/javascript">
$("#piGal a[rel^='fancybox']").fancybox({
 cyclic: true
});
</script>

<?php
   }
?>
<div>
 <h1><?php echo $products_name; ?></h1>
 <h1><?php echo $products_price; ?></h1><br />
 <span class="buttonAction"><?php echo TEXT_ENTER_QUANTITY . ": " . tep_draw_input_field('cart_quantity', '1', 'size=2'); ?><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_draw_button(IMAGE_BUTTON_IN_CART, 'cart', null, 'primary'); ?></span></div>
 <br />
 <br />  
 <br />
 <?php

$sbm_array = explode(';', MODULE_SOCIAL_BOOKMARKS_INSTALLED);

$social_bookmarks = array();

foreach ( $sbm_array as $sbm ) {
$class = substr($sbm, 0, strrpos($sbm, '.'));

if ( !class_exists($class) ) {
include(DIR_WS_LANGUAGES . $language . '/modules/social_bookmarks/' . $sbm);
include(DIR_WS_MODULES . 'social_bookmarks/' . $class . '.php');
}

$sb = new $class();

if ( $sb->isEnabled() ) {
$social_bookmarks[] = $sb->getOutput();
}
}

if ( !empty($social_bookmarks) ) {
$data = '<div>' .
                 '  <div>' . '  ' . implode(' ', $social_bookmarks) . '</div>' .
                 '</div>';}
echo $data;
?><br />
<?php echo stripslashes($product_info['products_description']); ?>

<?php
   $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'");
   $products_attributes = tep_db_fetch_array($products_attributes_query);
   if ($products_attributes['total'] > 0) {
?>  

//options

<?php
   }
?>

   <div style="clear: both;"></div>

<?php
   if ($product_info['products_date_available'] > date('Y-m-d H:i:s')) {
?>

   <p style="text-align: center;"><?php echo sprintf(TEXT_DATE_AVAILABLE, tep_date_long($product_info['products_date_available'])); ?></p>

<?php
   }
?>

 </div>

<?php
   $reviews_query = tep_db_query("select count(*) as count from " . TABLE_REVIEWS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and reviews_status = 1");
   $reviews = tep_db_fetch_array($reviews_query);
?>
</p>
<!--tabs--> 
<script> $(document).ready(function() { $("#tabs").tabs(); }); </script> 
<div id="tabs"> 
<ul> 
<li><a href="#fragment-1"><span>Product Reviews</span></a></li>
<li><a href="#fragment-2"><span>Notification</span></a></li> 
<li><a href="#fragment-3"><span>Also Purchased</span></a></li> 
</ul> 
<div id="fragment-1"><?php
// BEGIN PopTheTop Product Info Reviews
?>
				 <TD ALIGN="left">
</TD>      
<?php
	  $reviews_query = tep_db_query("select count(*) as count from " . TABLE_REVIEWS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
	  $reviews = tep_db_fetch_array($reviews_query);
	  $reviews_query_average = tep_db_query("select (avg(reviews_rating)) as average_rating from " . TABLE_REVIEWS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
	  $reviews_average = tep_db_fetch_array($reviews_query_average);
	  $reveiws_stars = $reviews_average['average_rating'];
	  $reveiws_rating = number_format($reveiws_stars,0);
?>
     <tr>
       <td></td>
     </tr>
<?php
if (MAX_REVIEWS_IN_PRODUCT_INFO > 0) {
 $reviews_query = tep_db_query("select r.reviews_id, rd.reviews_text, r.reviews_rating, r.date_added, r.customers_name from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd where r.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and rd.reviews_id = r.reviews_id and rd.languages_id = '" . $languages_id . "' order by r.reviews_id DESC");
 $num_rows = tep_db_num_rows($reviews_query);
?>
     <tr>
       <td>
	  <table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td valign="top"></td>
         </tr>
       </table>
	  </td>
     </tr>
<?php
 if ($num_rows > 0) {
   $row = 0;
   while (($reviews_values = tep_db_fetch_array($reviews_query)) && ($row < MAX_REVIEWS_IN_PRODUCT_INFO)) {
     $row++;
     $date_added = tep_date_short($reviews_values['date_added']);
	// Write product reviews
?>
<?php
// END PopTheTop Product Info Reviews
?>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
     	<td>
		<table border="0" width="100%" cellspacing="1" cellpadding="2">
			<tr>
				<td>
				<table border="0" width="100%" cellspacing="0" cellpadding="2">
					<tr>
						<td valign="top" class="main"><?php echo '<FONT COLOR="#006699"><b>Submited By:</b> ' . $reviews_values['customers_name'] . ' on <span class="smallText">' . $date_added . '</span></font><br>' . tep_break_string(nl2br(tep_output_string_protected($reviews_values['reviews_text'])), 60, '-<br>') . '<br><br>' . sprintf(tep_image(DIR_WS_IMAGES . 'stars_' . $reviews_values['reviews_rating'] . '.gif', sprintf(BOX_REVIEWS_TEXT_OF_5_STARS, $reviews_values['reviews_rating']))) ?></td>
					</tr>
				</table>
				</td>
			</tr>
		</table>
		</td>
     </tr>
<?php
   } // END while (($reviews_values...
?>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '15'); ?></td>
     </tr>
     <tr>
       <td>
       <table border="0" width="100%" cellspacing="1" cellpadding="2">
        <tr>
        		<td>
        		<table border="0" width="100%" cellspacing="0" cellpadding="2">
					<tr>
						<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
						<TD ALIGN="left" VALIGN="middle" CLASS="buttonAction">
<?php
   if ($num_rows > MAX_REVIEWS_IN_PRODUCT_INFO) {
	echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, substr(tep_get_all_get_params(), 0, -1)) . '">' . tep_draw_button(IMAGE_BUTTON_REVIEWS) . '</a></td>';
	echo '							<TD ALIGN="right" VALIGN="middle" CLASS="main"><a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, substr(tep_get_all_get_params(), 0, -1)) . '">' . tep_draw_button(IMAGE_BUTTON_REVIEWS) . '</a></td>';
	echo '							<td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') . '</td>';
 } else {
	echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, substr(tep_get_all_get_params(), 0, -1)) . '">' . tep_draw_button(IMAGE_BUTTON_REVIEWS) . '</a></td>';
 }
?>
					</tr>
				</table>
				</td>
        </tr>
       </table>
	  </td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td>
     </tr>
<?php
   if ($reviews['count'] > 0) {
?>
     <tr>
     	<td class="smallText">
     	<table width="100%">
			<tr>
				<td align="left" class="smallText"><FONT COLOR="#006699"><?php echo TEXT_REVIEW_AVERAGE . ': ' . tep_image(DIR_WS_IMAGES . 'stars_' . $reveiws_rating . '.gif', '', 60, 12, 'align=absmiddle') . '</a>'; ?></font></td>
				<td align="right" class="smallText"><FONT COLOR="#006699"><?php echo sprintf(TEXT_DISPLAY_NUMBER_OF_REVIEWS_PRODUCT_INFO, $row, $num_rows); ?></font></td>
			</tr>
		</table>
		</td>
	</tr>
<?php
   } else {
?>
     <tr>
       <td class="smallText"><FONT COLOR="#006699"><?php echo sprintf(TEXT_DISPLAY_NUMBER_OF_REVIEWS_PRODUCT_INFO, $row, $num_rows); ?></font></td>
     </tr>
<?php
   }
?>

<?php
   } else { // if ($num_rows < 0)...
?>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td>
     </tr>
     <tr>
     	<td>
		<table border="0" width="100%" cellspacing="1" cellpadding="2">
			<tr>
				<td>
				<table border="0" width="100%" cellspacing="0" cellpadding="2">
					<tr>
						<td valign="top" class="buttonAction"><?php echo TEXT_NO_REVIEWS . '<br><a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, substr(tep_get_all_get_params(), 0, -1)) . '">' . tep_draw_button(IMAGE_BUTTON_REVIEWS) . '</a>'; ?></td>
					</tr>
				</table>
				</td>
			</tr>
		</table>
		</td>
     </tr>
<?php
 }
}
// END PopTheTop Product Info Reviews
?></div> 
<div id="fragment-2">
<?php

   if (tep_session_is_registered('customer_id'))
   {
     $check_query = tep_db_query("select count(*) as count from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . (int)$customer_id . "' and global_product_notifications = '1'");
     $check = tep_db_fetch_array($check_query);
     if ($check['count'] <= 0)
     {
     $check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and customers_id = '" . (int)$customer_id . "'");
     $check = tep_db_fetch_array($check_query);

     if($check['count'] > 0)
       echo '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=notify_remove', $request_type) . '">' . tep_image(DIR_WS_IMAGES . 'checked.gif', IMAGE_BUTTON_REMOVE_NOTIFICATIONS) . '</a> <a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=notify_remove', $request_type) . '">' . sprintf(BOX_NOTIFICATIONS_NOTIFY, tep_get_products_name($HTTP_GET_VARS['products_id'])) .'</a>';
     else
       echo '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=notify', $request_type) . '">' . tep_image(DIR_WS_IMAGES . 'unchecked.gif', IMAGE_BUTTON_NOTIFICATIONS) . '</a> <a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=notify', $request_type) . '">' . sprintf(BOX_NOTIFICATIONS_NOTIFY, tep_get_products_name($HTTP_GET_VARS['products_id'])) .'</a>';
     }
   }
   else
   {
     echo '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=notify', $request_type) . '">' . tep_image(DIR_WS_IMAGES . 'unchecked.gif', IMAGE_BUTTON_NOTIFICATIONS) . '</a> <a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=notify', $request_type) . '">' . sprintf(BOX_NOTIFICATIONS_NOTIFY, tep_get_products_name($HTTP_GET_VARS['products_id'])) .'</a>';
   }
?></div> 
<div id="fragment-3"><?php include(DIR_WS_MODULES . 'also_purchased_products.php'); ?></div>
</div> 
<!--/tabs-->
</div>

</form>

<?php
 }

 require(DIR_WS_INCLUDES . 'template_bottom.php');
 require(DIR_WS_INCLUDES . 'application_bottom.php');
?> 

 

Here is the jquery tabs section,

 

 <!--tabs--> 
<script> $(document).ready(function() { $("#tabs").tabs(); }); </script> 
<div id="tabs"> 
<ul> 
<li><a href="#fragment-1"><span>Product Reviews</span></a></li>
<li><a href="#fragment-2"><span>Notification</span></a></li> 
<li><a href="#fragment-3"><span>Also Purchased</span></a></li> 
</ul> 
<div id="fragment-1"><?php
// BEGIN PopTheTop Product Info Reviews
?>
				 <TD ALIGN="left">
</TD>      
<?php
	  $reviews_query = tep_db_query("select count(*) as count from " . TABLE_REVIEWS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
	  $reviews = tep_db_fetch_array($reviews_query);
	  $reviews_query_average = tep_db_query("select (avg(reviews_rating)) as average_rating from " . TABLE_REVIEWS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
	  $reviews_average = tep_db_fetch_array($reviews_query_average);
	  $reveiws_stars = $reviews_average['average_rating'];
	  $reveiws_rating = number_format($reveiws_stars,0);
?>
     <tr>
       <td></td>
     </tr>
<?php
if (MAX_REVIEWS_IN_PRODUCT_INFO > 0) {
 $reviews_query = tep_db_query("select r.reviews_id, rd.reviews_text, r.reviews_rating, r.date_added, r.customers_name from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd where r.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and rd.reviews_id = r.reviews_id and rd.languages_id = '" . $languages_id . "' order by r.reviews_id DESC");
 $num_rows = tep_db_num_rows($reviews_query);
?>
     <tr>
       <td>
	  <table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td valign="top"></td>
         </tr>
       </table>
	  </td>
     </tr>
<?php
 if ($num_rows > 0) {
   $row = 0;
   while (($reviews_values = tep_db_fetch_array($reviews_query)) && ($row < MAX_REVIEWS_IN_PRODUCT_INFO)) {
     $row++;
     $date_added = tep_date_short($reviews_values['date_added']);
	// Write product reviews
?>
<?php
// END PopTheTop Product Info Reviews
?>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
     	<td>
		<table border="0" width="100%" cellspacing="1" cellpadding="2">
			<tr>
				<td>
				<table border="0" width="100%" cellspacing="0" cellpadding="2">
					<tr>
						<td valign="top" class="main"><?php echo '<FONT COLOR="#006699"><b>Submited By:</b> ' . $reviews_values['customers_name'] . ' on <span class="smallText">' . $date_added . '</span></font><br>' . tep_break_string(nl2br(tep_output_string_protected($reviews_values['reviews_text'])), 60, '-<br>') . '<br><br>' . sprintf(tep_image(DIR_WS_IMAGES . 'stars_' . $reviews_values['reviews_rating'] . '.gif', sprintf(BOX_REVIEWS_TEXT_OF_5_STARS, $reviews_values['reviews_rating']))) ?></td>
					</tr>
				</table>
				</td>
			</tr>
		</table>
		</td>
     </tr>
<?php
   } // END while (($reviews_values...
?>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '15'); ?></td>
     </tr>
     <tr>
       <td>
       <table border="0" width="100%" cellspacing="1" cellpadding="2">
        <tr>
        		<td>
        		<table border="0" width="100%" cellspacing="0" cellpadding="2">
					<tr>
						<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
						<TD ALIGN="left" VALIGN="middle" CLASS="buttonAction">
<?php
   if ($num_rows > MAX_REVIEWS_IN_PRODUCT_INFO) {
	echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, substr(tep_get_all_get_params(), 0, -1)) . '">' . tep_draw_button(IMAGE_BUTTON_REVIEWS) . '</a></td>';
	echo '							<TD ALIGN="right" VALIGN="middle" CLASS="main"><a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, substr(tep_get_all_get_params(), 0, -1)) . '">' . tep_draw_button(IMAGE_BUTTON_REVIEWS) . '</a></td>';
	echo '							<td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') . '</td>';
 } else {
	echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, substr(tep_get_all_get_params(), 0, -1)) . '">' . tep_draw_button(IMAGE_BUTTON_REVIEWS) . '</a></td>';
 }
?>
					</tr>
				</table>
				</td>
        </tr>
       </table>
	  </td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td>
     </tr>
<?php
   if ($reviews['count'] > 0) {
?>
     <tr>
     	<td class="smallText">
     	<table width="100%">
			<tr>
				<td align="left" class="smallText"><FONT COLOR="#006699"><?php echo TEXT_REVIEW_AVERAGE . ': ' . tep_image(DIR_WS_IMAGES . 'stars_' . $reveiws_rating . '.gif', '', 60, 12, 'align=absmiddle') . '</a>'; ?></font></td>
				<td align="right" class="smallText"><FONT COLOR="#006699"><?php echo sprintf(TEXT_DISPLAY_NUMBER_OF_REVIEWS_PRODUCT_INFO, $row, $num_rows); ?></font></td>
			</tr>
		</table>
		</td>
	</tr>
<?php
   } else {
?>
     <tr>
       <td class="smallText"><FONT COLOR="#006699"><?php echo sprintf(TEXT_DISPLAY_NUMBER_OF_REVIEWS_PRODUCT_INFO, $row, $num_rows); ?></font></td>
     </tr>
<?php
   }
?>

<?php
   } else { // if ($num_rows < 0)...
?>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td>
     </tr>
     <tr>
     	<td>
		<table border="0" width="100%" cellspacing="1" cellpadding="2">
			<tr>
				<td>
				<table border="0" width="100%" cellspacing="0" cellpadding="2">
					<tr>
						<td valign="top" class="buttonAction"><?php echo TEXT_NO_REVIEWS . '<br><a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, substr(tep_get_all_get_params(), 0, -1)) . '">' . tep_draw_button(IMAGE_BUTTON_REVIEWS) . '</a>'; ?></td>
					</tr>
				</table>
				</td>
			</tr>
		</table>
		</td>
     </tr>
<?php
 }
}
// END PopTheTop Product Info Reviews
?></div> 
<div id="fragment-2">
<?php

   if (tep_session_is_registered('customer_id'))
   {
     $check_query = tep_db_query("select count(*) as count from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . (int)$customer_id . "' and global_product_notifications = '1'");
     $check = tep_db_fetch_array($check_query);
     if ($check['count'] <= 0)
     {
     $check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and customers_id = '" . (int)$customer_id . "'");
     $check = tep_db_fetch_array($check_query);

     if($check['count'] > 0)
       echo '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=notify_remove', $request_type) . '">' . tep_image(DIR_WS_IMAGES . 'checked.gif', IMAGE_BUTTON_REMOVE_NOTIFICATIONS) . '</a> <a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=notify_remove', $request_type) . '">' . sprintf(BOX_NOTIFICATIONS_NOTIFY, tep_get_products_name($HTTP_GET_VARS['products_id'])) .'</a>';
     else
       echo '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=notify', $request_type) . '">' . tep_image(DIR_WS_IMAGES . 'unchecked.gif', IMAGE_BUTTON_NOTIFICATIONS) . '</a> <a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=notify', $request_type) . '">' . sprintf(BOX_NOTIFICATIONS_NOTIFY, tep_get_products_name($HTTP_GET_VARS['products_id'])) .'</a>';
     }
   }
   else
   {
     echo '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=notify', $request_type) . '">' . tep_image(DIR_WS_IMAGES . 'unchecked.gif', IMAGE_BUTTON_NOTIFICATIONS) . '</a> <a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=notify', $request_type) . '">' . sprintf(BOX_NOTIFICATIONS_NOTIFY, tep_get_products_name($HTTP_GET_VARS['products_id'])) .'</a>';
   }
?></div> 
<div id="fragment-3"><?php include(DIR_WS_MODULES . 'also_purchased_products.php'); ?></div>
</div> 
<!--/tabs--> 

 

I appreciate any help :)

- James

Link to comment
Share on other sites

where is your product attributes code ?

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

No, don't worry about what goes in the tab, im looking to have the <li>, which with the jquery css creates a tab, disappear if there is no data. Here is a better example, i want to show "also purchased" in a tab,(<li>). If there were nothing to show, i don't want the tab to be displyed.

 

Thanks!

Link to comment
Share on other sites

you have to figure out how the valid records are retrieved for your particular query, very similar to the code you have

here:

     $check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and customers_id = '" . (int)$customer_id . "'");
     $check = tep_db_fetch_array($check_query);

     if($check['count'] > 0)
      ...

 

basically, you take the sql statement and replace the "select field_x, y z ... from"

with "select count(*) as count from"

then you run the query and check if you have any records returned.

 

In the tabs contribution, you then put this check around the generation of the list item code e.g.

<li><a href="#fragment-3"><span>Also Purchased</span></a></li> 

 

so your code follows this scheme:

 

     $check_query = tep_db_query("select count(*) as count from " . ... replace from and where clause...");
     $check = tep_db_fetch_array($check_query);

     if($check['count'] > 0){
?>
       <li><a href="#fragment-3"><span>Also Purchased</span></a></li> 
<?php
     }

 

In the actual content generation, you could also put this check before executing the section, so you don't rerun the query for the details, if you already know from the top that there is no data.

Mind if you use this "check" construction, to use different names if you plan on re-using the results further down the page ...

 

Hope I'm not being to cryptic and this does make sense to you :)

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

Super!! It works!! i had to do some digging to make it completely work but here is my code.

 

<?php
$orders_query = tep_db_query("select p.products_id, p.products_image from " . TABLE_ORDERS_PRODUCTS . " opa, " . TABLE_ORDERS_PRODUCTS . " opb, " . TABLE_ORDERS . " o, " . TABLE_PRODUCTS . " p where opa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and opa.orders_id = opb.orders_id and opb.products_id != '" . (int)$HTTP_GET_VARS['products_id'] . "' and opb.products_id = p.products_id and opb.orders_id = o.orders_id and p.products_status = '1' group by p.products_id order by o.date_purchased desc limit " . MAX_DISPLAY_ALSO_PURCHASED);
   $num_products_ordered = tep_db_num_rows($orders_query);
     if ($num_products_ordered >= MIN_DISPLAY_ALSO_PURCHASED){
echo '<li>' . '<a href="#fragment-4"><span>' . 'Also Purchased' . '</span></a></li>'; 
     } else { }?>

 

Thanks bruyndoncx for all your help!!!!

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...