Jump to content
zonetown

[Contribution] QTpro - Quantity Tracking Professional

Recommended Posts

Sigh. I'm back at it again.

 

My wife still hasn't gone live with her store, thank Heaven. We seem to find little anomalies every time we try to do something.

 

This time, QTPro (using my slightly-modified pad_sequenced_dropdowns_qty.php) allows us to add an available quantity of product. When I look at it in the shopping cart, however, it's marked out of stock.

 

This particular product has a non-tracked addon; when I comment out the code for the non-tracked option, the shopping cart shows that the product is in stock. (Eri just added it to a stocked product that's been working well for a while.)

 

I tracked down part of the problem: in the pad_*, it's calling tep_check_stock("40", 1, array(25,55)). At the shopping cart, it's calling tep_check_stock("40{8}25{4}55{9}56", 1, array(25,55,56)). I modified the call so it uses tep_get_prid(), changing it to tep_check_stock("40", 1, array(25,55,56)). The problem persists.

 

I've checked the pad_base.php, and it does some wild stuff to retrieve all the stocked-attribute combinations. Can somebody tell me the magic SQL/php incantation to remove the non-stocked attribute(s) from a list of attributes?


If this were easy, everybody would do it.

Share this post


Link to post
Share on other sites
I tracked down part of the problem: in the pad_*, it's calling tep_check_stock("40", 1, array(25,55)). At the shopping cart, it's calling tep_check_stock("40{8}25{4}55{9}56", 1, array(25,55,56)). I modified the call so it uses tep_get_prid(), changing it to tep_check_stock("40", 1, array(25,55,56)). The problem persists.

 

Yeah, that's not even part of my problem. tep_check_stock() calls tep_get_products_stock(), which does its own tep_get_prid(). It even does the SQL I was trying to figure out.

 

I think I have manged to trace it down, though: the products page calls the function in attribute ID order: (4-25,8-43),(4-25,8-39)... while the cart is calling it in reverse order (8-39,4-25).


If this were easy, everybody would do it.

Share this post


Link to post
Share on other sites

Thanks for the reply above : )

 

I get this error or my product_info.php page after uploading the new product _info.php page

 

Warning: main(includes/classes/pad_PRODINFO_ATTRIBUTE_PLUGIN.php): failed to open stream: No such file or directory in /var/www/html/product_info.php on line 163

 

Fatal error: main(): Failed opening required 'includes/classes/pad_PRODINFO_ATTRIBUTE_PLUGIN.php' (include_path='.:/php/includes:/usr/share/php') in /var/www/html/product_info.php on line 163

 

Cheers for the help

-Dyno66

 

Thanks for the reply above : )

 

I get this error or my product_info.php page after uploading the new product _info.php page

 

Warning: main(includes/classes/pad_PRODINFO_ATTRIBUTE_PLUGIN.php): failed to open stream: No such file or directory in /var/www/html/product_info.php on line 163

 

Fatal error: main(): Failed opening required 'includes/classes/pad_PRODINFO_ATTRIBUTE_PLUGIN.php' (include_path='.:/php/includes:/usr/share/php') in /var/www/html/product_info.php on line 163

 

Sorry for posting this I just found the cause of problem. I didn't install config.sql doh!

 

Anyhow Cheers for the help

-Dyno66

Share this post


Link to post
Share on other sites
I think I have manged to trace it down, though: the products page calls the function in attribute ID order: (4-25,8-43),(4-25,8-39)... while the cart is calling it in reverse order (8-39,4-25).

tep_check_stock()/tep_get_products_stock() don't care what order the attributes are in the array passed to them. The SQL products_options_id in ($options_list) doesn't care about order and the order by products_options_id gets things in the right order to build the key to the products_stock table. And as you noticed non-stocked attributes are filtered out when building the key to the products_stock table.

 

I've checked the pad_base.php, and it does some wild stuff to retrieve all the stocked-attribute combinations.

The wild stuff is building the attribute combinations. A recursive call is required to build the attribute combinations because its unknown how many attributes a product has and SQL just doesn't handle that.

 

