Dear all,
I was working on this idea, and with a little help we can have a pc configurator.
HERE's MY DEDICATED THREAD FOR THIS TOPIC:
http://www.zen-cart.com/forum/showthread.php?t=70184
I made a copy of product_listing.php from includes/modules and named it pc_configurator.php
Then, in the tpl_modules_product_listing.php, I made some changes so if the category I created and I want to use as configurator is showing, then we load the new file from modules -> pc_configurator.php instead of product_listing.php
I also added some new classes in the stylesheet.css to use for this purpose and some new...... SEE BELLOW SOME STEPS I MADE AND IF SOMEONE THINKS HE CAN HELP.....LETS TRY IT.
You can see what the diference is, comparing to other categories of my web site:
Compare this category with any other to see the difference:
http://www.lebrand.gr/eshop/index.ph...&cPath=116_137
Well, if I name this category PC CONFIGURATOR, and the add products with general names , to be the items, like CASE, HDD, VGA, FDD, DVD-RW DRIVE, MOTHERBOARD etc, then I can add ATTRIBUTES to all these parts with specific brands and charachteristics and prices, so then I have my configurator done.
The only thing remaining, is to show the cart on this page and prices change dinamically when I choose diferent attributes. Then I use the button "Add Selected Products to Cart" . THE GOOD THING IS THAT :
CUSTOMER CAN DELETE A SPECIFIC PART, AFTER HE HAS ADDED IT IN THE CART AND GO BACK TO CONFIGURATOR TO SELECT ANOTHER.
WE CAN EASILY MAKE A PRODUCT WITH MANY-MANY ATTRIBUTES LIKE THIS:
http://www.lebrand.gr/eshop/index.ph...products_id=26
TO USE IT AS A PC CONFIGURATOR BUT CUSTOMER COULD NOT DELETE A SPECIFIC PART. HE SHOULD DELETE THE PRODUCT AND BUILD IT FROM THE START !!!
THE NEW WAY IT IS EASIER !!! LETS MAKE A TEAM TO HAVE IT DONE !!!
Code:
define('FILENAME_PC_CONFIGURATOR', 'pc_configurator.php');
Code:
ALTER TABLE `products` ADD COLUMN `pc_configurator_sort_order` int(3) NOT NULL default '0' AFTER `metatags_title_tagline_status`;
ALTER TABLE `products` ADD COLUMN `pc_configurator_cpu_type` int(1) NOT NULL default '0' AFTER `pc_configurator_sort_order`;
ALTER TABLE `products` ADD COLUMN `pc_configurator_part_name` varchar(64) NOT NULL default '' AFTER `pc_configurator_cpu_type`;
ALTER TABLE `products` ADD COLUMN `pc_configurator_compatibility` int(1) NOT NULL default '0' AFTER `pc_configurator_part_name`;
ALTER TABLE `categories` ADD COLUMN `pc_configurator` int(1) NOT NULL default '0' AFTER `categories_status`;
Code:
INSERT INTO `configuration` VALUES ('',
'Activate PC Configurator / 1=on 0=off',
'PRODUCT_LIST_CONFIGURATOR',
'1',
'Set this to 1 if you are going to use PC Configurator. This will cause attributes to show on Product Listing<br /> PRODUCT_LIST_CONFIGURATOR',
8, 20, now(), now(), NULL, NULL);
Code:
INSERT INTO `configuration` VALUES ('',
'Display Category/Manufacturer Filter on PC Configurator / 1=on 0=off',
'PRODUCT_LIST_FILTER_CONFIGURATOR',
'1',
'Do you want to display the Category/Manufacturer Filter?<br /> PRODUCT_LIST_FILTER_CONFIGURATOR',
8, 21, now(), now(), NULL,
"zen_cfg_select_option(array('0', '1'),");
Code:
INSERT INTO `configuration` VALUES ('',
'Display Product Description PC Configurator / Set chars',
'PRODUCT_LIST_DESCRIPTION_CONFIGURATOR',
'1',
'Set the maximum charachters to display for product description on PC Configurator.<br /> PRODUCT_LIST_DESCRIPTION_CONFIGURATOR',
8, 22, now(), now(), NULL, NULL);
Code:
PC CONFIGURATOR
catalog/inculdes/modules/pc_configurator.php
<?php
require(DIR_WS_MODULES . zen_get_module_directory(FILENAME_ATTRIBUTES));
require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
?>
<?php
if (!defined('IS_ADMIN_FLAG')) {
die('Illegal Access');
}
$show_submit = zen_run_normal();
$listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_PRODUCTS_LISTING, 'p.products_id', 'page');
$how_many = 0;
// needs a better check v1.3.1
if (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != 0 and $show_submit == true and $listing_split->number_of_rows > 0) {
// bof: multiple products
// $chk_attributes = $db->Execute($listing_sql);
$chk_attributes = $db->Execute($listing_split->sql_query);
while (!$chk_attributes->EOF) {
if ($chk_attributes->fields['product_is_call'] == 0) {
if (zen_get_products_allow_add_to_cart($chk_attributes->fields['products_id']) !='N') {
if (zen_has_product_attributes($chk_attributes->fields['products_id']) < 1 and $chk_attributes->fields['products_type'] != 3) {
$how_many++;
}
}
}
$chk_attributes->MoveNext();
}
if ($how_many >= 1) {
echo zen_draw_form('multiple_products_cart_quantity', zen_href_link(FILENAME_DEFAULT, zen_get_all_get_params(array('action')) . 'action=multiple_products_add_product'), 'post', 'enctype="multipart/form-data"');
}
}
$list_box_contents[0] = array('params' => 'class="productConfigurator-rowheading"');
$zc_col_count_description = 0;
for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
switch ($column_list[$col]) {
case 'PRODUCT_LIST_MODEL':
$lc_text = TABLE_HEADING_MODEL;
$lc_align = '';
$zc_col_count_description++;
break;
case 'PRODUCT_LIST_NAME':
$lc_text = TABLE_HEADING_PRODUCTS;
$lc_align = '';
$zc_col_count_description++;
break;
case 'PRODUCT_LIST_MANUFACTURER':
$lc_text = TABLE_HEADING_MANUFACTURER;
$lc_align = '';
$zc_col_count_description++;
break;
case 'PRODUCT_LIST_PRICE':
$lc_text = TABLE_HEADING_PRICE;
$lc_align = 'right' . (PRODUCTS_LIST_PRICE_WIDTH > 0 ? '" width="' . PRODUCTS_LIST_PRICE_WIDTH : '');
$zc_col_count_description++;
break;
case 'PRODUCT_LIST_QUANTITY':
$lc_text = TABLE_HEADING_QUANTITY;
$lc_align = 'right';
$zc_col_count_description++;
break;
case 'PRODUCT_LIST_WEIGHT':
$lc_text = TABLE_HEADING_WEIGHT;
$lc_align = 'right';
$zc_col_count_description++;
break;
case 'PRODUCT_LIST_IMAGE':
$lc_text = TABLE_HEADING_IMAGE;
$lc_align = 'center';
$zc_col_count_description++;
break;
}
if ( ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) {
$lc_text = zen_create_sort_heading($_GET['sort'], $col+1, $lc_text);
}
$list_box_contents[0][$col] = array(
'align' => $lc_align,
'params' => 'class="productConfigurator-heading"',
'text' => $lc_text
);
}
if ($listing_split->number_of_rows > 0) {
$rows = 0;
$listing = $db->Execute($listing_split->sql_query);
$extra_row = 0;
while (!$listing->EOF) {
$rows++;
if ((($rows-$extra_row)/2) == floor(($rows-$extra_row)/2)) {
$list_box_contents[$rows] = array('params' => 'class="productConfigurator-even"');
} else {
$list_box_contents[$rows] = array('params' => 'class="productConfigurator-odd"');
}
$cur_row = sizeof($list_box_contents) - 1;
for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
$lc_align = '';
switch ($column_list[$col]) {
case 'PRODUCT_LIST_MODEL':
$lc_align = '';
$lc_text = $listing->fields['products_model'];
break;
case 'PRODUCT_LIST_NAME':
$lc_align = '';
if (isset($_GET['manufacturers_id'])) {
$lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'manufacturers_id=' . $_GET['manufacturers_id'] . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION_CONFIGURATOR) . '</div>' ;
} else {
// HERE BELLOW I TRIED MANY WAYS, BUT I CAN NOT LOAD PRODUCT ATTRIBUTES INSTEAD OF PRODUCT DESCRIPTION
// I JUST LOAD THE PRODUCT NAME WITHOUT LINK, BECAUSE THE LINK EXISTS ON THE IMAGE
// WITH THE 3 NEW CONFIGURATION FIELDS ADDED IN THE CONFIGURATION GROUP 8 ( Product Listing ) WE CAN HAVE DIFFERENT
// AMOUNT OF PRODUCT DESCRIPTION CHARACHTERS ONLY FOR PC CONFIGURATOR OR WE SET TO 0 NOT TO HAVE DESCRIPTION.
// THIS IS WHAT I TRIED, BECAUSE INSTEAD OF DESCRIPTION I WANTED TO ADD ATTRIBUTES.
// SO THIS WAY WE CAN HAVE A LIST OF PRODUCTS IN A SPECIFIC CATEGORY THAT THEY ONLY SHOW
// IF THEY ARE CHARACTERISED TO BE USED FOR PC CONFIGURATOR ( USING THE NEW FIELDS ADDED WHEN ADDING OR EDITING PRODUCT )
// NEXT STEP IS TO SHOW CART SPECIFICALLY IN THIS CATEGORY, AND PRICES TO CHANGE DINAMICALY
// WHEN WE CHOOSE DIFERENT ATTRIBUTES VALUES OF A PRODUCT.
// I KNOW THAT THIS COULD BE DONE IF WE ACT AS A TEAM - DO NOT JUST DOWNLOAD AND GO - TRY TO HELP THIS COMMUNITY
$lc_text = '<h4 class="itemTitle">'
. $listing->fields['products_name'] .
'</h4>'
. require($template->get_template_dir('/tpl_modules_attributes.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_attributes.php');
}
break;
case 'PRODUCT_LIST_MANUFACTURER':
$lc_align = '';
$lc_text = '<a href="' . zen_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing->fields['manufacturers_id']) . '">' . $listing->fields['manufacturers_name'] . '</a>';
break;
case 'PRODUCT_LIST_PRICE':
$lc_price = zen_get_products_display_price($listing->fields['products_id']) . '<br />';
$lc_align = 'right';
$lc_text = $lc_price;
$lc_button = TEXT_PRODUCT_LISTING_MULTIPLE_ADD_TO_CART . "<input type=\"text\" name=\"products_id[" . $listing->fields['products_id'] . "]\" value=\"0\" size=\"4\" />";
$the_button = $lc_button;
$products_link = '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'products_id=' . $listing->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
$lc_text .= '<br />' . zen_get_buy_now_button($listing->fields['products_id'], $the_button, $products_link) . '<br />' . zen_get_products_quantity_min_units_display($listing->fields['products_id']);
$lc_text .= '<br />' . (zen_get_show_product_switch($listing->fields['products_id'], 'ALWAYS_FREE_SHIPPING_IMAGE_SWITCH') ? (zen_get_product_is_always_free_shipping($listing->fields['products_id']) ? TEXT_PRODUCT_FREE_SHIPPING_ICON . '<br />' : '') : '');
break;
case 'PRODUCT_LIST_QUANTITY':
$lc_align = 'right';
$lc_text = $listing->fields['products_quantity'];
break;
case 'PRODUCT_LIST_WEIGHT':
$lc_align = 'right';
$lc_text = $listing->fields['products_weight'];
break;
case 'PRODUCT_LIST_IMAGE':
$lc_align = 'center';
if (isset($_GET['manufacturers_id'])) {
$lc_text = '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'manufacturers_id=' . $_GET['manufacturers_id'] . '&products_id=' . $listing->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $listing->fields['products_image'], $listing->fields['products_name'], IMAGE_PRODUCT_LISTING_WIDTH, IMAGE_PRODUCT_LISTING_HEIGHT) . '</a>';
} else {
$lc_text = '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $listing->fields['products_image'], $listing->fields['products_name'], IMAGE_PRODUCT_LISTING_WIDTH, IMAGE_PRODUCT_LISTING_HEIGHT) . '</a>';
}
break;
}
$list_box_contents[$rows][$col] = array('align' => $lc_align,
'params' => 'class="productConfigurator-data"',
'text' => $lc_text);
}
$listing->MoveNext();
}
$error_categories = false;
} else {
$list_box_contents = array();
$list_box_contents[0] = array('params' => 'class="productConfigurator-odd"');
$list_box_contents[0][] = array('params' => 'class="productConfigurator-data"',
'text' => TEXT_NO_PRODUCTS);
$error_categories = true;
}
if (($how_many > 0 and $show_submit == true and $listing_split->number_of_rows > 0) and (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART == 1 or PRODUCT_LISTING_MULTIPLE_ADD_TO_CART == 3) ) {
$show_top_submit_button = true;
} else {
$show_top_submit_button = false;
}
if (($how_many > 0 and $show_submit == true and $listing_split->number_of_rows > 0) and (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART >= 2) ) {
$show_bottom_submit_button = true;
} else {
$show_bottom_submit_button = false;
}
?>
TPL_MODULES_PRODUCT_LISTING.PHP
Code:
<?php
//THE FOLLOWING CAN GO TO A LANGUAGE FILE
define('PC_CONF_CUSTOMER_TITLE', 'Pc Configurator');
//THE FOLLOWING LINE CHECK TO SEE IF A SPECIFIC CATEGORY IS GOING TO BE USED FOR PC CONFIGURATOR
//AND THEN LOADS THE FILE pc_configurator.php INSTEAD OF product_listing.php FROM catalog/includes/modules DIRECTORY
//INSTEAD OF MAKING THIS KIND OF CHECK I AM PREPARING TO ADD SOME NEW COLUMNS IN TABLE PRODUCTS AND CATEGORIES SO I CAN QUERY AND HAVE A DIFERENT CHECK-BETTER
if ($cPath == '116_137') {
include(DIR_WS_MODULES . zen_get_module_directory(FILENAME_PC_CONFIGURATOR));
}else{
include(DIR_WS_MODULES . zen_get_module_directory(FILENAME_PRODUCT_LISTING));
}
?>
<div id="productListing">
<?php if ($cPath == '116_137') { ?>
<h1 id="indexCategoriesHeading"><?php echo PC_CONF_CUSTOMER_TITLE; ?></h1>
<?php } ?>
<?php
if ($cPath != '116_137') {
if ($show_top_submit_button == true) {
?>
<div class="buttonRow forward"><?php echo zen_image_submit(BUTTON_IMAGE_ADD_PRODUCTS_TO_CART, BUTTON_ADD_PRODUCTS_TO_CART_ALT, 'id="submit1" name="submit1"'); ?></div>
<br class="clearBoth" />
<?php
}
?>
<?php
}
?>
<?php
if ($cPath != '116_137') {
if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
?>
<div id="productsListingTopNumber" class="navSplitPagesResult back"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></div>
<div id="productsListingListingTopLinks" class="navSplitPagesLinks forward"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, zen_get_all_get_params(array('page', 'info', 'x', 'y', 'main_page'))); ?></div>
<br class="clearBoth" />
<?php
}
?>
<?php
}
?>
<?php
//FOR NOW tpl_tabular_configurator.php IS THE SAME WITH tpl_tabular_display.php
//BUT HERE WE ALSO CHECK AND LOAD A SPECIFIC TEMPLATE TO USE
//ALSO THIS KIND OF CHECK COULD BE WITH QUERY USING THE NEW COLUMNS FROM TABLE PRODUCTS AND CATEGORIES
if ($cPath == '116_137') {
require($template->get_template_dir('tpl_tabular_configurator.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_tabular_configurator.php');
}else{
require($template->get_template_dir('tpl_tabular_display.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_tabular_display.php');
}
?>
<?php
if ($cPath != '116_137') {
if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
?>
<div id="productsListingBottomNumber" class="navSplitPagesResult back"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></div>
<div id="productsListingListingBottomLinks" class="navSplitPagesLinks forward"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, zen_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></div>
<br class="clearBoth" />
<?php
}
?>
<?php
}
?>
<?php
if($cPath == '116_137') {
if( $show_bottom_submit_button == true) {
?>
<div class="buttonRow forward"><?php echo zen_image_submit(BUTTON_IMAGE_ADD_PRODUCTS_TO_CART, BUTTON_ADD_PRODUCTS_TO_CART_ALT, 'id="submit2" name="submit1"'); ?></div>
<br class="clearBoth" />
<?php
}
?>
</div>
<?php
if ($show_top_submit_button == true or $show_bottom_submit_button == true) {
?>
</form>
<?php } ?>
HERE's MY DEDICATED THREAD FOR THIS TOPIC:
http://www.zen-cart.com/forum/showthread.php?t=70184
Bookmarks