limor01 Posted January 12, 2005 Share Posted January 12, 2005 I've started this function but its a little stalled right now due to other demands on my time. Its the way to go for Paypal IPN as well which duplicates the stock reduction logic in a couple of places. :'( Some hints for you if I don't get back to this soon. Stock reduction logic is in catalog/checkoutprocess.php. Stock add logic is different and in catalog/admin/includes/functions/general.php function tep_remove_order. The biggest differences are how to set the products_quantity value for the overall product - maybe I should just let it go negative and eat the database call to find out if all attributes are out of stock (similar to how catalog/admin/stock.php determines what to set product_quantity to). And that the in stock flag doesn't get changed crossing zero when addding stock but does when subtracting stock. <{POST_SNAPBACK}> Hello, I am not too good in development and good in integration :-) So I will give it a try and see where it goes. Thanks!! Quote Link to comment Share on other sites More sharing options...
ElementumNick Posted January 13, 2005 Share Posted January 13, 2005 Just wanted to let everyone know that I implemented Don Mitchinson's Product Attribute Sorting fix into QT Pro's installation. I uploaded the necessary files at the QT Pro contribution page: CLICK HERE Hope this helps everyone and thanks for the wonderful contribution! Nick Quote Link to comment Share on other sites More sharing options...
♥avoisin Posted January 17, 2005 Share Posted January 17, 2005 Hi All, I'm somewhat new to the QTpro mod, so bear with me .... Can it handle multiple master/slave levels? Or just one set? Can it handle price breaks? I've seen the price_breaks on products, but what about on attributes? Has anyone tried using it with lots of variations? Say, 50k+ worth that really only stem from a few hundred option values? If so, how's the handling of so many variations done on the admin side? I ask because I had to deal with these issues for a customer, and not knowing enough about qtpro (at the time, early 2004), I built my own system. It works in the same fashion as qtpro, at least as far as I can tell. What I'm trying to determine is if I've totally reinvented the wheel or if I can help to extend qtpro's capabilities. Also, the www.vary.net/qtpro link seems to dead-end ... maybe that's just me though. Is qtpro getting rolled into MS3? Thanks tons, Scott Hartranft Quote Link to comment Share on other sites More sharing options...
ralphday Posted January 17, 2005 Share Posted January 17, 2005 Hi All, I'm somewhat new to the QTpro mod, so bear with me .... Can it handle multiple master/slave levels? Or just one set? <{POST_SNAPBACK}> If you are talking about an option that has options - no. Or are you thinking of something like the Master Products contribution where option combinations are products and you can sell a combination of products as a single master product? Can it handle price breaks? I've seen the price_breaks on products, but what about on attributes? <{POST_SNAPBACK}> QTPro changes nothing in regard to pricing. so no. Has anyone tried using it with lots of variations? Say, 50k+ worth that really only stem from a few hundred option values? If so, how's the handling of so many variations done on the admin side? <{POST_SNAPBACK}> I haven't heard of anyone trying this. The admin side would fall apart in this scenario. You add the stock for combinations one at a time and on that page it lists all of the combinations already entered. If you have stock for most of the 50K combinations the page would take a long time to generate and be pretty darn big. You'd have to scroll all the way to the bottom to enter the next combination or change stock for an existing combination. I ask because I had to deal with these issues for a customer, and not knowing enough about qtpro (at the time, early 2004), I built my own system. It works in the same fashion as qtpro, at least as far as I can tell. What I'm trying to determine is if I've totally reinvented the wheel or if I can help to extend qtpro's capabilities. <{POST_SNAPBACK}> It sounds like what you have developed has some significant features that QT Pro doesn't. It may be different enough to warrant releasing as its own contribution rather than trying to incorporate its features into QT Pro. Also, the www.vary.net/qtpro link seems to dead-end ... maybe that's just me though. <{POST_SNAPBACK}> Yes, that's a very old link for the original QT Pro developer's site that has been dead for quite a while now. Contribution descriptions can't be edited, so it lives on confusing people. Is qtpro getting rolled into MS3? <{POST_SNAPBACK}> Harald has hinted that attribute stock will be in MS3 but what path he will be taking I haven't heard. Quote Link to comment Share on other sites More sharing options...
ElementumNick Posted January 17, 2005 Share Posted January 17, 2005 Corrected link. CLICK HERE Nick :-" Quote Link to comment Share on other sites More sharing options...
♥avoisin Posted January 17, 2005 Share Posted January 17, 2005 If you are talking about an option that has options - no. Or are you thinking of something like the Master Products contribution where option combinations are products and you can sell a combination of products as a single master product? <{POST_SNAPBACK}> I don't think so. It sounds like the answer is no, as you said, to be able to do many levels, e.g. the shirt has three colors, each color has a set of sizes, each size has a set of fabrics, and each fabric can be pre-washed or not. I haven't heard of anyone trying this. The admin side would fall apart in this scenario. You add the stock for combinations one at a time and on that page it lists all of the combinations already entered. If you have stock for most of the 50K combinations the page would take a long time to generate and be pretty darn big. You'd have to scroll all the way to the bottom to enter the next combination or change stock for an existing combination. <{POST_SNAPBACK}> Ok, that makes sense - and is why I hadn't even tried to deal with the admin side yet, basically. I got it sort of working, but it's not good enough. It sounds like what you have developed has some significant features that QT Pro doesn't. It may be different enough to warrant releasing as its own contribution rather than trying to incorporate its features into QT Pro. <{POST_SNAPBACK}> Fair enough. I really hate to create yet another contribution that has similar functionality, though. Perhaps the two can merge ... Ok, so I'll open it up. Anyone that's interested in what I got, go to http://hartranft.org/catalog, log in with 12345/12345 and go to this product: Stahls->letters & numbers->pro block & varsity->varsity and play around. Let me know! If there's enough interest, I'll send it in. And if anyone wants to help me work on this contrib .... I'm sure I'd help buy beer for your troubles. Thanks, Scott Quote Link to comment Share on other sites More sharing options...
bwstyle Posted January 19, 2005 Share Posted January 19, 2005 I can not get my stock to subtract, and I have spent this morning going through every post in this thread because I did not want to post when the answer already existed. I have tried every change that i've seen posted here and nothing yet, so I am looking for your help. (I am using a 3.x version.) Here is a snippet of code from my checkout_process page, any help would be greatly appreciated. thanks! // Stock Update - Joao Correia if (STOCK_LIMITED == 'true') { if (DOWNLOAD_ENABLED == 'true') { $stock_query_raw = "SELECT products_quantity, pad.products_attributes_filename FROM " . TABLE_PRODUCTS . " p LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa ON p.products_id=pa.products_id LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad ON pa.products_attributes_id=pad.products_attributes_id WHERE p.products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"; // Will work with only one option for downloadable products // otherwise, we have to build the query dynamically with a loop $products_attributes = $order->products[$i]['attributes']; if (is_array($products_attributes)) { $stock_query_raw .= " AND pa.options_id = '" . $products_attributes[0]['option_id'] . "' AND pa.options_values_id = '" . $products_attributes[0]['value_id'] . "'"; } $stock_query = tep_db_query($stock_query_raw); } else { $stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); } if (tep_db_num_rows($stock_query) > 0) { $stock_values = tep_db_fetch_array($stock_query); // do not decrement quantities if products_attributes_filename exists if ((DOWNLOAD_ENABLED != 'true') || (!$stock_values['products_attributes_filename'])) { $stock_left = $stock_values['products_quantity'] - $order->products[$i]['qty']; } else { $stock_left = $stock_values['products_quantity']; } tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) { tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); } } } Quote Link to comment Share on other sites More sharing options...
ralphday Posted January 19, 2005 Share Posted January 19, 2005 I can not get my stock to subtract, and I have spent this morning going through every post in this thread because I did not want to post when the answer already existed. I have tried every change that i've seen posted here and nothing yet, so I am looking for your help. (I am using a 3.x version.) Here is a snippet of code from my checkout_process page, any help would be greatly appreciated. thanks! <{POST_SNAPBACK}> This doesn't have any of the QT Pro modifications in it. It looks like the base osCommerce checkoutprocess.php Quote Link to comment Share on other sites More sharing options...
gomtuu Posted January 20, 2005 Share Posted January 20, 2005 hello, i came over from the german board. there are only a few guys using qt pro. i started installing and am now looking for some changes. is it possible to delete the options from pulldown when soldout. eg i want that in the pulldown only these options are shown that are on stock. no soldout, no option to show that i cant sell. and why does qt pro dont support the product_listing? there i can also put items in the cart but no stock check is possible.is there a solution allready posted. sorry for my english, i am not using this very often! at this point: to ralph. very good work, thank you! Quote Link to comment Share on other sites More sharing options...
ralphday Posted January 20, 2005 Share Posted January 20, 2005 is it possible to delete the options from pulldown when soldout.eg i want that in the pulldown only these options are shown that are on stock. no soldout, no option to show that i cant sell. <{POST_SNAPBACK}> Yes, there are several ways to deal with that in QT Pro 4. Its not as simple as removing it from the dropdown unless there is only a single option. Take a look at the manual. It explains the four different plugins and how they each approach the problem of out of stock attribute combinations. Also, look at the admin site Configuration, Product Information for options you can set. and why does qt pro dont support the product_listing?there i can also put items in the cart but no stock check is possible.is there a solution allready posted. <{POST_SNAPBACK}> I think you mean the product listing with attributes contribution. I haven't had a need for this contribution so I haven't looked into it. Integrating with it will most likely take a bit of reengineering to deal with adding multiple items to the cart at once. I don't see working on that any time soon, sorry. Quote Link to comment Share on other sites More sharing options...
gomtuu Posted January 20, 2005 Share Posted January 20, 2005 thanks for fast answering. i have no multiple options, only one. i want to use qt pro for the stock abilities. i will just look to see if i can hide the out of stock options! Quote Link to comment Share on other sites More sharing options...
jpool Posted January 20, 2005 Share Posted January 20, 2005 hi there: I have just written a small hack to update stock and price from an excell file. it works straight into the database. Im posting this here because I have qtpro installed and this hack take care of the options, if someone wants this please let me know cheers j Quote Link to comment Share on other sites More sharing options...
gomtuu Posted January 20, 2005 Share Posted January 20, 2005 hi, i just finished installing qt pro 4.0. works fine BUT the stock is not substracted. the quantity in stock stays the same. did i forget something in admin or in the php code..? thanks greetings from germany Quote Link to comment Share on other sites More sharing options...
gomtuu Posted January 20, 2005 Share Posted January 20, 2005 again me, its getting late in germany. solved one problem, got a new. i missed one single line in the checkout_payment.php. now stock substraction works. new problem is: cant leave the checkout_shipping.php if i have more than one item. also redirect to the cart doesnt work if there insufficient stock... Quote Link to comment Share on other sites More sharing options...
gomtuu Posted January 21, 2005 Share Posted January 21, 2005 do i have to change the checkout_payment.php for qt pro 4? it doesnt work. Quote Link to comment Share on other sites More sharing options...
gomtuu Posted January 21, 2005 Share Posted January 21, 2005 i find it by myself. wasnt so difficult but little tricky. in the admin section the modules for shipping and conclusion had to be refreshed... :thumbsup: Quote Link to comment Share on other sites More sharing options...
gomtuu Posted January 22, 2005 Share Posted January 22, 2005 again me from germany. <_< i tried to change also the product_listing for putting the right option from there to cart. i had the contrib for options in product_listing allready installed. therefore i changed the current part and for one product in product_listing it worked. if there are more than one products with options than i get this message: Fatal error: Cannot redeclare class pad_single_dropdown in /catalog/includes/classes/pad_single_dropdown.php on line 46 so i cant declare this more than one time. and here are ending my php skills. does anybody know how to change this? this is the part in product_listing: //++++ QT Pro: Begin Changed code $products_id = $listing['products_id'];//(preg_match("/^\d{1,10}(\{\d{1,10}\}\d{1,10})*$/",$HTTP_GET_VARS['products_id']) ? $HTTP_GET_VARS['products_id'] : (int)$HTTP_GET_VARS['products_id']); require(DIR_WS_CLASSES . 'pad_' . PRODINFO_ATTRIBUTE_PLUGIN . '.php'); $class = 'pad_' . PRODINFO_ATTRIBUTE_PLUGIN; $pad = new $class($products_id); //echo $pad->draw1(); $lc_text_option1 = $pad->draw1(); $lc_text_option2 = $pad->draw2(); //++++ QT Pro: End Changed Code and this the single_drop_down: <?php /* QT Pro Version 4.0 pad_single_dropdown.php Contribution extension to: osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2004 Ralph Day Released under the GNU General Public License Based on prior works released under the GNU General Public License: QT Pro & CPIL 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 freezehell@hotmail.com Copyright (c) 2003 IBWO Joseph Shain, January 2003 osCommerce MS2 Copyright (c) 2003 osCommerce ******************************************************************************** *********** QT Pro Product Attributes Display Plugin pad_single_dropdown.php - Display stocked product attributes as a single dropdown with entries for each possible combination of attributes. Class Name: pad_single_dropdown This class generates the HTML to display product attributes. First, product attributes that stock is tracked for are displayed in a single dropdown list with entries for each possible combination of attributes.. Then attributes that stock is not tracked for are displayed, each attribute in its own dropdown list. Methods overidden or added: _draw_stocked_attributes draw attributes that stock is tracked for _draw_out_of_stock_message_js draw Javascript to display out of stock message for out of stock attribute combinations */ require_once(DIR_WS_CLASSES . 'pad_base.php'); class pad_single_dropdown extends pad_base { /* Method: _draw_stocked_attributes draw dropdown lists for attributes that stock is tracked for Parameters: none Returns: string: HTML to display dropdown lists for attributes that stock is tracked for */ function _draw_stocked_attributes() { global $languages_id; $out=''; $attributes = $this->_build_attributes_array(true, false); if (sizeof($attributes)>0) { $combinations = array(); $selected_combination = 0; $this->_build_attributes_combinations($attributes, $this->show_out_of_stock == 'True', $this->mark_out_of_stock, &$combinations, &$selected_combination); $combname=''; /*foreach ($attributes as $attrib) { $combname.=', '.$attrib['oname']; } $combname=substr($combname,2).':';*/ //$out.="<tr>\n"; $out.=/*' <td align="right" class=main>'.*/$combname/*"</td>\n <td class=main>"*/; $out.=tep_draw_pull_down_menu('attrcomb', $combinations, $combinations[$selected_combination]['id']); //$out.="</td>\n"; //$out.="</tr>\n"; } $out.=$this->_draw_out_of_stock_message_js($attributes); return $out; } /* Method: _draw_out_of_stock_message_js draw Javascript to display out of stock popup message if an attempt is made to add an out of stock attribute combination to the cart Parameters: $attributes array Array of attributes for the product. Format is as returned by _build_attributes_array. Returns: string: Javascript to display out of stock message for out of stock attribute combinations */ function _draw_out_of_stock_message_js($attributes) { $out=''; //$out.="<tr><td> </td><td> \n"; if (($this->show_out_of_stock == 'True') && ($this->no_add_out_of_stock == 'True')) { $out.="<script LANGUAGE=\"JavaScript\"><!--\n"; $combinations = array(); $selected_combination = 0; $this->_build_attributes_combinations($attributes, false, 'None', &$combinations, &$selected_combination); $out.=" function chkstk(frm) {\n"; // build javascript array of in stock combinations of the form // {optval1:{optval2:{optval3:1,optval3:1}, optval2:{optval3:1}}, optval1:{optval2:{optval3:1}}}; $out.=" var stk=".$this->_draw_js_stock_array($combinations)."\n"; $out.=" var instk=false;\n"; // build javascript to extract attribute values and check stock $out.=" if (frm.attrcomb.type=='select-one') {\n"; $out.=" var attrs=frm.attrcomb.value.split(',');\n"; $out.=" }\n"; $out.=" else {\n"; $out.=" for (i=0; i,frm.attrcomb.length; i++) {\n"; $out.=" if (frm.attrcomb[i].checked) {\n"; $out.=" var attrs=frm.attrcomb[i].value.split(',');\n"; $out.=" break;\n"; $out.=" }\n"; $out.=" }\n"; $out.=" }\n"; $out.=" var id=Array(" . sizeof($attributes) . ");\n"; $out.=" for (i=0; i<attrs.length; i++) {\n"; $out.=" id[i]=attrs[i].split('-')[1];\n"; $out.=" }\n"; $out.=' '; for ($i=0; $i<sizeof($attributes); $i++) { $out.='if (stk'; for ($j=0; $j<=$i; $j++) { $out.="[id[".$j."]]"; } $out.=') '; } $out.="instk=true;\n"; $out.=" return instk;\n"; $out.=" }\n"; if ($this->no_add_out_of_stock == 'True') { // js to not allow add to cart if selection is out of stock $out.=" function chksel() {\n"; $out.=" var instk=chkstk(document.cart_quantity);\n"; $out.=" if (!instk) alert('".TEXT_OUT_OF_STOCK_MESSAGE."');\n"; $out.=" return instk;\n"; $out.=" }\n"; $out.=" document.cart_quantity.onsubmit=chksel;\n"; } $out.="//--></SCRIPT>\n"; } //$out.="</td></tr>\n"; return $out; } } ?> perhaps it works with changing the $out everytime its called...??? :huh: line 46 is: class pad_single_dropdown extends pad_base { Quote Link to comment Share on other sites More sharing options...
alex_rus Posted January 22, 2005 Share Posted January 22, 2005 (edited) hi there:I have just written a small hack to update stock and price from an excell file. it works straight into the database. Im posting this here because I have qtpro installed and this hack take care of the options, if someone wants this please let me know cheers j <{POST_SNAPBACK}> Hi, can you send me this mod to "cc at compass-c dot com" or may be post it in contrib section? Thank you in advance Alexander Edited January 22, 2005 by alex_rus Quote Link to comment Share on other sites More sharing options...
ralphday Posted January 22, 2005 Share Posted January 22, 2005 again me from germany. <_< i tried to change also the product_listing for putting the right option from there to cart. i had the contrib for options in product_listing allready installed. therefore i changed the current part and for one product in product_listing it worked. if there are more than one products with options than i get this message: so i cant declare this more than one time. and here are ending my php skills. does anybody know how to change this? <{POST_SNAPBACK}> In you code you have: require(DIR_WS_CLASSES . 'pad_' . PRODINFO_ATTRIBUTE_PLUGIN . '.php'); Change that to: require_once(DIR_WS_CLASSES . 'pad_' . PRODINFO_ATTRIBUTE_PLUGIN . '.php'); That will get rid of the message. You will run into other challenges integrating this code. I assume that multiple forms, one for each product, are created by the product_listing contribution you are using. The javascript in the plugins that runs when the form is submitted to check stock uses a hard-coded form name of the form on the product_info page. You'll need to change the class constructor to accept the form name and set a class property. The change the hard-code form names to use the property. I think the other javascript that hides/displays the out of stock message and handles the sequencing in the sequenced dropdown plugin wil work ok as the form fields are reference the form they are triggered by. The one big problem will be that the javascript functions will get generated once for each product on the page. You may need to modify the draw methods to to accept a parameter to control generating the javascript functions. Don't blanket kill all javascript. Some inline javascript is generated for initial setup of the out of stock message or the dropdown sequencing. If the contribution you are using allows adding multiple products to the cart with one click of an add to cart button then it will get much more complicated due to needing option fields with unique names for each different product. Good luck and keep asking questions if you get stuck. Quote Link to comment Share on other sites More sharing options...
gomtuu Posted January 23, 2005 Share Posted January 23, 2005 dear ralph, this small change maked the script running :o . thank you so much. :thumbsup: it was the last little brick in my shop. i am adding now all the products and hope to go online tomorrow with it. when it is online i will post the link. thanks chandler :-" from germany Quote Link to comment Share on other sites More sharing options...
jpool Posted January 25, 2005 Share Posted January 25, 2005 For those who pm me, here is the code. Please feel free to do whatever you like with it jp <?php /* ///////////////////////////////////////////////////////// Stock update. Use: Update stock and price in a oscommerce database 2005 Jodie Pool [of course its not a real name] //////////////////////////////////////////////////////// INSTRUCTIONS 1. Back up your database. 2. Now, this is a bit complicated, you must create a new field in Products atributes called products_model that will be a unique identifier for each of the atributes and fill that with the values you are going to be using in the Tab Separeted file 3. Create a Tab Separeted file that will contain product name, stock and selling price this file should have no header 4. You should configure your conection file 5. Put the Tab Separeted file in name as it should in here $lines = file ('http://localhost/update.txt'); line 56. 6. There is going to be updates on this as I am still testing I hope it helps */ require_once('Connections/your_conection.php'); ?> <?php mysql_select_db($database, $conection); ?> <html> <head> <title>Stock Update</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php function calculate_total() { $q=mysql_query("SELECT products_id , sum( products_stock_quantity ) as sum FROM products_stock GROUP BY (products_id) "); if (mysql_affected_rows()>0) { While ($row=mysql_fetch_row($q)) { $up_q=mysql_query("UPDATE products Set products.products_quantity = '$row[1]' , products_last_modified = NOW() WHERE products_id = '$row[0]' "); if (mysql_affected_rows()>0){ echo "Changed Product: $row[0] stock is now: $row[1] <br>"; } }// if we found any products }// function declaration //////////////////////////////////////// //please replace with the path to the file $lines = file ('http://localhost/update.txt'); foreach ($lines as $line_num => $line) { $columns=explode("\t",$line); foreach ($columns as $column_num=> $col) { //echo " Proceso el valor $column_num ".$col." ."; switch ($column_num) { case 0: $productid[]=$col; break; case 1: $stockct[]=$col; break; case 2: $rrp[]=$col; break; } } }//clear de { } foreach ($productid as $num => $code) { if ($stockct[num] < 0) { $stockct[num]=0; //if the stock is negative in the system then update to 0. } $check_query= mysql_query("select * From products_attributes Where products_model like '$code'"); if (mysql_affected_rows()>0)//if this is true product has atributes { // Need this for stock control (new price and p_id) $new_price=$rrp[$num]; $get_p_id=mysql_query("Select products_id from products_attributes where products_model like '$code'"); $a_get_p_id=mysql_fetch_row($get_p_id); $p_id=$a_get_p_id[0]; //check if this is the master product $check_query_master= "select * From products, products_attributes Where products.products_id=products_attributes.products_id AND products.products_model like '$code'"; $res=mysql_query($check_query_master); if (mysql_affected_rows()>0) //this IF complete with the else are used to change the price in product { $pro_atr_query="UPDATE products SET products_price = $rrp[$num], products_last_modified =now() WHERE products_model like '$code'"; $rrr=mysql_query($pro_atr_query); if (mysql_affected_rows()>0) { echo "'$code' price has changed"; } else { echo "'$code' price No changes @ €'$rrp[num]' this is master prod with no updates "; } } else { //get Products_id and with this and checking that this hasn't been changed in the last hour //then we can put this price as the true one, this is nearly unnecesary, but it s here to //avoid any unplanned problems $pricee= mysql_query("Select products_price from products where products_id = '$p_id'"); if (mysql_affected_rows()>0) { $get_price=mysql_fetch_row($pricee); $price=$get_price[0]; } else { echo " Price for '$code' Not set from Products please CHECK THIS OUT !!! . $p_id not found"; } $price_change=mysql_query("Update products SET products_price = $price, products_last_modified =now() WHERE products_id like '$p_id'"); if (mysql_affected_rows()>0) { echo "'$code' price has changed FROM Products Attributes"; } else { echo "'$code' price No changes @ €'$rrp[num]"; } } //From here to $value_stock_option gathering the value that goes in products_stock_atributes $get_stk_attr="select options_id, options_values_id from products_attributes where products_model like '$code'"; $get_stk_query=mysql_query($get_atk_attr); if (mysql_affected_rows()>0) { //mysql_fetch_row transforma el resultado a array y con eso ya agrego si me hace falta $opt=mysql_fetch_row($get_stk_query)or die ("Invalid Query: ".mysql_error()); $value_stock_option= $opt[3]."-".$opt[4]; } else { echo "$code wasnt found when lookig for options_id, Options_values_id"; } //start with update in products_stock $p_idexists=mysql_query("Select * from products_stock where products_id like '$p_id' AND products_stock_attributes like '$value_stock_option' "); if (mysql_affected_rows()>0 ) { $update_q="Update products SET products_stock ='$stockct[num]', products_last_modified =now() WHERE products_id like '$p_id' AND products_stock_attributes like '$value_stock_option'"; $upq=mysql_query($update_q); echo "'$code' stock has changed to '$stockct[num]'"; } else { // $q="Insert into products_stock ( `products_stock_id` , `products_id` , `products_stock_attributes` , `products_stock_quantity` ) values ('', '$p_id', '$value_stock_option', '$stockct[num]')"; $result2=mysql_query($q); if (mysql_affected_rows()>0) { echo "'$code' stock has changed to '$stockct[num]'. New Row created in p_stk"; } else { echo "Not inserted or updated : '$code'";} // end update in products_stock }//del if si se cambio el precio del }//if we have atributes echo(" NO ATRIBUTES FOR CODE $code "); $updatequery="UPDATE SET products_quantity = $stockct[$num], products_price = $rrp[$num] WHERE products_model like '$code'"; $results2=mysql_query($updatequery) or die ("Invalid Query: ".mysql_error()); if (mysql_affected_rows() > 0) { echo "The price and stock count for ".$code." has been changed to: STK ".$stockct[$num]." RRP: ".$rrp[$num]." <br>"; } else {//product not updates 2 possible reasons product doesnt exist or no update necesary $exist_model=mysql_query("Select * from products WHERE products_model like '$code'"); if (mysql_affected_rows()>0) { echo "Product $code exists but no necesary to update"; } else { echo "product $code not found please check"; } }// del else }//del foreach //now recalculate the sotk of the master product calculate_total(); //end of calculate total unset($productid, $stockct, $rrp, $columns); mysql_free_result($exist_model); ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
gomtuu Posted January 27, 2005 Share Posted January 27, 2005 is it a known bug that an option is shown if i dont have configured one??? i was online and had the correct product with no option pulldown. same time my father checked the same product and had a pulldown with color black (product doesnt excist in black) <_< and i am online with my shop.: BREE im Quartier its only in german but the functions are samesame!! :) Quote Link to comment Share on other sites More sharing options...
jpool Posted January 27, 2005 Share Posted January 27, 2005 hi there, one of the ways to get this error is if you are using easypopulate with attributes and accidentally removed a whole column. Any way, that s what happened to me. I love the design by the way (and the purses!!) j Quote Link to comment Share on other sites More sharing options...
fixion Posted January 28, 2005 Share Posted January 28, 2005 Hi, Have an odd error, I can't see could ever have worked -but I can't figure out to fix it either.. hope you could shed some light on it.. PHP Parse error: parse error, unexpected T_ELSE in /www/customers/linuxpusher2/html/checkout_process.php on line 251 and my line 251 looks like this (it's the one with --line251--> in the beginning :) //++++ QT Pro: Begin Changed code $actual_stock_bought = $order->products[$i]['qty']; } else { if (is_array($products_attributes)) { $all_nonstocked = true; $products_stock_attributes_array = array(); foreach ($products_attributes as $attribute) { if ($attribute['track_stock'] == 1) { $products_stock_attributes_array[] = $attribute['option_id'] . "-" . $attribute['value_id']; $all_nonstocked = false; } if ($all_nonstocked) { $actual_stock_bought = $order->products[$i]['qty']; } else { asort($products_stock_attributes_array, SORT_NUMERIC); $products_stock_attributes = implode(",", $products_stock_attributes_array); $attributes_stock_query = tep_db_query("select products_stock_quantity from " . TABLE_PRODUCTS_STOCK . " where products_stock_attributes = '$products_stock_attributes' AND products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); if (tep_db_num_rows($attributes_stock_query) > 0) { $attributes_stock_values = tep_db_fetch_array($attributes_stock_query); $attributes_stock_left = $attributes_stock_values['products_stock_quantity'] - $order->products[$i]['qty']; tep_db_query("update " . TABLE_PRODUCTS_STOCK . " set products_stock_quantity = '" . $attributes_stock_left . "' where products_stock_attributes = '$products_stock_attributes' AND products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); $actual_stock_bought = ($attributes_stock_left < 1) ? $attributes_stock_values['products_stock_quantity'] : $order->products[$i]['qty']; } else { $attributes_stock_left = 0 - $order->products[$i]['qty']; tep_db_query("insert into " . TABLE_PRODUCTS_STOCK . " (products_id, products_stock_attributes, products_stock_quantity) values ('" . tep_get_prid($order->products[$i]['id']) . "', '" . $products_stock_attributes . "', '" . $attributes_stock_left . "')"); $actual_stock_bought = 0; } } --line251--> else { $actual_stock_bought = $order->products[$i]['qty']; } //++++ QT Pro: End Changed Code Quote Link to comment Share on other sites More sharing options...
smokestack Posted January 28, 2005 Share Posted January 28, 2005 Can anyone tell me the difference between QTPro & Master Products and which is the best one to use for handling attribute stock? Thank you.. 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.