Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Template "New Products For Month" ...


Recommended Posts

Here is the first draft of the template structure for the "New Products For Month" module in the front page of most osCommerce sites;

 

1.  change /includes/modules/new_products.php to:

 

 

<?php
/*
  $Id$

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

  Copyright (c) 2014 osCommerce

  Released under the GNU General Public License
*/

  if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
    $new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
  } else {
    $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
  }

  $num_new_products = tep_db_num_rows($new_products_query);
  
  if ($num_new_products > 0) {

    echo '<h3>' . sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')) . '</h3>';

    echo '<div class="row">';
    while ($new_products = tep_db_fetch_array($new_products_query)) {
      include(DIR_WS_MODULES . 'templates/new_products.php');
    }
    echo '</div>';
  }

2. Make a new folder called "templates" inside of the existing modules folder. /includes/modules/templates/

 

3. Inside that new folder, make a new file called new_products.php

 

4. In that new file, paste the following:

 

<div class="col-sm-6 col-md-4">
  <div class="thumbnail equal-height">
    <?php echo '<a href="' . tep_href_link('product_info.php', 'products_id=' . (int)$new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>'; ?>
    <div class="caption">
      <p class="text-center"><?php echo '<a href="' . tep_href_link('product_info.php', 'products_id=' . (int)$new_products['products_id']) . '">' . $new_products['products_name'] . '</a>'; ?></p>
      <hr>
      <p class="text-center"><?php echo $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])); ?></p>
      <div class="text-center">
        <div class="btn-group">
          <?php echo '<a href="' . tep_href_link('product_info.php', tep_get_all_get_params(array('action')) . 'products_id=' . (int)$new_products['products_id']) . '" class="btn btn-default" role="button">' . SMALL_IMAGE_BUTTON_VIEW . '</a>'; ?>
          <?php echo '<a href="' . tep_href_link('index.php', tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . (int)$new_products['products_id']) . '" class="btn btn-success" role="button">' . SMALL_IMAGE_BUTTON_BUY . '</a>'; ?>
        </div>
      </div>
    </div>
  </div>
</div>
So far so good. Refresh the index page of your site a few times. Any changes? Should be zero change.

 

5. Open up that new template file, and change it to:

 

<div class="col-sm-3">
  <h1><?php echo '<a href="' . tep_href_link('product_info.php', 'products_id=' . (int)$new_products['products_id']) . '">' . $new_products['products_name'] . '</a>'; ?></h1>
  <h2><?php echo $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])); ?></h2>      
</div>
Once again, refresh the index page. Any changes?

 

In this way, shopowners and developers can amend the look of the module without having to touch core code. Any thoughts and feedback would be appreciated.

Link to comment
Share on other sites

First, Happy New Year.

 

I'll test the code out on a 2.3.4 shop later after a morning coffee, but this is along what the content modules concept is, if I have that correct.  So basically no need to do anything with the modules, because the data calling, design is done in the template files.

 

So if I have that all correct, this is the way to go.  Great.

I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Link to comment
Share on other sites

Happy New Year @@burt and all

 

 

yes this is the best way. One note for template structure would be better in a separated folders.

example:

 

catalog/templates/basic/modules/new_products.php

catalog/templates/basic/index.php

:blink:
osCommerce based shop owner with minimal design and focused on background works. When the less is more.
Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store.

Link to comment
Share on other sites

So just for the sake of discussion,  it seems that total modularization of new_products.php would would be desirable to some shop owners.  Meaning they could remove it if they like from admin.

 

I recall many topics on this subject of how to remove new products with solutions being given to comment out the line that call's new_products.php and/or modify that module to a "featured products" as one or more add on allows.  I think this comes about in shops where perhaps the product turn over isn't great and the "What's New" ends up showing products that have been in the shop for quite some time.  Years even.

 

new_products.php is convenient though in that  results are automatically generated and probably works for high product turn over shops.

 

Anyway, that's all aside from what you laid out here with the template introduction for the module.

I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Link to comment
Share on other sites

@@burt

 

Tested it in an unmodified and a heavily modified BS shop. Works fine in both full and collapsed view.

 

I agree with altoid that the New Products module should be removable from the admin. In the german forum I answered a million times the question of users how to remove it from the start page...

 

J.J.

Link to comment
Share on other sites

I agree with everyone who suggested this be a content module. Why go only half way? Either leave the template changes for later or make the page modular.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Thanks for testing chaps :thumbsup:

 

For those who want "more", how about coding it up and giving it back to the community ?

 

I'll man the testing station in the meanwhile. 

I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Link to comment
Share on other sites

  • 3 weeks later...

Wouldnt it be nice if there was a module for the front page that suited everyones needs - selectable from Admin...

 

One that could show new products, or Featured products, or my personal favourite Categories images as per @kymations non-bs version.

 

maybe one day someone will fund its development and contribute it back

Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Link to comment
Share on other sites

@@Mort-lemur - that's the reason why we're introducing modular pages (index.php is next, followed by product_info.php). Then the shopowner can do as is done in (eg) the footer area. Drop in a new module, turn it on, set the sort order...done...and he/she had to alter no core code at all.

 

Working towards it, but incredible resistance to change is hurting development :(

Link to comment
Share on other sites

@@Mort-lemur - that's the reason why we're introducing modular pages (index.php is next, followed by product_info.php). Then the shopowner can do as is done in (eg) the footer area. Drop in a new module, turn it on, set the sort order...done...and he/she had to alter no core code at all.

 

Working towards it, but incredible resistance to change is hurting development :(

 

is the fully modular version going to be in 2.4? and is it going to have the sort of template idea you posted above?

so you load modules, then if you need to change anything, you just create your template file, rather than creating an entire new module each time.

 

Fully modular index would be great. Who is resisting the changes? I would of thought these ideas would be implemented as a neccessity since they are so good and will make things easier in the future, and also since a lot of great work has already been done with making oscommerce responsive out of the box.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...