Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

custom_computer.php


shu keat

Recommended Posts

<_< what changes should i make and where should i modify so that radio button will be the option that let the users to choose.

 

i face a serious problem, which is after from drop down to radio button. after i select the products and press submit, the product name cannot be display and the price cannot be sum up.

 

what can i do in order to display the name of the product after the radio button had been selected.

 

<?php

/*

Custom Computer Creator

Version 9.3

7/10/2004

custom_computer.php

Designed And Coded By: Stephen Walker

 

You Are Free To Edit This File However You Would Like

Custom Computer Creator Is Coded For A Base In OsCommerce Shopping Cart

Released under the GNU General Public License

*/

 

//Function to create the drop down menus for custom builds

function tep_custom($systype, $fsb, $number, $selected = ''){

global $tax_rate, $languages_id;

$mb = tep_db_query('select p.*, cp.osc_prod_id, pd.* from '.TABLE_CCC_PROD.' cp, '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd where fsb_id = "'.$fsb.'" and cat_id = "'.$number.'" and cp.osc_prod_id = p.products_id and pd.products_id = p.products_id and pd.language_id = "'.(int)$languages_id.'" order by sort_order asc');

$mbb_array= array();

if ($selected != ''){

$default_query = tep_db_query('select p.products_price, p.products_id, cp.osc_prod_id from '.TABLE_CCC_PROD.' cp, '.TABLE_PRODUCTS.' p where p.products_id = cp.osc_prod_id and fsb_id = "'.$fsb.'" and cat_id = "'.$number.'" and p.products_id = "' . $selected . '" limit 1');

}else{

$default_query = tep_db_query('select p.products_price, p.products_id, cp.osc_prod_id from '.TABLE_CCC_PROD.' cp, '.TABLE_PRODUCTS.' p where p.products_id = cp.osc_prod_id and fsb_id = "'.$fsb.'" and cat_id = "'.$number.'" and default_prod = "1" limit 1');

}

$default_fetch = tep_db_fetch_array($default_query);

if ($selected == ''){

$selected = $default_fetch['osc_prod_id'];

}

while ($mb_values = tep_db_fetch_array($mb)) {

if (function_exists(tep_get_products_special_price)){

if ($products_price = tep_get_products_special_price($mb_values['products_id'])){

$mb_values['products_price'] = $products_price;

}

if ($default_price = tep_get_products_special_price($default_fetch['products_id'])){

$default_fetch['products_price'] = $default_price;

}

}

if (function_exists(osc_group_price)){

if ($products_price = osc_group_price($mb_values['products_id'])){

$mb_values['products_price'] = $products_price;

}

if ($default_price = osc_group_price($default_fetch['products_id'])){

$default_fetch['products_price'] = $default_price;

}

}

if (DISPLAY_PRICE_WITH_TAX == 'true'){

$products_tax = tep_get_tax_rate($mb_values['products_tax_class_id']);

$new_price = (tep_add_tax($mb_values['products_price'], $products_tax) - tep_add_tax($default_fetch['products_price'], $products_tax));

}else{

$new_price = ($mb_values['products_price'] - $default_fetch['products_price']);

}

$mbb_array[] = array('mb_price' => $mb_values['products_price'],

'price_diff' => $new_price,

'mb_model' => $mb_values['products_id'],

'mb_image' => $mb_values['products_image'],

'mb_name' => $mb_values['products_name'],

'def' => $selected,

'mb_tax' => $mb_values['products_tax_class_id']);

}

return $mbb_array;

}

 

//Creates a pull-down list for Custom Computer Creator

function tep_get_parts_list($name, $number, $selected = '', $systype, $fsb) {

$mb_array = array(array('id' => 'default',

'price' => '0',

'name' => 'nosel.jpg',

'text' => PULL_DOWN_DEFAULT));

$motherboards = tep_custom($systype, $fsb, $number, $selected);

for ($i=0,$n=sizeof($motherboards);$i<$n;$i++) {

 

$mb_array[] = array('model' => $motherboards[$i]['mb_model'],

'text' => $motherboards[$i]['mb_name'],

'price' => $motherboards[$i]['mb_price'],

'price_diff' => $motherboards[$i]['price_diff'],

'name' => $motherboards[$i]['mb_image'],

'default' => $motherboards[$i]['def'],

'tax' => $motherboards[$i]['mb_tax']);

}

 

return tep_draw_custom_pull_down_menu($name, $mb_array, '', $parameters, $systype, $fsb, $number);

// return tep_draw_custom_radio_field($name, $mb_array, '', $parameters, $systype, $fsb, $number);

}

 

 

// Output a form pull down menu for Custom Computer Creator

function tep_draw_custom_pull_down_menu($name, $values, $default = '', $parameters = '', $systype, $fsb, $number) {

global $tax_rate, $languages_id;

$field = '<select style="width:250;" name="' . tep_parse_input_field_data($name, array('"' => '"')) . '" id="' . tep_parse_input_field_data($name, array('"' => '"')) . '"';

 

if (tep_not_null($parameters)) $field .= ' ' . $parameters;

 

$field .= ' onChange="showimage(\'' . $number . '\', \'' . $name . '\')">';

 

for ($i=0; $i<sizeof($values); $i++) {

$field .= '<option price="' . $values[$i]['price'] . '" name="images/' . $values[$i]['name'] . '" model="' . $values[$i]['model'] . '" value="' . $values[$i]['text'] . '"';

if ($values[$i]['default'] == $values[$i]['model']){

$field .= 'SELECTED';

}

if ($values[$i]['price_diff'] == '0.00' || $values[$i]['price'] == '0.00'){

$new_price = '';

}else{

$price_fix = explode('-', $values[$i]['price_diff']);

if ($price_fix[0] != '' || $price_fix[0] == '-'){

$new_price = '+' . $values[$i]['price_diff'];

}else{

$new_price = '-' . $price_fix[1];

}

}

$field .= '>' . $values[$i]['text'] . ' ' . $new_price;

}

$field .= '</select>';

$reqn = explode('new', $name);

 

if ($systype == ''){ }else{

$req_check = tep_db_query('select cat_req from '.TABLE_CCC_CAT.' where cat_id = "'.$number.'" and status = "1" order by sort_order asc');

$req = tep_db_fetch_array($req_check);

if ($req['cat_req'] == '1'){

$need = '1';

}

}

 

if ($need == "1") { $field .= DROP_DOWN_REQUIRED . "<input type=hidden name=required" . $reqn[1] . " value=" . tep_parse_input_field_data($name, array('"' => '"')) . ">"; }

return $field;

}

 

function tep_draw_custom_radio_field($name, $values, $default = '', $parameters = '', $systype, $fsb, $number) {

for ($i=0; $i<sizeof($values); $i++) {

if ($values[$i]['price'] == "0" || $values[$i]['price'] == ""){

$selected = 'checked';

}else{

$selected = '';

}

$new_num = explode('new', $name);

$field .= '<br>';

$field .= '<input name="' . $name . '" type="radio" price="' . $values[$i]['price'] . '" pic="images/' . $values[$i]['name'] . '" model="' . $values[$i]['model'] . '"';

$field .= 'onClick="showimage(\''.$name.'\', \''.$i.'\', \''.$new_num[1].'\')" '.$selected.'>';

$field .= $values[$i]['text'] . ' ' .$values[$i]['price'].'';

}

$reqn = explode('new', $name);

if ($systype == ''){

}else{

$req_check = tep_db_query('select cat_req from '.TABLE_CCC_CAT.' where cat_id = "' . $number . '" and status = "1" order by sort_order asc');

$req = tep_db_fetch_array($req_check);

if ($req['cat_req'] == "1"){

$need = '1';

}

}

if ($need == "1") {

$field .= DROP_DOWN_REQUIRED . "<input type=hidden name=required" . $reqn[1] . " value=" . $name . ">";

}

 

return $field;

}

?>

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...