Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Must login to view extra Field OSC2.3.4


wai4u2my

Recommended Posts

Posted
Help!!!!

 

I added extra field to product description and only allow login customer to view.  I managed to modified the sql and admin, but the front store stop at the production description not calling the side boxes & footer.

 

Wonder anybody know how to solve this.

 

 

Thanks

 

product_info.php

 

<?php

/*

  $Id$

 

  osCommerce, Open Source E-Commerce Solutions


 

  Copyright © 2014 osCommerce

 

  Released under the GNU General Public License

*/

 

  require('includes/application_top.php');

 

  if (!isset($HTTP_GET_VARS['products_id'])) {

    tep_redirect(tep_href_link(FILENAME_DEFAULT));

  }

 

  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 ($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']));

    }

 

    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'];

    }

?>

 

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

 

<div>

  <h1 style="float: right;"><?php echo $products_price; ?></h1>

  <h1><?php echo $products_name; ?></h1>

</div>

 

<div class="contentContainer">

  <div class="contentText">

 

<?php

    if (tep_not_null($product_info['products_image'])) {

      $photoset_layout = '1';

 

      $pi_query = tep_db_query("select image, htmlcontent from " . TABLE_PRODUCTS_IMAGES . " where products_id = '" . (int)$product_info['products_id'] . "' order by sort_order");

      $pi_total = tep_db_num_rows($pi_query);

 

      if ($pi_total > 0) {

        $pi_sub = $pi_total-1;

 

        while ($pi_sub > 5) {

          $photoset_layout .= 5;

          $pi_sub = $pi_sub-5;

        }

 

        if ($pi_sub > 0) {

          $photoset_layout .= ($pi_total > 5) ? 5 : $pi_sub;

        }

?>

 

    <div id="piGal">

 

<?php

        $pi_counter = 0;

        $pi_html = array();

 

        while ($pi = tep_db_fetch_array($pi_query)) {

          $pi_counter++;

 

          if (tep_not_null($pi['htmlcontent'])) {

            $pi_html[] = '<div id="piGalDiv_' . $pi_counter . '">' . $pi['htmlcontent'] . '</div>';

          }

 

          echo tep_image(DIR_WS_IMAGES . $pi['image'], '', '', '', 'id="piGalImg_' . $pi_counter . '"');

        }

?>

 

    </div>

 

<?php

        if ( !empty($pi_html) ) {

          echo '    <div style="display: none;">' . implode('', $pi_html) . '</div>';

        }

      } else {

?>

 

    <div id="piGal">

      <?php echo tep_image(DIR_WS_IMAGES . $product_info['products_image'], addslashes($product_info['products_name'])); ?>

    </div>

 

<?php

      }

    }

?>

 

<script type="text/javascript">

$(function() {

  $('#piGal').css({

    'visibility': 'hidden'

  });

 

  $('#piGal').photosetGrid({

    layout: '<?php echo $photoset_layout; ?>',

    width: '250px',

    highresLinks: true,

    rel: 'pigallery',

    onComplete: function() {

      $('#piGal').css({ 'visibility': 'visible'});

 

      $('#piGal a').colorbox({

        maxHeight: '90%',

        maxWidth: '90%',

        rel: 'pigallery'

      });

 

      $('#piGal img').each(function() {

        var imgid = $(this).attr('id').substring(9);

 

        if ( $('#piGalDiv_' + imgid).length ) {

          $(this).parent().colorbox({ inline: true, href: "#piGalDiv_" + imgid });

        }

      });

    }

  });

});

</script>

 

<?php echo stripslashes($product_info['products_description']); ?>

 

 

<?php

global $customer_id;

if ( defined( LOGIN_TO_VIEW_EFIELD ) && ( LOGIN_TO_VIEW_EFIELD == 'true' ) && (! tep_session_is_registered('customer_id') ) ) {

        return TEXT_LOG_IN_TO_VIEW_EXTRA_FIELD;

}

 

 

 // START: Extra Fields Contribution v2.0b - mintpeel display fix

   

                      $extra_fields_query = tep_db_query("

SELECT pef.products_extra_fields_order, pef.products_extra_fields_status as status, pef.products_extra_fields_name as name, ptf.products_extra_fields_value as value

FROM ". TABLE_PRODUCTS_EXTRA_FIELDS ." pef

LEFT JOIN ". TABLE_PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS ." ptf

ON ptf.products_extra_fields_id=pef.products_extra_fields_id

WHERE ptf.products_id=". (int)$HTTP_GET_VARS['products_id'] ." and ptf.products_extra_fields_value<>'' and (pef.languages_id='0' or pef.languages_id='".(int)$languages_id."')

ORDER BY pef.products_extra_fields_order");

 

 

        echo '<tr>

 <td>

 <table border="0" width="50%" cellspacing="0" cellpadding="2px">';

  while ($extra_fields = tep_db_fetch_array($extra_fields_query)) {

        if (! $extra_fields['status'])  // show only enabled extra field

           continue;

     echo'<tr><td class="main" align="left" valign="middle"><font size="1" color="#666666"><b>'.$extra_fields['name'].': </b>' . stripslashes($extra_fields['value']).'</font></td></tr>';

  }

  

     echo' </table>

 </td>

      </tr>'; 

       // END: Extra Fields Contribution - mintpeel display fix

 

?>

 

<?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) {

?>

 

    <p><?php echo TEXT_PRODUCT_OPTIONS; ?></p>

 

    <p>

<?php

      $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name 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 . "' order by popt.products_options_name");

      while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {

        $products_options_array = array();

        $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'");

        while ($products_options = tep_db_fetch_array($products_options_query)) {

          $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);

          if ($products_options['options_values_price'] != '0') {

            $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';

          }

        }

 

        if (is_string($HTTP_GET_VARS['products_id']) && isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) {

          $selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']];

        } else {

          $selected_attribute = false;

        }