I'm puzzled as to what your problem is. I have some pretty good test cases for combinations of stocked and non-stocked options. The only thing I can think of is an option was added as a stocked option, stock was added using it and then the option was changed to non-stocked. That would leave an orphan entry in the products_stock table that can fool the logic in pad_sequenced_dropdowns that might allow it to add an out of stock attribute combination to the cart. I actually think it would behave differently though. And it sounds like you are dealing with an attribute combination that is in stock.

Share this post


Link to post
Share on other sites

Hi there, I'm starting a clothing store and want to know if this is the right contribution for me. I cant seem to find a demo.

 

I need to have a drop down box with different sizes in it eg

 

xxs

xs

s

m

L

 

but if all the "xs" shirts are sold out then I want the drop down to automatically look like this

 

xxs

xs (sold out)

s

m

L

 

does QTpro let me do this?

 

Josh

Edited by jaminunit

Share this post


Link to post
Share on other sites
Hi there, I'm starting a clothing store and want to know if this is the right contribution for me. I cant seem to find a demo.

 

I need to have a drop down box with different sizes in it eg

 

xxs

xs

s

m

L

 

but if all the "xs" shirts are sold out then I want the drop down to automatically look like this

 

xxs

xs (sold out)

s

m

L

 

does QTpro let me do this?

 

Josh

yes.

Share this post


Link to post
Share on other sites
tep_check_stock()/tep_get_products_stock() don't care what order the attributes are in the array passed to them. The SQL products_options_id in ($options_list) doesn't care about order and the order by products_options_id gets things in the right order to build the key to the products_stock table. And as you noticed non-stocked attributes are filtered out when building the key to the products_stock table.

Ralph, I actually found this myself last night and edited my post. I don't know where the edit went, though; if it had actually worked, you wouldn't have wasted any more time on this.

 

The problem was a misplaced single quote. (I don't know where it came from; perhaps I was careless while adding all those contributions, but I don't think so. Maybe it was something I did while debugging.) When tep_get_products_stock() builds its SQL query, there's a bit that looks like:

... and language_id='" . $languages[whatever] . "order by products_option_id'"

Note the single ending quote at the very end. (I don't have my computer on-hand, or this would be much more accurate. Like last night's edit. :P ) Note also that there's no space before the "order".

 

That built a query like:

... and language_id='englishorder by products_option_id'

But I didn't notice for two and a half hours. I added debugging print statements, which consistently told me that "4,8" got sorted properly, but "4,8,9" got sorted in reverse. Throwing in ASC and DESC didn't have any effect at all (of course). Frankly, I'm surprised it returned anything, since that language_id clause shouldn't have matched anything. But it did.

 

When I moved the single quote before the "order" and added a space, everything automagically started working. Amazing: SQL actually performs as expected when you create a syntactically correct query.

 

Incidentally, is there some reason we don't add " and products_option_track_stock=1" to the query, and just eliminate all the non-tracked attributes there? That would allow us to remove the "all_non_tracked" variable, too.

 

The wild stuff is building the attribute combinations. A recursive call is required to build the attribute combinations because its unknown how many attributes a product has and SQL just doesn't handle that.

I understand -- it's just that recursive stuff can make your (particularly my) head spin. My level of PHP familiarity just compounds the problem. If this was Java, now...

 

I'm puzzled as to what your problem is. I have some pretty good test cases for combinations of stocked and non-stocked options. The only thing I can think of is an option was added as a stocked option, stock was added using it and then the option was changed to non-stocked. That would leave an orphan entry in the products_stock table that can fool the logic in pad_sequenced_dropdowns that might allow it to add an out of stock attribute combination to the cart. I actually think it would behave differently though. And it sounds like you are dealing with an attribute combination that is in stock.

It is in stock, it was just being returned as "8-25,4-55" instead of the right way round -- in the shopping cart only, since it was passing all three attributes, while the pad_sequenced_dropdowns only passes the stocked ones.

 

Incidentally, marvelous work with the class hierarchy thing. I've already extended it to include a quantity box (although of course a customer could then enter more stock than I have available), and I'm planning on extending it with pictures and stuff. Easy as pie. :thumbsup:


If this were easy, everybody would do it.

Share this post


Link to post
Share on other sites
The problem was a misplaced single quote. (I don't know where it came from; perhaps I was careless while adding all those contributions, but I don't think so. Maybe it was something I did while debugging.) When tep_get_products_stock() builds its SQL query, there's a bit that looks like:

