Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

A friend of mine asked me recently if I knew a Price List addon that works with osC 2.3.4
I told him that it must exist since it is an important tool for some shops. Well, I was partially wrong.
There was no price list specific addon available that worked with 2.3.4 so I did more digging and found Jacks All Products SEO addon
which contains a price list which he again, in the support topic only, updated but did not upload to the addons area.

I took his updated version re-worked it for osC 2.3.4 first and then converted it to Bootstrap.

Thanks to @@ArtcoInc for the Print Styles :D and kudos to @@Jack_mcs for the codes.
And here it is. (screenshot)

 

create new file, name it price_list.php and place it inside the root or catalog folder.

<?php
/*
$Id: Price List BS | price_list.php 

osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2015 osCommerce
Released under the GNU General Public License

*/
require('includes/application_top.php');

// the following cPath references come from application_top.php
$category_depth = 'top';
if (isset($cPath) && tep_not_null($cPath)) {
$categories_products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");
$cateqories_products = tep_db_fetch_array($categories_products_query);
if ($cateqories_products['total'] > 0) {
  $category_depth = 'products'; // display products
} else {
  $category_parent_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$current_category_id . "'");
  $category_parent = tep_db_fetch_array($category_parent_query);
  if ($category_parent['total'] > 0) {
   $category_depth = 'nested'; // navigate through the categories
  } else {
   $category_depth = 'products'; // category has no products, but display the 'no products' message
  }
}
}

$breadcrumb->add(TITLE_PRICE, tep_href_link('price_list.php'));
 
 require(DIR_WS_INCLUDES . 'template_top.php');
?>


<?php // SETTINGS FOR PRICE LIST	
define('PRICE_LIST_SHOW_MODEL',true); // true - show model, false - hide model
define('PRICE_LIST_SHOW_PRICE',true); // true - show price, false - hide price
define('PRICE_LIST_SHOW_QTY',true); // true - show quantity, false - hide quantity
define('PRICE_LIST_SHOW_OUT_OF_STOCK',false); // true - show out of stock products, false - hide out of stock products
?>
<style>
/* Print Styles */
@[member='media'] print {

#columnLeft {display:none;}
#columnRight {display:none;}
#bs-navbar-collapse-1 {display:none;}
.navbar {display:none;}
.footer {display:none;}
.footer-extra {display:none;}
.breadcrumb {display:none;}
.panel {display:none;}
.panel.panel-default {display:none;}
.buttonSet {display:none;}
#buttonAction {display:none;}
.searchbox-margin {display:none;}
.header {display:none;}
.btn {display:none;}
a[href]:after {content: none;}

}
</style>
<?php
// group have products?
function PL_CheckProducts($id_group){
    $products_price_query = tep_db_query("select products_to_categories.products_id FROM products_to_categories where products_to_categories.categories_id = ".$id_group." LIMIT 0,1");
    if ($products_price = tep_db_fetch_array($products_price_query)) {
        return true;
    }
    return false;
}


// list products determined group
function PL_GetProducts($id_group, $width) {
    global $currencies, $languages_id;
    $query = "";
    
    if(PRICE_LIST_SHOW_OUT_OF_STOCK == 'false') {
        $query = " and p.products_status = 1";
    }
    
    $listing_sql = "select distinct pd.products_name, p.products_quantity, p.products_price, p.products_model, p2c.products_id, p2c.categories_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, p.products_tax_class_id FROM " .
      TABLE_PRODUCTS . " p inner join " . 
      TABLE_PRODUCTS_DESCRIPTION ." pd on p.products_id = pd.products_id left join " . 
      TABLE_SPECIALS . " s on p.products_id = s.products_id inner join " .
      TABLE_PRODUCTS_TO_CATEGORIES . " p2c on p2c.products_id = p.products_id 
      where p2c.categories_id = " . (int)$id_group . $query . " and pd.language_id = '" . $languages_id . "' order by pd.products_name";

    $products_query = tep_db_query($listing_sql);
   

    
    while ($products = tep_db_fetch_array($products_query)) {
        $cell = tep_get_products_special_price($products_price['products_id']);

        if($cell == 0) {
            $cell = $products['products_price'];
        }

		echo '<tr>';
		
		echo '<td class="col-sm-2"> </td>';
		
        if(PRICE_LIST_SHOW_QTY == 'true') {
            echo '<td class="col-sm-1 text-center">(' . $products['products_quantity'] . ')</td>';
        }

        if (PRICE_LIST_SHOW_MODEL == 'true') {
            echo '<td class="col-sm-2 text-center">' . $products['products_model'] . '</td>';
        }

        echo '<td class="col-sm-5"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, "products_id=" . $products['products_id']) . '">' . str_replace(" ", " ", strip_tags($products['products_name'])) . '</a></td>'; 
        
        if (PRICE_LIST_SHOW_PRICE == 'true') {
            echo '<td class="col-sm-2 text-right">';
            if (tep_not_null($products['specials_new_products_price'])) {
                echo '<del>' .  $currencies->display_price($products['products_price'], tep_get_tax_rate($products['products_tax_class_id'])) . '</del>  <span style="color:#ff2800;">' . $currencies->display_price($products['specials_new_products_price'], tep_get_tax_rate($products['products_tax_class_id'])) . '</span>';
            } else {   
                echo $currencies->display_price($products['products_price'], tep_get_tax_rate($products['products_tax_class_id']));
            }            
        }    

        echo '</tr>'; 
    }
}