?>

      <strong><?php echo $products_options_name['products_options_name'] . ':'; ?></strong><br /><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?><br />

<?php

      }

?>

    </p>

 

<?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 . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd where r.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and r.reviews_id = rd.reviews_id and rd.languages_id = '" . (int)$languages_id . "' and reviews_status = 1");

    $reviews = tep_db_fetch_array($reviews_query);

?>

 

  <div class="buttonSet">

    <span class="buttonAction"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_draw_button(IMAGE_BUTTON_IN_CART, 'cart', null, 'primary'); ?></span>

 

    <?php echo tep_draw_button(IMAGE_BUTTON_REVIEWS . (($reviews['count'] > 0) ? ' (' . $reviews['count'] . ')' : ''), 'comment', tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params())); ?>

  </div>

 

<?php

    if ((USE_CACHE == 'true') && empty($SID)) {

      echo tep_cache_also_purchased(3600);

    } else {

      include(DIR_WS_MODULES . FILENAME_ALSO_PURCHASED_PRODUCTS);

    }

?>

 

</div>

 

</form>

 

<?php

  }

 

  require(DIR_WS_INCLUDES . 'template_bottom.php');

  require(DIR_WS_INCLUDES . 'application_bottom.php');

?>

Posted

@@wai4u2my

 

I'm not familiar with this contribution but it looks like you are able to define whether it can be viewed or not.

if ( defined( LOGIN_TO_VIEW_EFIELD ) && ( LOGIN_TO_VIEW_EFIELD == 'true' ) && (! tep_session_is_registered('customer_id') ) ) {
        return TEXT_LOG_IN_TO_VIEW_EXTRA_FIELD;

Is there a setting to control whether you can view it or not?  Perhaps a setting on the admin side of the shop or some way to configure it that is mentioned in the instructions?

 

Dan

Posted

Hi Dan,

 

Yes, in admin there is a control setting and I can manage it.

 

In the product__info.php srcipt should have a massage asking customer to login for further info. The problem is that if the customer login the script is ok they can call the further info out, but if the customer does not login the product info page should have a massage telling them to login for further detail, this not working.

 

I donnot know where goes wrong on the return...script

 

Wai

Posted

Hi

 

The code looks OK but I'm not so sure the return works there as I think it has been pulled in from a class or function file (hence the global $customer_id??) - try this:

<?php

if ( defined( LOGIN_TO_VIEW_EFIELD ) && ( LOGIN_TO_VIEW_EFIELD == 'true' ) && (! tep_session_is_registered('customer_id') ) ) {
       echo TEXT_LOG_IN_TO_VIEW_EXTRA_FIELD;//<--change return to echo
}else{//<--add all the stuff after the original }
 
 
 // START: Extra Fields Contribution v2.0b - mintpeel display fix
   
                      $extra_fields_query = tep_db_query("
SELECT pef.products_extra_fields_order, pef.products_extra_fields_status as status, pef.products_extra_fields_name as name, ptf.products_extra_fields_value as value
FROM ". TABLE_PRODUCTS_EXTRA_FIELDS ." pef
LEFT JOIN ". TABLE_PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS ." ptf
ON ptf.products_extra_fields_id=pef.products_extra_fields_id
WHERE ptf.products_id=". (int)$HTTP_GET_VARS['products_id'] ." and ptf.products_extra_fields_value<>'' and (pef.languages_id='0' or pef.languages_id='".(int)$languages_id."')
ORDER BY pef.products_extra_fields_order");
 
 
        echo '<tr>
 <td>
 <table border="0" width="50%" cellspacing="0" cellpadding="2px">';
  while ($extra_fields = tep_db_fetch_array($extra_fields_query)) {
        if (! $extra_fields['status'])  // show only enabled extra field
           continue;
     echo'<tr><td class="main" align="left" valign="middle"><font size="1" color="#666666"><b>'.$extra_fields['name'].': </b>' . stripslashes($extra_fields['value']).'</font></td></tr>';
  }
  
     echo' </table>
 </td>
      </tr>'; 
       // END: Extra Fields Contribution - mintpeel display fix
 }//<-- extra closing bracket
?>
Posted

Hi Dan & Bob,

 

Firstly I would like to thank Bob, the problem solve.

 

And also thanks to Dan and below the addons I used.

 

The main purpose is to add an extra field in the product description only for login customers.

 

1. http://addons.oscommerce.com/info/7810  

 

to add extra fields in product description

 

2. http://addons.oscommerce.com/info/8325 

 

Modified from the following only show the extra field for login customers only

 

3. http://addons.oscommerce.com/info/8523/v,23

 

To screen customer before allow them to access the site.

 

The whole purpose is to prevent competitor to obtain info from the store.

 

Once again.. Thanks guys

Archived

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

×
×
  • Create New...