... and language_id='" . $languages[whatever] . "order by products_option_id'"

Note the single ending quote at the very end. (I don't have my computer on-hand, or this would be much more accurate. Like last night's edit. :P ) Note also that there's no space before the "order".

Nice catch. That's definitely a bug. I'll have to work up a test case to replicate your problem and get a patched version out when I get a breather from holiday ramp up.

 

Thanks for the kind words on the class structure. Good luck with your site.

Share this post


Link to post
Share on other sites

Hi,

 

I have searched through this thread and I need a bit of help. I am attempting to use this contribution on a downloadable product. I have installed and it appears to not hinder anything, but it won't reduce the stock when an item is sold and it won't register that a particular item is sold out. Lets say that I have 10 distinct files I want them to only able to be purchased one time each.

 

I have tried a number of different settings and just not getting good results. I did read that there were some issues with downloads. Have these been resolved?

 

Is it possible to use this contribution for downloadable items? If so, the best way to configure the attributes?

 

Thanks

 

Tim

Share this post


Link to post
Share on other sites
Hi,

 

I have searched through this thread and I need a bit of help. I am attempting to use this contribution on a downloadable product. I have installed and it appears to not hinder anything, but it won't reduce the stock when an item is sold and it won't register that a particular item is sold out. Lets say that I have 10 distinct files I want them to only able to be purchased one time each.

 

I have tried a number of different settings and just not getting good results. I did read that there were some issues with downloads. Have these been resolved?

 

Is it possible to use this contribution for downloadable items? If so, the best way to configure the attributes?

 

Thanks

 

Tim

Stock is not tracked for downloadable products with QT Pro just like in base osCommerce. This would require mods in several places as the stock reduction/addition is somewhat scattered about in osCommerce.

Share this post


Link to post
Share on other sites
Stock is not tracked for downloadable products with QT Pro just like in base osCommerce. This would require mods in several places as the stock reduction/addition is somewhat scattered about in osCommerce.

 

I think I maybe able to use this but I need an idea about how to mask the option value from the site and only have it appear on the invoice. I could make an item with 10 different option values ( like a serial number) and not display until someone got the checkout confirmation/ invoice email.

 

Any ideas about how I can make that happen?

 

 

Tim

Share this post


Link to post
Share on other sites
I think I maybe able to use this but I need an idea about how to mask the option value from the site and only have it appear on the invoice. I could make an item with 10 different option values ( like a serial number) and not display until someone got the checkout confirmation/ invoice email.

 

Any ideas about how I can make that happen?

Tim

This contribution would just complicate what you are trying to do. I think I would set up a downloadable product using base osC. Then tweak the download section of checkout_process.php to use the file name in the products_attributes_download, generate the next file name, save it back to products_attributes_download and decrement the stock. If your file names have a prefix followed by a sequential number this should be pretty easy. You'll need to tweak product_info.php to change the option dropdown to a hidden field as well.

Share this post


Link to post
Share on other sites

I would like to add a javascript function to the QT Pro dropdown. Where should I look...in the code or a link to an existing reply/topic would be helpful. Many Thanks,

Tim

Share this post


Link to post
Share on other sites
I would like to add a javascript function to the QT Pro dropdown. Where should I look...in the code or a link to an existing reply/topic would be helpful. Many Thanks,

Tim

Depends on which dropdown. For multiple dropdowns look at catalog/includes/classes/pad_multiple_dropdowns. In method _draw_stocked_attributes the dropdown html is generated. It includes an onchange to call a javascript function stkmsg to display an out of stock message if the selected combination is out of stock. You can change that to call your javascript and have your javascript call stkmsg.

 

If its the single dropdown look at catalog/includes/classes/pad_single_dropdown. In method _draw_stocked_attributes the dropdown html is generated. It does not have an onchange. Add your onchange to it. Look at pad_multiple_dropdowns for an example of how that is done.

Share this post


Link to post
Share on other sites

Hi everyone,

 

I have installed this module and all seems to work fine on the admin side and the product info pages, but the problem is that when items are sold it does not update the stock levels.

 

I have also installed the "nochexapc" and the "points module 1.5" - im not sure if they've intefered with eachother or are just incompatible.

 

