[ Index ] |
PHP Cross Reference of osCMax 2.0.4 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 QT Pro Version 4.1 4 5 pad_single_dropdown.php 6 7 Contribution extension to: 8 osCMax Power E-Commerce 9 http://oscdox.com 10 11 Copyright 2006 osCMax2004, 2005 Ralph Day 12 Released under the GNU General Public License 13 14 Based on prior works released under the GNU General Public License: 15 QT Pro & CPIL prior versions 16 Ralph Day, October 2004 17 Tom Wojcik aka TomThumb 2004/07/03 based on work by Michael Coffman aka coffman 18 FREEZEHELL - 08/11/2003 [email protected] Copyright 2006 osCMax2003 IBWO 19 Joseph Shain, January 2003 20 osCommerce MS2 21 Copyright 2006 osCMax 22 Modifications made: 23 11/2004 - Created 24 12/2004 - Fix _draw_out_of_stock_message_js to add semicolon to end of js stock array 25 03/2005 - Remove '&' for pass by reference from parameters to call of 26 _build_attributes_combinations. Only needed on method definition and causes 27 error messages on some php versions/configurations 28 29 ******************************************************************************************* 30 31 QT Pro Product Attributes Display Plugin 32 33 pad_single_dropdown.php - Display stocked product attributes as a single dropdown with entries 34 for each possible combination of attributes. 35 36 Class Name: pad_single_dropdown 37 38 This class generates the HTML to display product attributes. First, product attributes that 39 stock is tracked for are displayed in a single dropdown list with entries for each possible 40 combination of attributes.. Then attributes that stock is not tracked for are displayed, 41 each attribute in its own dropdown list. 42 43 Methods overidden or added: 44 45 _draw_stocked_attributes draw attributes that stock is tracked for 46 _draw_out_of_stock_message_js draw Javascript to display out of stock message for out of 47 stock attribute combinations 48 49 */ 50 require_once (DIR_WS_CLASSES . 'pad_base.php'); 51 52 class pad_single_dropdown extends pad_base { 53 54 55 /* 56 Method: _draw_stocked_attributes 57 58 draw dropdown lists for attributes that stock is tracked for 59 60 61 Parameters: 62 63 none 64 65 Returns: 66 67 string: HTML to display dropdown lists for attributes that stock is tracked for 68 69 */ 70 function _draw_stocked_attributes() { 71 global $languages_id; 72 73 $out=''; 74 75 $attributes = $this->_build_attributes_array(true, false); 76 if (sizeof($attributes)>0) { 77 $combinations = array(); 78 $selected_combination = 0; 79 $this->_build_attributes_combinations($attributes, $this->show_out_of_stock == 'True', $this->mark_out_of_stock, $combinations, $selected_combination); 80 81 $combname=''; 82 foreach ($attributes as $attrib) { 83 $combname.=', '.$attrib['oname']; 84 } 85 $combname=substr($combname,2).':'; 86 87 $out.="<tr>\n"; 88 $out.=' <td align="right" class=main><b>'.$combname."</b></td>\n <td class=main>"; 89 $out.=tep_draw_pull_down_menu('attrcomb', $combinations, $combinations[$selected_combination]['id']); 90 $out.="</td>\n"; 91 $out.="</tr>\n"; 92 } 93 94 $out.=$this->_draw_out_of_stock_message_js($attributes); 95 96 return $out; 97 } 98 99 100 /* 101 Method: _draw_out_of_stock_message_js 102 103 draw Javascript to display out of stock popup message if an attempt is made to add an out of 104 stock attribute combination to the cart 105 106 107 Parameters: 108 109 $attributes array Array of attributes for the product. Format is as returned by 110 _build_attributes_array. 111 112 Returns: 113 114 string: Javascript to display out of stock message for out of stock attribute combinations 115 116 */ 117 function _draw_out_of_stock_message_js($attributes) { 118 $out=''; 119 $out.="<tr><td> </td><td> \n"; 120 121 if (($this->show_out_of_stock == 'True') && ($this->no_add_out_of_stock == 'True')) { 122 $out.="<SCRIPT LANGUAGE=\"JavaScript\"><!--\n"; 123 $combinations = array(); 124 $selected_combination = 0; 125 $this->_build_attributes_combinations($attributes, false, 'None', $combinations, $selected_combination); 126 127 $out.=" function chkstk(frm) {\n"; 128 129 // build javascript array of in stock combinations of the form 130 // {optval1:{optval2:{optval3:1,optval3:1}, optval2:{optval3:1}}, optval1:{optval2:{optval3:1}}}; 131 $out.=" var stk=".$this->_draw_js_stock_array($combinations).";\n"; 132 $out.=" var instk=false;\n"; 133 134 // build javascript to extract attribute values and check stock 135 $out.=" if (frm.attrcomb.type=='select-one') {\n"; 136 $out.=" var attrs=frm.attrcomb.value.split(',');\n"; 137 $out.=" }\n"; 138 $out.=" else {\n"; 139 $out.=" for (i=0; i,frm.attrcomb.length; i++) {\n"; 140 $out.=" if (frm.attrcomb[i].checked) {\n"; 141 $out.=" var attrs=frm.attrcomb[i].value.split(',');\n"; 142 $out.=" break;\n"; 143 $out.=" }\n"; 144 $out.=" }\n"; 145 $out.=" }\n"; 146 $out.=" var id=Array(" . sizeof($attributes) . ");\n"; 147 $out.=" for (i=0; i<attrs.length; i++) {\n"; 148 $out.=" id[i]=attrs[i].split('-')[1];\n"; 149 $out.=" }\n"; 150 $out.=' '; 151 for ($i=0; $i<sizeof($attributes); $i++) { 152 $out.='if (stk'; 153 for ($j=0; $j<=$i; $j++) { 154 $out.="[id[".$j."]]"; 155 } 156 $out.=') '; 157 } 158 159 $out.="instk=true;\n"; 160 $out.=" return instk;\n"; 161 $out.=" }\n"; 162 163 if ($this->no_add_out_of_stock == 'True') { 164 // js to not allow add to cart if selection is out of stock 165 $out.=" function chksel() {\n"; 166 $out.=" var instk=chkstk(document.cart_quantity);\n"; 167 $out.=" if (!instk) alert('".TEXT_OUT_OF_STOCK_MESSAGE."');\n"; 168 $out.=" return instk;\n"; 169 $out.=" }\n"; 170 $out.=" document.cart_quantity.onsubmit=chksel;\n"; 171 } 172 $out.="//--></SCRIPT>\n"; 173 } 174 $out.="</td></tr>\n"; 175 176 return $out; 177 } 178 179 } 180 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Jan 1 13:43:16 2010 | Cross-referenced by PHPXref 0.7 |