Re: PC Configurator For Zen Cart
Best Chris,
Just to make any sort of sense in this extremly difficult mod, please post a complete install pack, not just some jumping from page to page. Then maybe some real good coder could get the hang of this, and help you out with it, because as it is now its very hard to keep track in the various changes. I'm not a coder but very interested in this mod and could maybe participate in some way.
Re: PC Configurator For Zen Cart
Hi,
would you mind to upload your module in to one new file? It would be very handy for beginners as well as for those who have fresh install. THX
Re: PC Configurator For Zen Cart
Well, I am using a FOR to loop within categories, that have been selected to paricipate in product configurator.
INSIDE this FOR loop, I am using a WHILE loop, to select all products from every category.
Before I close the FOR loop, I produce the drop down lists.
OLD configurator, was too much code.
This way, the NEW way, some lines of code do all the job.
Because of the reason I am too bussy, I did not manage to gather and pack the NEW version.
I also need to make changes for the next steps.
BUT, as there are many requests from many of you, for making this module to be working for any kind of product, I am here to listen to your ideas.
Maybe we can use some more JAVA script and AJAX to perform smart operations.
Just I need all of you, give me your ideas. How would you like a configurator to be etc.
As about configuring a PC there are issues about dependency between parts of it, so we have to write a function to check it.
I introduce the code that does the JOB , below
[file : includes/languages/english/html_includes/classic/define_configurator.php]:
<?php
// Instead using language file, language defines are below and you can change it to your language :
define('PRODUCT_DETAILS_LINK_TEXT', 'Product Details');
define('CONFIGURATOR_NET_PRICE_TEXT', 'Net Price : ');
define('CONFIGURATOR_TAX_PRICE_TEXT', 'Tax Price : ');
define('CONFIGURATOR_TOTAL_PRICE_TEXT', 'Total Price : ');
define('CONFIGURATOR_BUTTON_RESET_TEXT', 'Reset');
define('CONFIGURATOR_BUTTON_STEP_2_TEXT', 'Continue');
?>
<!-- Using custom STYLE for configurator page. You can make changes if needed-->
<STYLE type=text/css>
A.main:link { FONT-WEIGHT: bold; FONT-SIZE: 10px; COLOR: #000000; FONT-FAMILY: Verdana, Tahoma, Arial, GRHelvetica; TEXT-DECORATION: none }
A.main:visited { FONT-WEIGHT: bold; FONT-SIZE: 10px; COLOR: #000000; FONT-FAMILY: Verdana, Tahoma, Arial, GRHelvetica; TEXT-DECORATION: none }
A.main:hover { FONT-WEIGHT: bold; FONT-SIZE: 10px; COLOR: #454545; FONT-FAMILY: Verdana, Tahoma, Arial, GRHelvetica; TEXT-DECORATION: none }
.form { FONT-WEIGHT: normal; FONT-SIZE: 10px; COLOR: #000000; FONT-FAMILY: Verdana, Tahoma, Arial, GRHelvetica; }
TD.products_attributes_controler_conf { PADDING-RIGHT: 5px; PADDING-LEFT: 5px; FONT-WEIGHT: normal; FONT-SIZE: 10px; PADDING-BOTTOM: 2px; BORDER-LEFT: #ffffff 1px solid; WIDTH: 100%; COLOR: #000000; PADDING-TOP: 2px; BORDER-BOTTOM: #ffffff 1px solid; FONT-FAMILY: Verdana, Tahoma, Arial, GRHelvetica; BACKGROUND-COLOR: #cfcfcf }
TD.additional_value_tax { PADDING-RIGHT: 5px; PADDING-LEFT: 5px; FONT-WEIGHT: normal; FONT-SIZE: 10px; PADDING-BOTTOM: 2px; BORDER-LEFT: #ffffff 1px solid; COLOR: #ffffff; PADDING-TOP: 2px; BORDER-BOTTOM: #ffffff 1px solid; FONT-FAMILY: Verdana, Tahoma, Arial, GRHelvetica; BACKGROUND-COLOR: #5d5e61; }
TABLE.zen_table_conf { BORDER-RIGHT: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid; }
.configurator_select_element { FONT-WEIGHT: normal; FONT-SIZE: 9px; WIDTH: 80%; COLOR: #000000; FONT-FAMILY: Verdana, Tahoma, Arial, GRHelvetica; }
</STYLE>
<--!
The function below is for OLD version. It will change to work with new version
All it does, is to open a new window, and show only picture and prouct details, hidding HEADER, FOOTER and SIDEBOXES !!!
-->
<SCRIPT language=Javascript>
function display_product_details(productid) {
if (productid==0)
return;
if (productid.indexOf("CONFIGURATOR")!=-1)
{
var product_details_link = "index.php?main_page=product_info_pc_configurator&products_id=" + productid + "&hide_header_left_right_footer=1"
}
window.open(product_details_link,"",'fullscreen=yes,resizable=no,toolbar=no,scro llbars=yes,status=no,titlebar=0');
}
<!--
The function below, is just parsing the product value to the right input element when we select a product
from a drop down list, and also update the NET PRICE, TAX PRICE and TOTAL PRICE
-->
function change_price_when_selected(where,value) {
var price = parseFloat(value);
if (!value){
price = 0;
}
var option_attribute= where+"_name";
var option_attribute_value= where+"_price";
document.ConfiguratorForm.elements[option_attribute_value].value = price;
var amount = 0;
var i=0;
for (i=0; i < document.ConfiguratorForm.elements.length-1 ;i++) {
if ((document.ConfiguratorForm.elements[i].type=="text") && (document.ConfiguratorForm.elements[i].name.indexOf("_price")!=-1) ) {
amount += parseFloat(document.ConfiguratorForm.elements[i].value);
}
}
var gross = parseFloat(amount);
var netprice = Math.round(gross/0.0119)/100;
var taxprice = Math.round(netprice*19)/100;
gross = Math.round(gross*100)/100;
document.ConfiguratorForm.elements["netprice"].value = netprice;
document.ConfiguratorForm.elements["taxprice"].value = taxprice;
document.ConfiguratorForm.elements["totalpricegross"].value = gross;
}
</SCRIPT>
<?php
/*
This function is from the ORIGINAL zen_draw_pull_down_menu but with some changes,
to keep custom parameters needed.
*/
function zen_draw_pull_down_menu_for_configurator($name, $values, $default = '', $parameters = '', $required = false)
{
$field = '<select class="configurator_select_element" rel="dropdown" onchange=change_price_when_selected(this.name,this.options[this.selectedIndex].title) name='.zen_output_string($name).'';
if (zen_not_null($parameters)) $field .= ' ' . $parameters; $field .= '>';
if (empty($default) && isset($GLOBALS[$name])) $default = stripslashes($GLOBALS[$name]);
for ($i=0, $n=sizeof($values); $i<$n; $i++) {
$field .= '<option title=' . zen_output_string($values[$i]['price']) . ' value=CONFIGURATOR.' . zen_output_string($values[$i]['id']) . '';
if ($default == $values[$i]['id']) { $field .= ' SELECTED'; }
$field .= '>' . zen_output_string($values[$i]['text'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>'));
$field .= ' ' . zen_output_string($values[$i]['price'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')) . '</option>';}
$field .= '</select>'; if ($required == true) $field .= TEXT_FIELD_REQUIRED; return $field;
}
// As you can notice below, there has been added a new column to TABLE_CATEGORIES , "pc_configurator"
// that just works as switch for categories. If it's value is 1 all products of a category will be automatically added
// to a drop down list. The title of the drop down list will be automatically the category name.
// Finding number of categories to use it in the FOR loop below.
$cat_no_q = $db->Execute("select count(*) as total from ".TABLE_CATEGORIES." where pc_configurator = 1 and categories_status = 1 ");
// This var holds the number of categories
$cat_no_r = $cat_no_q->fields['total'];
$configurator_category = $db->Execute("select c.categories_id, cd.categories_name
from ".TABLE_CATEGORIES." c, ".TABLE_CATEGORIES_DESCRIPTION." cd
where c.pc_configurator = 1 and c.categories_status = 1
and c.categories_id = cd.categories_id
and cd.language_id = '" . (int)$_SESSION['languages_id'] . "'
");
// order by c.categories_id ASC
// lebrand2006 : TODO : new table to store sort order for every set of configurable products
// to use it in the categories query above. The configuration of sort order
// will be done in Admin->Categories [not yet ready]
// START CATEGORIES IDs WHILE.
// BUILDING AN ARRAY OF CATEGORIES BASED ON THE VALUE OF COLUMN pc_configurator
while (!$configurator_category->EOF){
// NOTICE : we are constructing an array of categories ids and names
$categories_ids_array[] = array('id' => $configurator_category->fields['categories_id'],
'name' => $configurator_category->fields['categories_name']);
$configurator_category->MoveNext();
}
// END CATEGORIES IDs WHILE
?>
<!--
The foolowing will also change for the NEW version. Instead of using again server sources, we send with a variable the number of categories to the next step page
-->
<form enctype="multipart/form-data" name="ConfiguratorForm" action="<?php echo HTTP_SERVER;?><?php echo DIR_WS_CATALOG;?>index.php?main_page=pc_configurator_step_2&cat_num=<?php echo $cat_no_r;?> " method="POST">
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#808080" width="100%" id="AutoNumber1">
<?php
// START LOOPING WITHIN CATEGORIES :
//
// THIS "for" LOOP WILL PRODUCE ALL DROP DOWN LISTS OF PRODUCTS
for ($ii=0; $ii<$cat_no_r; $ii++) {
$products_group_array = array(array('id' => '',
'model' => '',
'text' => $categories_ids_array[$ii]['name'],
'price' => '' ));
// Setting the SELECT paramaters
$products_group = $db->Execute("SELECT p.products_id,p.products_model,
p.products_tax_class_id,
p.products_price, pd.products_name
FROM " . TABLE_PRODUCTS . " p,
" . TABLE_PRODUCTS_DESCRIPTION . " pd
WHERE p.master_categories_id = '".$categories_ids_array[$ii]['id']."'
AND p.products_status = 1
AND p.products_id = pd.products_id
ORDER BY p.products_price ASC ");
// START PRODUCTS WHILE LOOP
while (!$products_group->EOF) {
// PRODUCING THE ARRAY OF PRODUCTS :
$products_group_array[] = array('id' => $products_group->fields['products_id'],
'model' => $products_group->fields['products_model'],
'text' => $products_group->fields['products_name'],
'price' => $currencies->display_price($products_group->fields['products_price'],
zen_get_tax_rate($products_group->fields['products_tax_class_id'])));
$products_group->MoveNext();
}
// END PRODUCTS WHILE LOOP
/*
NOTICE :
Every select needs to carry a name. It could be the same for all selects and just to be added "[]".
This would produce an ARRAY of all selects.
Anyway, we automatically give a different name [name element = variable], for every select
We use the following part [product_group_] of this variable $prod_dd_select_names
*/
$prod_dd_select_names = 'product_group_';
?>
<tr>
<td width="90%">
<?php
/*
NOTICE : The first parameter of the function "zen_draw_pull_down_menu_for_configurator" asks for select name, as it is producing a SELECT. We also add autonumbering from the "for" loop, so every select have a different name !
The second parameter is the ARRAY of PRODUCTS, used from the function to populate the select with all category products.
*/
echo zen_draw_pull_down_menu_for_configurator(''.$prod_dd_select_names.''.$ii.'', $products_group_array);
?>
<!-- Below we use the function "display_product_details" for witch we talked about ABOVE-->
<a onclick=display_product_details(document.ConfiguratorForm.product_group_<?php echo $ii;?>.value) href="javascript:void(0)"><font size="1"><?php echo PRODUCT_DETAILS_LINK_TEXT;?></font></a>
</td><td width="10%"><input class="form" style="TEXT-ALIGN: right" readOnly align="right" size="10" value="0" name="product_group_<?php echo $ii;?>_price">
</td>
</tr>
<?php
} // END LOOPING WITHIN GATEGORIES
?>
<tr>
<td align="right">
<?php echo CONFIGURATOR_NET_PRICE_TEXT; ?>
</td>
<td>
<input class=form style="TEXT-ALIGN: right" readOnly align=right size=10 value=0 name=netprice>
</td>
</tr>
<tr>
<td align="right">
<?php echo CONFIGURATOR_TAX_PRICE_TEXT; ?>
</td>
<td>
<input class=form style="TEXT-ALIGN: right" readOnly align=right size=10 value=0 name=taxprice>
</td>
</tr>
<tr>
<td align="right">
<?php echo CONFIGURATOR_TOTAL_PRICE_TEXT; ?>
</td>
<td>
<input id=totalpricegross class=form style="TEXT-ALIGN: right" readOnly align=right size=10 value=0 name=totalpricegross>
</td>
</tr>
<tr>
<td align="center">
<font size="1">There are <b><font color="#FF0000"><?php echo $cat_no_r;?></font></b> categories to choose products from.</font>
</td>
</tr>
<tr>
<td align="left">
<input type="reset" value="<?php echo CONFIGURATOR_BUTTON_RESET_TEXT;?>">
</td>
<td align="right">
<input align="right" type="submit" value="<?php echo CONFIGURATOR_BUTTON_STEP_2_TEXT;?>">
</td>
</tr>
</table>
</form>
Re: PC Configurator For Zen Cart
Zen Cart, have 100's of functions and 1000's lines of code.
I started learning PHP and MySQL with Zen Cart.
I want to make this module to be fully compatible with Zen Cart, without changing Zen Cart code but using override system. It is not difficult to do this, but I need a good team...just people that want to help, just to tell me their opinion and ideas...
I am also, one of those who have downloaded and installed 10's of modules. But I also try to give something to Zen Cart.
So, do not just comment, but be a part of this, JUST with your ideas [if you have any].
I know [or I can imagine] 10's ways to make a module like this to work, but because of the reason it is not just for me, but maybe for 100's of people that want to use it, maybe you can tell you ideas.
So, you can post your ideas, then we gather all of it, and comment it.
Next step will be easy.
Re: PC Configurator For Zen Cart
Just an advice for new zen cart users. You may not need this module!
If you want customers to be able to configure their computers, use attributes. Read this tutorial https://www.zen-cart.com/tutorials/index.php?article=57
Being a new user I spent hours trying to get PC Configurator to work without success. Using attributes worked at once and was easy to configure. So, as usual, reading the manual can save you a lot of trouble :blush:
Re: PC Configurator For Zen Cart
Yes I agree.
Attributes is the best solution.
Costomers will love it !
Thanks to zab-sv for helping !
Re: PC Configurator For Zen Cart
Hello,
to the community I am French I do not speak English even crowns me.
I am writing to you because I can not install a pc configurator its puts me into error someone can help me please:smile:
Re: PC Configurator For Zen Cart
Hello,
to the community I am French I do not speak English even crowns me.
I am writing to you because I can not install a pc configurator its puts me into error someone can help me please
Re: Configurator For Zen Cart
Quote:
Originally Posted by
lebrand2006
New testing WORKING version available.
Download the new zip file from this POST.
Upload and test.
Please provide your URL, and tell me what else you need the configurator to do.
Thanks
So is this the latest addition of the module?
I noticed that the version posted on the free addons page is way outdated.
Re: PC Configurator For Zen Cart
Quote:
Originally Posted by
zab-sv
Just an advice for new zen cart users. You may
not need this module!
If you want customers to be able to configure their computers, use
attributes. Read this tutorial
https://www.zen-cart.com/tutorials/index.php?article=57
Being a new user I spent hours trying to get PC Configurator to work without success. Using attributes worked at once and was easy to configure. So, as usual, reading the manual can save you a lot of trouble :blush:
Hello zab-sv
Don't know how you can say this.
OSC has a configurator were you can browse for the different kinds of products (mainbord, hd, mem, etc) and add them to the configurator and give a discount to it because the customer buys multiple products. How can this be done with attributes ?
Regards,