// get all groups
function PL_GetGroup($id_parent, $position){
    global $languages_id;
    
    $groups_price_query = tep_db_query("select c.categories_id, cd.categories_name from " . TABLE_CATEGORIES . " c left join " . TABLE_CATEGORIES_DESCRIPTION . " cd on c.categories_id = cd.categories_id where c.parent_id = " . (int)$id_parent . " and cd.language_id = " . (int)$languages_id . " order by c.sort_order");
    $titleShown = false;

    while ($groups_price = tep_db_fetch_array($groups_price_query)) {
       $catpad = "";
       $catPad = str_replace(" ", "  ", str_pad($catPad, ($position * 3), " ", STR_PAD_LEFT)); //pad str wont accept   so prefill and replace

       if($position == 0 && ! $titleShown) {
            $titleShown = true;        
            
            echo '<thead bgcolor="#eee"><tr>';
        
			echo '<th> </th>';
            
			if (PRICE_LIST_SHOW_QTY == 'true') {
                echo '<th class="text-center">' . PRICE_HEADING_STOCK . '</th>';
            }
            
            if (PRICE_LIST_SHOW_MODEL == 'true') {
                echo '<th class="text-center">' . PRICE_HEADING_MODEL . '</th>';
            }
            
            echo '<th>' . PRICE_HEADING_PRODUCT . '</th>';

            if (PRICE_LIST_SHOW_PRICE == 'true') {
                echo '<th class="text-right">' . PRICE_HEADING_PRICE . '</th>';
            }
            
            echo '</tr></thead>';
       }

       if (PL_CheckProducts($groups_price['categories_id']) || $position == 0){
            echo '<tr>
					<td bgcolor="#bcdfeb" colspan="6">
						<strong>' . $catPad . $groups_price['categories_name'] . '</strong>
					</td>
				  </tr>';
            PL_GetProducts($groups_price['categories_id'], '');
       }
       
       PL_GetGroup($groups_price['categories_id'],$position+1);
    }
}
?>

	<div class="row clearfix">
		<div class="col-xs-8">
			<h3><?php echo TITLE_PRICE . ' ' . date("Y"); ?></h3>
		</div>
		<div class="col-xs-4 text-right">
			<a class="btn btn-default" role="submit" title="Print Price List" onClick="window.print()"><?php echo PRINT_PRICE_LIST; ?></a>
		</div>	
	</div>
		<div class="text-right">
			<?php echo date("Y-m-d"); ?>
		</div>
	    <table class="table table-condensed table-responsive table-hover">
		 <?php
		  PL_GetGroup(0,0);
		 ?>
	    </table>

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

add the following lang definitions inside the english.php

// BOF Price List
define('TITLE_PRICE', 'Price List');
define('PRICE_HEADING_PRODUCT', 'PRODUCT');
define('PRICE_HEADING_MODEL', 'MODEL NO.');
define('PRICE_HEADING_PRICE', 'PRICE');
define('PRICE_HEADING_STOCK', 'STOCK');
define('BOX_INFORMATION_PRICE_LIST', 'View Price List');
define('PRINT_PRICE_LIST', '<i class="fa fa-print"></i> <span class="hidden-xs">Print List</span>');
// EOF Price List

place the following code there where you want to show the price list link

<!-- BOF PRICE LIST LINK //-->  
  <p><?php echo '<a href="' . tep_href_link('price_list.php') . '">' . BOX_INFORMATION_PRICE_LIST . '</a>'; ?></p>
<!-- EOF PRICE LIST LINK //-->
Link to comment
Share on other sites

Archived

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

×
×
  • Create New...