Guest Posted July 21, 2008 Share Posted July 21, 2008 I have several products that all work together as one "kit" I have put some of these "kits" together but some customers want to change the individual prouducts that make up the "kit" I was wanting to make a product named "Custom Kit" with the price set at $0.00 and add attributes for each individual part There would be several drop down lists such as "compressor" "tank" "valve" etc (all the individual parts that make the kit) with the price increase for each attribute pre set but the problem is you have to check out before you can see what the subtotal will be. I was wondering if anyone knew how to add a calculator button to the end of the drop down lists that would give the customer a subtotal before they checkout? It might even be good to have a reset button so if the price doesnt satisfy the customer they could click reset and the price would go back to $0.00 and they could start over. The main thing would be the calculator button, the reset option would just be an added bonus. Does anyone know how to do this? Quote Link to comment Share on other sites More sharing options...
♥toyicebear Posted July 21, 2008 Share Posted July 21, 2008 Click me... Quote Basics for osC 2.2 Design - Basics for Design V2.3+ - Seo & Sef Url's - Meta Tags for Your osC Shop - Steps to prevent Fraud... - MS3 and Team News... - SEO, Meta Tags, SEF Urls and osCommerce - Commercial Support Inquiries - OSC 2.3+ How To To see what more i can do for you check out my profile [click here] Link to comment Share on other sites More sharing options...
Guest Posted July 21, 2008 Share Posted July 21, 2008 Thanks that is exactly what I was looking for. I am not sure of what files to change though????????? Quote Link to comment Share on other sites More sharing options...
Guest Posted July 21, 2008 Share Posted July 21, 2008 I am not exactly sure on how to do this. Quote Link to comment Share on other sites More sharing options...
♥toyicebear Posted July 21, 2008 Share Posted July 21, 2008 You download the contribution and read the instructions inside. If the top one does not have instructions inside, then download the next one and so on till you find a full version with instructions. Quote Basics for osC 2.2 Design - Basics for Design V2.3+ - Seo & Sef Url's - Meta Tags for Your osC Shop - Steps to prevent Fraud... - MS3 and Team News... - SEO, Meta Tags, SEF Urls and osCommerce - Commercial Support Inquiries - OSC 2.3+ How To To see what more i can do for you check out my profile [click here] Link to comment Share on other sites More sharing options...
cincopunto5 Posted July 23, 2008 Share Posted July 23, 2008 well, this contributions was "almost perfect" http://addons.oscommerce.com/info/1385 Thanks for that, BUT, i will offer printing services, the only way this contribution will help is if a enter a price for each product (let say business cards), 0.05 for example each, so the customer can select >1,000 price 0.05 <1,000-5,000> price 0.04, etc if I add another atribute, it will need to be in cents too, I was looking something like www. hotcards .com/, does anybody knows any contribution like that, i have been looking for it, but i cant find it, maybe someone here wanna make this small job I can pay for it, thanks, Quote Link to comment Share on other sites More sharing options...
Guest Posted July 24, 2008 Share Posted July 24, 2008 I think that http://addons.oscommerce.com/info/1385 will work for me just fine and I have read the install instructions but I still cant get it to work. I guess I dont have the "creative javascripting" mentioned in the instructions lol Just incase you couldnt tell, I am not a pro at this hahaha ?????????????????????????? Quote Link to comment Share on other sites More sharing options...
Guest Posted July 28, 2008 Share Posted July 28, 2008 Can anyone help me along with this install??? Please Quote Link to comment Share on other sites More sharing options...
francois21 Posted August 18, 2008 Share Posted August 18, 2008 Hello is this contribution work with qtpro?? There is juste this code different Search For: THIS PART OF CODE IS NOT WHEN WE HAVE QTPRO <td class="main"><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?></td> Change to: <td class="main"><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute, "onChange='showPrice(this.form);showPrice1(this.form);'"); ?></td> AN IDEA thank's francois Quote Link to comment Share on other sites More sharing options...
tejure Posted September 18, 2008 Share Posted September 18, 2008 Hellois this contribution work with qtpro?? There is juste this code different Search For: THIS PART OF CODE IS NOT WHEN WE HAVE QTPRO <td class="main"><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?></td> Change to: <td class="main"><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute, "onChange='showPrice(this.form);showPrice1(this.form);'"); ?></td> AN IDEA thank's francois Hello, Sorry for my english... I have the same problem and I think this code may be can put on file pad_base.php on includes/classes/ directory, but I don't know where :blink: I think only is needed this function "onChange='showPrice(this.form);showPrice1(this.form);'" with QTpro, because if you put all appear another draw pull down menu. This is a pad_base.php file: --------------------------------- <?php /* QT Pro Version 4.1 pad_base.php Contribution extension to: osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2004, 2005 Ralph Day Released under the GNU General Public License Based on prior works released under the GNU General Public License: QT Pro prior versions Ralph Day, October 2004 Tom Wojcik aka TomThumb 2004/07/03 based on work by Michael Coffman aka coffman FREEZEHELL - 08/11/2003 [email protected] Copyright © 2003 IBWO Joseph Shain, January 2003 osCommerce MS2 Copyright © 2003 osCommerce Modifications made: 11/2004 - Created 12/2004 - Fix _draw_js_stock_array to prevent error when all attribute combinations are out of stock. ******************************************************************************** *********** QT Pro Product Attributes Display Plugin pad_base.php - Base Class Class Name: pad_base This base class, although functional, is not intended to be installed and used directly. It is extended by other classes to provide different display options for product attributes on the product information page (product_info.php). Methods: pad_base constructor _SetConfigurationProperties set local properties from DB config constants draw draw the product attributes _draw_table_start draw start of the table to enclose the attributes display _draw_stocked_attributes draw attributes that stock is tracked for _draw_nonstocked_attributes draw attributes that stock is not tracked for _draw_table_end draw end of the table to enclose the attributes display _draw_js_stock_array draw a Javascript array of in stock attribute combinations _build_attributes_array build an array of the attributes for the product _build_attributes_combinations build an array of the attribute combinations for the product Properties: products_id the product id for attribute display products_tax_class_id the products tax class id show_out_of_stock show out of stock attributes flag mark_out_of_stock mark out of stock attributes flag out_of_stock_msgline show out of stock message line flag no_add_out_of_stock prevent add to cart of out of stock attributes combinations */ class pad_base { var $products_id; var $products_tax_class_id; var $show_out_of_stock; var $mark_out_of_stock; var $out_of_stock_msgline; var $no_add_out_of_stock; /* Method: pad_base Class constructor Parameters: $products_id integer The product id of the product attributes are to be displayed for Returns: nothing */ function pad_base($products_id=0) { $this->products_id = $products_id; if ($this->products_id != 0) { $tax_class_query = tep_db_query('SELECT products_tax_class_id, products_price /* AGF */ FROM ' . TABLE_PRODUCTS . " WHERE products_id = '" . (int)$products_id . "'"); $tax_class_array = tep_db_fetch_array($tax_class_query); $this->products_tax_class_id = $tax_class_array['products_tax_class_id']; $this->products_original_price = $tax_class_array['products_price']; /* AGF */ } $this->_SetConfigurationProperties('PRODINFO_ATTRIBUTE_'); } /* Method: _SetConfigurationProperties Set local configuration properties from osCommerce configuration DB constants Parameters: $prefix sting Prefix for the osCommerce DB constants Returns: nothing */ function _SetConfigurationProperties($prefix) { $this->show_out_of_stock = constant($prefix . 'SHOW_OUT_OF_STOCK'); $this->mark_out_of_stock = constant($prefix . 'MARK_OUT_OF_STOCK'); $this->out_of_stock_msgline = constant($prefix . 'OUT_OF_STOCK_MSGLINE'); $this->no_add_out_of_stock = constant($prefix . 'NO_ADD_OUT_OF_STOCK'); } /* Method: draw Draws the product attributes. This is the only method other than the constructor that is intended to be called by a user of this class. Attributes that stock is tracked for are grouped first and drawn with one dropdown list per attribute. All attributes are drawn even if no stock is available for the attribute and no indication is given that the attribute is out of stock. Attributes that stock is not tracked for are then drawn with one dropdown list per attribute. Parameters: none Returns: string: HTML for displaying the product attributes */ function draw() { $out=$this->_draw_table_start(); $out.=$this->_draw_stocked_attributes(); $out.=$this->_draw_nonstocked_attributes(); $out.=$this->_draw_table_end(); return $out; } /* Method: _draw_table_start Draws the start of a table to wrap the product attributes display. Intended for class internal use only. Parameters: none Returns: string: HTML for start of table */ function _draw_table_start() { $out =' <table border="0" cellspacing="0" cellpadding="2">'; $out.=' <tr>'; $out.=' <td class="main" colspan="2"><b>' . TEXT_PRODUCT_OPTIONS . '</b></td>'; $out.=' </tr>'; return $out; } /* Method: _draw_stocked_attributes Draws the product attributes that stock is tracked for. Intended for class internal use only. Attributes that stock is tracked for are drawn with one dropdown list per attribute. All attributes are drawn even if no stock is available for the attribute and no indication is given that the attribute is out of stock. Parameters: none Returns: string: HTML for displaying the product attributes that stock is tracked for */ function _draw_stocked_attributes() { $out = ''; $attributes = $this->_build_attributes_array(true, false); if (sizeof($attributes)>0) { foreach ($attributes as $stocked) { $out .= '<tr><td align="right" class=main><b>' . $stocked['oname'] . ":</b></td><td class=main>" . tep_draw_pull_down_menu('id['.$stocked['oid'].']',array_values($stocked['ovals']),$stocked['default']) . "</td></tr>\n"; } } return $out; } /* Method: _draw_nonstocked_attributes Draws the product attributes that stock is not tracked for. Intended for class internal use only. Attributes that stock is not tracked for are drawn with one dropdown list per attribute. Parameters: none Returns: string: HTML for displaying the product attributes that stock is not tracked for */ function _draw_nonstocked_attributes() { $out=''; $nonstocked_attributes = $this->_build_attributes_array(false, true); foreach($nonstocked_attributes as $nonstocked) { $out.='<tr><td align="right" class=main><b>'.$nonstocked['oname'].":</b></td><td class=main>".tep_draw_pull_down_menu('id['.$nonstocked['oid'].']',$nonstocked['ovals'],$nonstocked['default'])."</td></tr>\n"; } return $out; } /* Method: _draw_table_end Draws the end of a table to wrap the product attributes display. Intended for class internal use only. Parameters: none Returns: string: HTML for end of table */ function _draw_table_end() { return ' </table>'; } /* Method: _build_attributes_array Build an array of the attributes for the product Parameters: $build_stocked boolean Flag indicating if stocked attributes should be built. $build_nonstocked boolean Flag indicating if non-stocked attribute should be built. Returns: array: Array of attributes for the product of the form: 'oid' => integer: products_options_id 'oname' => string: products_options_name 'ovals' => array: option values for the option id of the form 'id' => integer: products_options_values_id 'text' => string: products_options_values_name 'default' => integer: products_options_values_id that the product id contains for this option id and should be the default selection when this attribute is drawn. Set to zero if the product id did not contain this option. */ function _build_attributes_array($build_stocked, $build_nonstocked) { global $languages_id; global $currencies; global $cart; if (!($build_stocked | $build_nonstocked)) return null; if ($build_stocked && $build_nonstocked) { $stocked_where=''; } elseif ($build_stocked) { $stocked_where="and popt.products_options_track_stock = '1'"; } elseif ($build_nonstocked) { $stocked_where="and popt.products_options_track_stock = '0'"; } $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_track_stock from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$this->products_id . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' " . $stocked_where . " order by popt.products_options_name"); $attributes=array(); while ($products_options_name = tep_db_fetch_array($products_options_name_query)) { $products_options_array = array(); $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$this->products_id . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'"); while ($products_options = tep_db_fetch_array($products_options_query)) { $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']); //START of integration of contribution Actual "Price Pull Down v1.2.3a" if(PRODINFO_ATTRIBUTE_ACTUAL_PRICE_PULL_DOWN == 'True'){ //Option prices will displayed as a final product price. This can (currently) only be used with a satisfying result if you have only one option per product. $new_price ? $original_price = $new_price : $original_price = $this->products_original_price; //// check if set special price note $this variable if ($products_options['price_prefix'] == '-') {// in case price lowers, don't add values, subtract. $show_price = 0.0 + $original_price - $products_options['options_values_price']; // force float (in case) using the 0.0; } else { $show_price = 0.0 + $original_price + $products_options['options_values_price']; // force float (in case) using the 0.0; } $products_options_array[sizeof($products_options_array)-1]['text'] .= ' ' . $currencies->display_price( $show_price, tep_get_tax_rate($this->products_tax_class_id)) .' '; }else{ //Display the option prices as differece prices with +/- prefix as usually if ($products_options['options_values_price'] != '0') { $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($this->products_tax_class_id)) . ')'; } } //END of integration of contribution Actual "Price Pull Down v1.2.3a" } if (isset($cart->contents[$this->products_id]['attributes'][$products_options_name['products_options_id']])) $selected = $cart->contents[$this->products_id]['attributes'][$products_options_name['products_options_id']]; else $selected = 0; $attributes[]=array('oid'=>$products_options_name['products_options_id'], 'oname'=>$products_options_name['products_options_name'], 'ovals'=>$products_options_array, 'default'=>$selected); } return $attributes; } /* Method: _build_attributes_combinations A recursive method for building an array enumerating the attribute combinations for the product Parameters: $attributes array An array of the attributes that combinations will be built for. Format is as returned by _build_attributes_array. $showoos boolean Flag indicating if non-stocked attributes should be built. $markoos string 'Left' if out of stock indication is to be appended in front of the attribute combination text. 'Right' if out of stock indication is to be appended at the end of the attribute combination text. $combinations array Array of the attribute combinations is returned in this parameter. Should be set to an empty array before an external call to this method. 'comb' => array: array of a single attribute combination options_id => options_value_id 'id' => string: options/values string for this combination in the form for the key of the products_stock table opt_id-val_id,opt_id-val_id,... 'text' => string: Text for this combination. Values text is as built by _build_attributes_array and contains the add/subtract price for the option value if applicable. Form is: values_text, values_text $selected_combination integer Index into the $combinations array of the combination that should be the default selection when the combination is drawn is returned in this parameter. Determined from product id. Should be set to zero before an external call to this method. Parameters for internal recursion use only: $oidindex integer Index into the $attributes array of the option to operate on. $comb array Array containing option id/values of combination built so far products_options_id => products_options_value_id $id string Contains string of options/values built so far $text string Text for the options values constructed so far. $isselected boolean Flag indicating if so far all option values in this combination were indicated to be defaults in the product id. Returns: see $combinations and $selected_combination parameters above no actual function return value. */ function _build_attributes_combinations($attributes, $showoos, $markoos, &$combinations, &$selected_combination, $oidindex=0, $comb=array(), $id="", $text='', $isselected=true) { global $cart; foreach ($attributes[$oidindex]['ovals'] as $attrib) { $newcomb = $comb; $newcomb[$attributes[$oidindex]['oid']] = $attrib['id']; $newid=$id.','.$attributes[$oidindex]['oid'].'-'.$attrib['id']; $newtext = $text.", ".$attrib['text']; if (isset($cart->contents[$this->products_id]['attributes'][$attributes[$oidindex]['oid']])) $newisselected = ($cart->contents[$this->products_id]['attributes'][$attributes[$oidindex]['oid']] == $attrib['id']) ? $isselected : false; else $newisselected = false; if (isset($attributes[$oidindex+1])) { $this->_build_attributes_combinations($attributes, $showoos, $markoos, $combinations, $selected_combination, $oidindex+1, $newcomb, $newid, $newtext, $newisselected); } else { $is_out_of_stock=tep_check_stock(tep_get_prid($this->products_id),1,$newcomb); if (!$is_out_of_stock | ($showoos == true)) { switch ($markoos) { case 'Left': $newtext=($is_out_of_stock ? TEXT_OUT_OF_STOCK.' - ' : '').substr($newtext,2); break; case 'Right': $newtext=substr($newtext,2).($is_out_of_stock ? ' - '.TEXT_OUT_OF_STOCK : ''); break; default: $newtext=substr($newtext,2); break; } $combinations[] = array('comb'=>$newcomb, 'id'=>substr($newid,1), 'text'=>$newtext); if ($newisselected) $selected_combination = sizeof($combinations)-1; } } } } /* Method: _draw_js_stock_array Draw a Javascript array containing the given attribute combinations. Generally used to draw array of in-stock combinations for Javascript out of stock validation and messaging. Parameters: $combinations array Array of combinations to build the Javascript array for. Array must be of the form returned by _build_attributes_combinations Usually this array only contains in-stock combinations. Returns: string: Javacript array definition. Excludes the "var xxx=" and terminating ";". Form is: {optval1:{optval2:{optval3:1,optval3:1}, optval2:{optval3:1}}, optval1:{optval2:{optval3:1}}} For example if there are 3 options and the instock value combinations are: opt1 opt2 opt3 1 5 4 1 5 8 1 10 4 3 5 8 The string returned would be {1:{5:{4:1,8:1}, 10:{4:1}}, 3:{5:{8:1}}} */ function _draw_js_stock_array($combinations) { if (!((isset($combinations)) && (is_array($combinations)) && (sizeof($combinations) > 0))){ return '{}'; } $out=''; foreach ($combinations[0]['comb'] as $oid=>$ovid) { $out.='{'.$ovid.':'; $opts[]=$oid; } $out.='1'; for ($combindex=1; $combindex<sizeof($combinations); $combindex++) { $comb=$combinations[$combindex]['comb']; for ($i=0; $i<sizeof($opts)-1; $i++) { if ($comb[$opts[$i]]!=$combinations[$combindex-1]['comb'][$opts[$i]]) break; } $out.=str_repeat('}',sizeof($opts)-1-$i).','; if ($i<sizeof($opts)-1) { for ($j=$i; $j<sizeof($opts)-1; $j++) $out.=$comb[$opts[$j]].':{'; } $out.=$comb[$opts[sizeof($opts)-1]].':1'; } $out.=str_repeat('}',sizeof($opts)); return $out; } } ?> ------------------------------------- Thanks Quote Link to comment Share on other sites More sharing options...
tejure Posted September 18, 2008 Share Posted September 18, 2008 Hello,Sorry for my english... I have the same problem and I think this code may be can put on file pad_base.php on includes/classes/ directory, but I don't know where :blink: I think only is needed this function "onChange='showPrice(this.form);showPrice1(this.form);'" with QTpro, because if you put all appear another draw pull down menu. This is a pad_base.php file: --------------------------------- <?php /* QT Pro Version 4.1 pad_base.php Contribution extension to: osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2004, 2005 Ralph Day Released under the GNU General Public License Based on prior works released under the GNU General Public License: QT Pro prior versions Ralph Day, October 2004 Tom Wojcik aka TomThumb 2004/07/03 based on work by Michael Coffman aka coffman FREEZEHELL - 08/11/2003 [email protected] Copyright © 2003 IBWO Joseph Shain, January 2003 osCommerce MS2 Copyright © 2003 osCommerce Modifications made: 11/2004 - Created 12/2004 - Fix _draw_js_stock_array to prevent error when all attribute combinations are out of stock. ******************************************************************************** *********** QT Pro Product Attributes Display Plugin pad_base.php - Base Class Class Name: pad_base This base class, although functional, is not intended to be installed and used directly. It is extended by other classes to provide different display options for product attributes on the product information page (product_info.php). Methods: pad_base constructor _SetConfigurationProperties set local properties from DB config constants draw draw the product attributes _draw_table_start draw start of the table to enclose the attributes display _draw_stocked_attributes draw attributes that stock is tracked for _draw_nonstocked_attributes draw attributes that stock is not tracked for _draw_table_end draw end of the table to enclose the attributes display _draw_js_stock_array draw a Javascript array of in stock attribute combinations _build_attributes_array build an array of the attributes for the product _build_attributes_combinations build an array of the attribute combinations for the product Properties: products_id the product id for attribute display products_tax_class_id the products tax class id show_out_of_stock show out of stock attributes flag mark_out_of_stock mark out of stock attributes flag out_of_stock_msgline show out of stock message line flag no_add_out_of_stock prevent add to cart of out of stock attributes combinations */ class pad_base { var $products_id; var $products_tax_class_id; var $show_out_of_stock; var $mark_out_of_stock; var $out_of_stock_msgline; var $no_add_out_of_stock; /* Method: pad_base Class constructor Parameters: $products_id integer The product id of the product attributes are to be displayed for Returns: nothing */ function pad_base($products_id=0) { $this->products_id = $products_id; if ($this->products_id != 0) { $tax_class_query = tep_db_query('SELECT products_tax_class_id, products_price /* AGF */ FROM ' . TABLE_PRODUCTS . " WHERE products_id = '" . (int)$products_id . "'"); $tax_class_array = tep_db_fetch_array($tax_class_query); $this->products_tax_class_id = $tax_class_array['products_tax_class_id']; $this->products_original_price = $tax_class_array['products_price']; /* AGF */ } $this->_SetConfigurationProperties('PRODINFO_ATTRIBUTE_'); } /* Method: _SetConfigurationProperties Set local configuration properties from osCommerce configuration DB constants Parameters: $prefix sting Prefix for the osCommerce DB constants Returns: nothing */ function _SetConfigurationProperties($prefix) { $this->show_out_of_stock = constant($prefix . 'SHOW_OUT_OF_STOCK'); $this->mark_out_of_stock = constant($prefix . 'MARK_OUT_OF_STOCK'); $this->out_of_stock_msgline = constant($prefix . 'OUT_OF_STOCK_MSGLINE'); $this->no_add_out_of_stock = constant($prefix . 'NO_ADD_OUT_OF_STOCK'); } /* Method: draw Draws the product attributes. This is the only method other than the constructor that is intended to be called by a user of this class. Attributes that stock is tracked for are grouped first and drawn with one dropdown list per attribute. All attributes are drawn even if no stock is available for the attribute and no indication is given that the attribute is out of stock. Attributes that stock is not tracked for are then drawn with one dropdown list per attribute. Parameters: none Returns: string: HTML for displaying the product attributes */ function draw() { $out=$this->_draw_table_start(); $out.=$this->_draw_stocked_attributes(); $out.=$this->_draw_nonstocked_attributes(); $out.=$this->_draw_table_end(); return $out; } /* Method: _draw_table_start Draws the start of a table to wrap the product attributes display. Intended for class internal use only. Parameters: none Returns: string: HTML for start of table */ function _draw_table_start() { $out =' <table border="0" cellspacing="0" cellpadding="2">'; $out.=' <tr>'; $out.=' <td class="main" colspan="2"><b>' . TEXT_PRODUCT_OPTIONS . '</b></td>'; $out.=' </tr>'; return $out; } /* Method: _draw_stocked_attributes Draws the product attributes that stock is tracked for. Intended for class internal use only. Attributes that stock is tracked for are drawn with one dropdown list per attribute. All attributes are drawn even if no stock is available for the attribute and no indication is given that the attribute is out of stock. Parameters: none Returns: string: HTML for displaying the product attributes that stock is tracked for */ function _draw_stocked_attributes() { $out = ''; $attributes = $this->_build_attributes_array(true, false); if (sizeof($attributes)>0) { foreach ($attributes as $stocked) { $out .= '<tr><td align="right" class=main><b>' . $stocked['oname'] . ":</b></td><td class=main>" . tep_draw_pull_down_menu('id['.$stocked['oid'].']',array_values($stocked['ovals']),$stocked['default']) . "</td></tr>\n"; } } return $out; } /* Method: _draw_nonstocked_attributes Draws the product attributes that stock is not tracked for. Intended for class internal use only. Attributes that stock is not tracked for are drawn with one dropdown list per attribute. Parameters: none Returns: string: HTML for displaying the product attributes that stock is not tracked for */ function _draw_nonstocked_attributes() { $out=''; $nonstocked_attributes = $this->_build_attributes_array(false, true); foreach($nonstocked_attributes as $nonstocked) { $out.='<tr><td align="right" class=main><b>'.$nonstocked['oname'].":</b></td><td class=main>".tep_draw_pull_down_menu('id['.$nonstocked['oid'].']',$nonstocked['ovals'],$nonstocked['default'])."</td></tr>\n"; } return $out; } /* Method: _draw_table_end Draws the end of a table to wrap the product attributes display. Intended for class internal use only. Parameters: none Returns: string: HTML for end of table */ function _draw_table_end() { return ' </table>'; } /* Method: _build_attributes_array Build an array of the attributes for the product Parameters: $build_stocked boolean Flag indicating if stocked attributes should be built. $build_nonstocked boolean Flag indicating if non-stocked attribute should be built. Returns: array: Array of attributes for the product of the form: 'oid' => integer: products_options_id 'oname' => string: products_options_name 'ovals' => array: option values for the option id of the form 'id' => integer: products_options_values_id 'text' => string: products_options_values_name 'default' => integer: products_options_values_id that the product id contains for this option id and should be the default selection when this attribute is drawn. Set to zero if the product id did not contain this option. */ function _build_attributes_array($build_stocked, $build_nonstocked) { global $languages_id; global $currencies; global $cart; if (!($build_stocked | $build_nonstocked)) return null; if ($build_stocked && $build_nonstocked) { $stocked_where=''; } elseif ($build_stocked) { $stocked_where="and popt.products_options_track_stock = '1'"; } elseif ($build_nonstocked) { $stocked_where="and popt.products_options_track_stock = '0'"; } $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_track_stock from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$this->products_id . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' " . $stocked_where . " order by popt.products_options_name"); $attributes=array(); while ($products_options_name = tep_db_fetch_array($products_options_name_query)) { $products_options_array = array(); $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$this->products_id . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'"); while ($products_options = tep_db_fetch_array($products_options_query)) { $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']); //START of integration of contribution Actual "Price Pull Down v1.2.3a" if(PRODINFO_ATTRIBUTE_ACTUAL_PRICE_PULL_DOWN == 'True'){ //Option prices will displayed as a final product price. This can (currently) only be used with a satisfying result if you have only one option per product. $new_price ? $original_price = $new_price : $original_price = $this->products_original_price; //// check if set special price note $this variable if ($products_options['price_prefix'] == '-') {// in case price lowers, don't add values, subtract. $show_price = 0.0 + $original_price - $products_options['options_values_price']; // force float (in case) using the 0.0; } else { $show_price = 0.0 + $original_price + $products_options['options_values_price']; // force float (in case) using the 0.0; } $products_options_array[sizeof($products_options_array)-1]['text'] .= ' ' . $currencies->display_price( $show_price, tep_get_tax_rate($this->products_tax_class_id)) .' '; }else{ //Display the option prices as differece prices with +/- prefix as usually if ($products_options['options_values_price'] != '0') { $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($this->products_tax_class_id)) . ')'; } } //END of integration of contribution Actual "Price Pull Down v1.2.3a" } if (isset($cart->contents[$this->products_id]['attributes'][$products_options_name['products_options_id']])) $selected = $cart->contents[$this->products_id]['attributes'][$products_options_name['products_options_id']]; else $selected = 0; $attributes[]=array('oid'=>$products_options_name['products_options_id'], 'oname'=>$products_options_name['products_options_name'], 'ovals'=>$products_options_array, 'default'=>$selected); } return $attributes; } /* Method: _build_attributes_combinations A recursive method for building an array enumerating the attribute combinations for the product Parameters: $attributes array An array of the attributes that combinations will be built for. Format is as returned by _build_attributes_array. $showoos boolean Flag indicating if non-stocked attributes should be built. $markoos string 'Left' if out of stock indication is to be appended in front of the attribute combination text. 'Right' if out of stock indication is to be appended at the end of the attribute combination text. $combinations array Array of the attribute combinations is returned in this parameter. Should be set to an empty array before an external call to this method. 'comb' => array: array of a single attribute combination options_id => options_value_id 'id' => string: options/values string for this combination in the form for the key of the products_stock table opt_id-val_id,opt_id-val_id,... 'text' => string: Text for this combination. Values text is as built by _build_attributes_array and contains the add/subtract price for the option value if applicable. Form is: values_text, values_text $selected_combination integer Index into the $combinations array of the combination that should be the default selection when the combination is drawn is returned in this parameter. Determined from product id. Should be set to zero before an external call to this method. Parameters for internal recursion use only: $oidindex integer Index into the $attributes array of the option to operate on. $comb array Array containing option id/values of combination built so far products_options_id => products_options_value_id $id string Contains string of options/values built so far $text string Text for the options values constructed so far. $isselected boolean Flag indicating if so far all option values in this combination were indicated to be defaults in the product id. Returns: see $combinations and $selected_combination parameters above no actual function return value. */ function _build_attributes_combinations($attributes, $showoos, $markoos, &$combinations, &$selected_combination, $oidindex=0, $comb=array(), $id="", $text='', $isselected=true) { global $cart; foreach ($attributes[$oidindex]['ovals'] as $attrib) { $newcomb = $comb; $newcomb[$attributes[$oidindex]['oid']] = $attrib['id']; $newid=$id.','.$attributes[$oidindex]['oid'].'-'.$attrib['id']; $newtext = $text.", ".$attrib['text']; if (isset($cart->contents[$this->products_id]['attributes'][$attributes[$oidindex]['oid']])) $newisselected = ($cart->contents[$this->products_id]['attributes'][$attributes[$oidindex]['oid']] == $attrib['id']) ? $isselected : false; else $newisselected = false; if (isset($attributes[$oidindex+1])) { $this->_build_attributes_combinations($attributes, $showoos, $markoos, $combinations, $selected_combination, $oidindex+1, $newcomb, $newid, $newtext, $newisselected); } else { $is_out_of_stock=tep_check_stock(tep_get_prid($this->products_id),1,$newcomb); if (!$is_out_of_stock | ($showoos == true)) { switch ($markoos) { case 'Left': $newtext=($is_out_of_stock ? TEXT_OUT_OF_STOCK.' - ' : '').substr($newtext,2); break; case 'Right': $newtext=substr($newtext,2).($is_out_of_stock ? ' - '.TEXT_OUT_OF_STOCK : ''); break; default: $newtext=substr($newtext,2); break; } $combinations[] = array('comb'=>$newcomb, 'id'=>substr($newid,1), 'text'=>$newtext); if ($newisselected) $selected_combination = sizeof($combinations)-1; } } } } /* Method: _draw_js_stock_array Draw a Javascript array containing the given attribute combinations. Generally used to draw array of in-stock combinations for Javascript out of stock validation and messaging. Parameters: $combinations array Array of combinations to build the Javascript array for. Array must be of the form returned by _build_attributes_combinations Usually this array only contains in-stock combinations. Returns: string: Javacript array definition. Excludes the "var xxx=" and terminating ";". Form is: {optval1:{optval2:{optval3:1,optval3:1}, optval2:{optval3:1}}, optval1:{optval2:{optval3:1}}} For example if there are 3 options and the instock value combinations are: opt1 opt2 opt3 1 5 4 1 5 8 1 10 4 3 5 8 The string returned would be {1:{5:{4:1,8:1}, 10:{4:1}}, 3:{5:{8:1}}} */ function _draw_js_stock_array($combinations) { if (!((isset($combinations)) && (is_array($combinations)) && (sizeof($combinations) > 0))){ return '{}'; } $out=''; foreach ($combinations[0]['comb'] as $oid=>$ovid) { $out.='{'.$ovid.':'; $opts[]=$oid; } $out.='1'; for ($combindex=1; $combindex<sizeof($combinations); $combindex++) { $comb=$combinations[$combindex]['comb']; for ($i=0; $i<sizeof($opts)-1; $i++) { if ($comb[$opts[$i]]!=$combinations[$combindex-1]['comb'][$opts[$i]]) break; } $out.=str_repeat('}',sizeof($opts)-1-$i).','; if ($i<sizeof($opts)-1) { for ($j=$i; $j<sizeof($opts)-1; $j++) $out.=$comb[$opts[$j]].':{'; } $out.=$comb[$opts[sizeof($opts)-1]].':1'; } $out.=str_repeat('}',sizeof($opts)); return $out; } } ?> ------------------------------------- Thanks I have the solution!!! In pad_multiple_dropdowns.php file search line with this: $out.='<tr><td align="right" class=main><b>'.$attributes[$o]['oname'].":</b></td><td class=main>".tep_draw_pull_down_menu('id['.$attributes[$o]['oid'].']',array_values($attributes[$o]['ovals']), $attributes[$o]['default'], "onchange=\"stkmsg(this.form);\"")."</td></tr>\n"; replace stkmsg(this.form) for showPrice(this.form);showPrice1(this.form) for me ok!! Quote Link to comment Share on other sites More sharing options...
tejure Posted September 19, 2008 Share Posted September 19, 2008 I have the solution!!! In pad_multiple_dropdowns.php file search line with this: $out.='<tr><td align="right" class=main><b>'.$attributes[$o]['oname'].":</b></td><td class=main>".tep_draw_pull_down_menu('id['.$attributes[$o]['oid'].']',array_values($attributes[$o]['ovals']), $attributes[$o]['default'], "onchange=\"stkmsg(this.form);\"")."</td></tr>\n"; replace stkmsg(this.form) for showPrice(this.form);showPrice1(this.form) for me ok!! Sorry, the correct instruccion is: "onchange=\"stkmsg(this.form);showPrice(this.form);showPrice1(this.form);\"" ok Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.