Im now completely stuck as to what to do, so if anyone can help, or has used these contributions together successfully, id appreciate your guidance.

 

Thanks.

 

Regards,

 

Dan.

Share this post


Link to post
Share on other sites

just noticed a problem

 

i have product-info where i have a radio-set with 2 options, BLACK and RED.... the problem is that if i click 'add to cart' without selecting a radio-set option then it still adds to cart (no atrributes show, just the item)

 

if i then return and add another non-selected item to cart, it shows up as ** item doesn't exist in quantities desired

 

however, if i select an option from the radio-set and 'add to cart' it properly shows the product name AND attribute

 

can anyone please tell me how to get a javascript pop-up (like the one that says 'SOLD OUT'), but for it to appear when someone presses 'add to cart' WITHOUT selecting an attribute.

 

It should say something like 'you have not selected an option, please select an option from the choices listed'

 

can anyone please please help??


Upon receiving fixes and advice, too many people don't bother to post updates informing the forum of how it went. Until of course they need help again on other issues and they come running back!

 

Why receive the information you require in good faith for free, only to then have the attitude to ignore the people who gave it to you?

 

There's no harm in saying, 'Thanks, it worked'. On the contrary, it creates a better atmosphere.

 

CHOOCH

Share this post


Link to post
Share on other sites

As im new to php im probably speaking rubbish, but why not simply set one radio box to be selected by default?

 

In html its easily done. id imagine its the same in php?

 

Dan.

 

 

 

 

just noticed a problem

 

i have product-info where i have a radio-set with 2 options, BLACK and RED.... the problem is that if i click 'add to cart' without selecting a radio-set option then it still adds to cart (no atrributes show, just the item)

 

if i then return and add another non-selected item to cart, it shows up as ** item doesn't exist in quantities desired

 

however, if i select an option from the radio-set and 'add to cart' it properly shows the product name AND attribute

 

can anyone please tell me how to get a javascript pop-up (like the one that says 'SOLD OUT'), but for it to appear when someone presses 'add to cart' WITHOUT selecting an attribute.

 

It should say something like 'you have not selected an option, please select an option from the choices listed'

 

can anyone please please help??

Share this post


Link to post
Share on other sites
As im new to php im probably speaking rubbish, but why not simply set one radio box to be selected by default?

 

In html its easily done. id imagine its the same in php?

 

Dan.

i have options to offer.. the customer can choose which option they want

 

i think the default QTPro probably has the same problem..

 

 

any advice please anyone?


Upon receiving fixes and advice, too many people don't bother to post updates informing the forum of how it went. Until of course they need help again on other issues and they come running back!

 

Why receive the information you require in good faith for free, only to then have the attitude to ignore the people who gave it to you?

 

There's no harm in saying, 'Thanks, it worked'. On the contrary, it creates a better atmosphere.

 

CHOOCH

Share this post


Link to post
Share on other sites
i have options to offer.. the customer can choose which option they want

 

i think the default QTPro probably has the same problem..

any advice please anyone?

There is always an item selected in a dropdown list. You must have a blank option in your list.

Share this post


Link to post
Share on other sites
There is always an item selected in a dropdown list. You must have a blank option in your list.

can you please tell me what the code should be? i guess i must have missed it out or done something that is not letting that happen

 

thanks


Upon receiving fixes and advice, too many people don't bother to post updates informing the forum of how it went. Until of course they need help again on other issues and they come running back!

 

Why receive the information you require in good faith for free, only to then have the attitude to ignore the people who gave it to you?

 

There's no harm in saying, 'Thanks, it worked'. On the contrary, it creates a better atmosphere.

 

CHOOCH

Share this post


Link to post
Share on other sites
can you please tell me what the code should be? i guess i must have missed it out or done something that is not letting that happen

 

thanks

There is no code to post. Either you have setup a color with a blank name that is showing up in your dropdown or you have tweaked _draw_stocked_attributes in one of the pad_... plugins to make it generate an extra entry at the beginning of the dropdown.

Share this post


Link to post
Share on other sites
There is no code to post. Either you have setup a color with a blank name that is showing up in your dropdown or you have tweaked _draw_stocked_attributes in one of the pad_... plugins to make it generate an extra entry at the beginning of the dropdown.

i only have radio-sets, eg with 2 options for T-Shirts (one is black an the other is red)

 

when product info.php is opened, the layout is fine and everything work fine, the two radio-set buttons options show the options too BUT as no option is selected by default, it is possible to iuse add to cart to add an attributeless item to cart!!

 

can this be changed by default to choose one one option (ie first radio-set option BLACK?)

 

the reason i request this is because if neither the BLACK or RED choices are selected and the 'add to cart' button is pressed then it does add the item but with no attributes to the cart

 

yes there maybe an error on my part in the coding but it will take too long to rectify it (and finding it will be a nightmare), i just want to see if it is possible to have a radio-set option selected by default as this will help me...

 

can anyone help out with a default selection (so there is one attribute selected when customer gets on the product info.php)

 

can anyone help me with the code please

Edited by chooch

Upon receiving fixes and advice, too many people don't bother to post updates informing the forum of how it went. Until of course they need help again on other issues and they come running back!

 

Why receive the information you require in good faith for free, only to then have the attitude to ignore the people who gave it to you?

 

There's no harm in saying, 'Thanks, it worked'. On the contrary, it creates a better atmosphere.

 

CHOOCH

Share this post


Link to post
Share on other sites
i only have radio-sets, eg with 2 options for T-Shirts (one is black an the other is red)

Doh! I've been working too many hours lately. Yes, you did say *radiosets* which can be left unselected. QT Pro will automatically select the first option in the radioset when product_info isn't invoked from the cart and it will select the option corresponding to the item clicked on if invoked from the cart. This is handled in the pad_singleradioset plugin _draw_stocked_attributes method. This line of code draws each selection in the radioset:

$out.=tep_draw_radio_field('attrcomb', $combinations[$combindex]['id'], ($combindex==$selected_combination)) . $comb['text'];

 

When ($combindex==$selected_combination) evaluates to true tep_draw_radio_field adds CHECKED to the input type="radio" html tag causing that option to be the selected option. $combindex is the index into the array of options being built starting at zero. Earlier in the code $selected_combination is set to zero then _build_attribute_combinations is called which updates it to the correct value if the page was linked to from the cart. If it didn't come from the cart its left alone at zero so that the first option is selected.

 

An easy fix to make sure an option is selected but that will break the selecting of the correct option when linked to from the cart is to replace ($combindex==$selected_combination) with true. This adds CHECKED to all options. The browser will recognize it as nonsense that all options in a radioset can be selected and select only the first one.

Share this post


Link to post
Share on other sites
Doh! I've been working too many hours lately. Yes, you did say *radiosets* which can be left unselected. QT Pro will automatically select the first option in the radioset when product_info isn't invoked from the cart and it will select the option corresponding to the item clicked on if invoked from the cart. This is handled in the pad_singleradioset plugin _draw_stocked_attributes method. This line of code draws each selection in the radioset:

$out.=tep_draw_radio_field('attrcomb', $combinations[$combindex]['id'], ($combindex==$selected_combination)) . $comb['text'];

 

When ($combindex==$selected_combination) evaluates to true tep_draw_radio_field adds CHECKED to the input type="radio" html tag causing that option to be the selected option. $combindex is the index into the array of options being built starting at zero. Earlier in the code $selected_combination is set to zero then _build_attribute_combinations is called which updates it to the correct value if the page was linked to from the cart. If it didn't come from the cart its left alone at zero so that the first option is selected.

 

An easy fix to make sure an option is selected but that will break the selecting of the correct option when linked to from the cart is to replace ($combindex==$selected_combination) with true. This adds CHECKED to all options. The browser will recognize it as nonsense that all options in a radioset can be selected and select only the first one.

ok, i know what is going on now

 

the radio-set doesn't show up for the same reason my low stock report won't, there must be some bugs in the store

 

changing the setting to true doesn't help on thisa install but has on previous ones and actually does choose the top option by default

 

i will give it another go

 

many thanks Ralph


Upon receiving fixes and advice, too many people don't bother to post updates informing the forum of how it went. Until of course they need help again on other issues and they come running back!

 

Why receive the information you require in good faith for free, only to then have the attitude to ignore the people who gave it to you?

 

There's no harm in saying, 'Thanks, it worked'. On the contrary, it creates a better atmosphere.

 

CHOOCH

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×