Zen Cart Logo
Forums / All Other Contributions/Addons / Stocks by attributes

Stocks by attributes

Locked

Views: 251,301

Results 661 to 680 of 1,126
This thread is locked. New replies are disabled.
25 Mar 2009, 2:11 AM
#661
jettrue avatar

jettrue

Totally Zenned

Join Date:
Jan 2005
Location:
USA, St. Louis
Posts:
3,651
Plugin Contributions:
5

Stocks by attributes

kellan4459:

I made a single SQL statement change that does the behavior that I was looking for in my original post. After reading some posts by Grayson I think I was able to do this properly. The version of zencart I have has since replaced main_template_vars_attributes.php with just attributes.php. What I wanted to do was prevent the option from showing if the individual product-option qty was 0. I made the following modification using a LEFT JOIN and then doing a check whether the quantity is greater than zero or IS NULL within the same sql statement. If > 0 then the individual product-option has qty available. If it IS NULL then there is not an entry for this product-option and it should be using the Main Item Qty.

$sql= "SELECT pov.products_options_values_id,
pov.products_options_values_name,
pa.,
pwas.

FROM " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_ATTRIBUTES . " pa LEFT JOIN " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pwas ON pwas.stock_attributes = pa.products_attributes_id
WHERE pa.products_id = '" . (int)$_GET['products_id'] . "'
and pa.options_id = '" . (int)$products_options_names->fields['products_options_id'] . "'
and (pwas.quantity > 0 or pwas.quantity IS NULL)
and pa.options_values_id = pov.products_options_values_id
and pov.language_id = '" . (int)$_SESSION['languages_id'] . "' " .
$order_by;

> 
> 
> 
> Do any of the senior zenners see any potential problems with this?  Are there other areas that could potentially be broken by this modification that I may have missed?  
> 
> Thanks
I'm trying to get a method where the drop down menu shows how many of each available items there are, but AT THE SAME doesn't show any zero items at all. I can only seem to get one or the other to work.

Does anyone have it to where ZERO options don't show up, but the drop down menu tells you how many for each that ARE available?

If someone has this working, would you mind attaching your attributes.php file?
Thanks!
Thanks!
26 Mar 2009, 12:43 PM
#662
surrealdesign avatar

surrealdesign

New Zenner

Join Date:
Jan 2009
Posts:
6
Plugin Contributions:
0

Re: Stocks by attributes

I second Jettrue, I'm trying to do the same, I just cannot get it to work....

If someone has their php file would be massively appreciated.

Nyssa.

26 Mar 2009, 7:01 PM
#663
spetaisaac avatar

spetaisaac

New Zenner

Join Date:
May 2008
Location:
E. Stroudsburg, PA
Posts:
4
Plugin Contributions:
0

Re: Stocks by attributes

I am on a Mac and using MAMP to host locally until I can get this thing built. I've used the Install SQL Patch function. I can't figure out how to upload the files correctly in my LOCAL directory.

"If you are installing onto a new install or upgrade of Zen Cart 1.3.5 or later then with most good FTP programs (such as FileZilla) you can simply drag and drop the admin and includes directories into the root directory of your site. The files are already arranged in their directory structure."

I tried grag and drop into my local folders at /Applications/MAMP/htdocs/NAME OF MY SITE/ but I can no longer log in afterwards. I tried using FileZilla and Fetch but can't seem to find the local direrctory. Any help with a step by step would be great. My co. is trying to sell off year dated shirts so I need this to work.

26 Mar 2009, 7:03 PM
#664
spetaisaac avatar

spetaisaac

New Zenner

Join Date:
May 2008
Location:
E. Stroudsburg, PA
Posts:
4
Plugin Contributions:
0

Re: Stocks by attributes

One more thing - I've been on this for 8 hours now and have read all 67 pages of this thread. A case of your fav. beverage to the person who solves this for me.

27 Mar 2009, 12:33 PM
#665
jettrue avatar

jettrue

Totally Zenned

Join Date:
Jan 2005
Location:
USA, St. Louis
Posts:
3,651
Plugin Contributions:
5

Re: Stocks by attributes

SurrealDesign:

I second Jettrue, I'm trying to do the same, I just cannot get it to work....

If someone has their php file would be massively appreciated.

Nyssa.

I actually got it myself. I just add an if statement right before the section where the drop menu items are created. Anyway, I'm attaching my includes/modules/attributes.php. Use at your own risk and please test. This one will show how many items in stock in the drop down, but will NOT show a drop down item if its not in stock. I'm using the multiadd version, so I'm not sure if its compatible if you're using the other.

If you want to just replace what I've changed, here's my chunk starting $sql starting around line 79 in my file, and ending RIGHT BEFORE this line:

if (((CUSTOMERS_APPROVAL == '2' and $_SESSION['customer_id'] == '') or (STORE_STATUS == '1')) or ((CUSTOMERS_APPROVAL_AUTHORIZATION == '1' or CUSTOMERS_APPROVAL_AUTHORIZATION == '2') and $_SESSION['customers_authorization'] == '') or (CUSTOMERS_APPROVAL == '2' and $_SESSION['customers_authorization'] == '2') or (CUSTOMERS_APPROVAL_AUTHORIZATION == '2' and $_SESSION['customers_authorization'] != 0) ) {

Here's my chunk:

$sql=	"SELECT  pov.products_options_values_id,
        pov.products_options_values_name,
        pa.*,
        pwas.*
        FROM   " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_ATTRIBUTES . " pa LEFT JOIN " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pwas ON pwas.stock_attributes = pa.products_attributes_id
        WHERE   pa.products_id = '" . (int)$_GET['products_id'] . "'
        and    pa.options_id = '" . (int)$products_options_names->fields['products_options_id'] . "'
		and    (pwas.quantity > 0 or pwas.quantity IS NULL)
        and    pa.options_values_id = pov.products_options_values_id
              and       pov.language_id = '" . (int)$_SESSION['languages_id'] . "' " .
		$order_by;

  
                $products_options = $db->Execute($sql);

                $products_options_value_id = '';
                $products_options_details = '';
                $products_options_details_noname = '';
                $tmp_radio = '';
                $tmp_checkbox = '';
                $tmp_html = '';
                $selected_attribute = false;

                $tmp_attributes_image = '';
                $tmp_attributes_image_row = 0;
                $show_attributes_qty_prices_icon = 'false';
                while (!$products_options->EOF) {
                  // reset
                  $products_options_display_price='';
                  $new_attributes_price= '';
                  $price_onetime = '';
                  
                  

if($products_options->fields['quantity'] > 0)
{
	$products_text_to_use = $products_options->fields['products_options_values_name'] . " (" .  $products_options->fields['quantity'] . " Available)"; //yes Available is improperly hard coded 
	} 
	else 
	{
	$products_text_to_use = $products_options->fields['products_options_values_name'];
}


if($products_options->fields['quantity'] > 0)
{
   $products_options_array[] = array('id' => $products_options->fields['products_options_values_id'],
   'text' => $products_text_to_use);
    }
    else
    {}
27 Mar 2009, 1:56 PM
#666
jettrue avatar

jettrue

Totally Zenned

Join Date:
Jan 2005
Location:
USA, St. Louis
Posts:
3,651
Plugin Contributions:
5

Re: Stocks by attributes

Never mind that, my version causes a problem if you don't define a value for every attribute you enter. Which is why I guess you have to have one or the other. Will see if I can figure something out. :smile:

27 Mar 2009, 2:18 PM
#667
ptownkid avatar

ptownkid

New Zenner

Join Date:
Jul 2008
Posts:
25
Plugin Contributions:
0

Re: Stocks by attributes

So I'm using the radio button version of this but i have one small problem, people don't have to choose one of the radio buttons to continue. So I'm getting orders with no attributes assigned...

Easy fix?

27 Mar 2009, 7:49 PM
#668
ptownkid avatar

ptownkid

New Zenner

Join Date:
Jul 2008
Posts:
25
Plugin Contributions:
0

Re: Stocks by attributes

No one...I'm dying here and my eyes can't take any more reading after 3 hours of it.

27 Mar 2009, 7:51 PM
#669
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Stocks by attributes

Don't know the answer personally, but you are looking in the wrong place. This isn't something that the Stock by Attributes add-in would have any influence over.

27 Mar 2009, 7:52 PM
#670
ptownkid avatar

ptownkid

New Zenner

Join Date:
Jul 2008
Posts:
25
Plugin Contributions:
0

Re: Stocks by attributes

Oh...didn't realize that. Any hint on where i should be looking?

27 Mar 2009, 7:56 PM
#671
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Stocks by attributes

Probably here

27 Mar 2009, 7:59 PM
#672
ptownkid avatar

ptownkid

New Zenner

Join Date:
Jul 2008
Posts:
25
Plugin Contributions:
0

Re: Stocks by attributes

Sorry for being daft and thank you very much.

27 Mar 2009, 8:00 PM
#673
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Stocks by attributes

Not at all. There's a bewildering amount of information on this forum, even for those of use who've been here a while and know our way around.

31 Mar 2009, 4:52 AM
#674
robrem avatar

robrem

New Zenner

Join Date:
Mar 2009
Location:
Taos, NM
Posts:
19
Plugin Contributions:
0

Re: Stocks by attributes

jettrue:

Never mind that, my version causes a problem if you don't define a value for every attribute you enter. Which is why I guess you have to have one or the other. Will see if I can figure something out. :smile:

I too would like to display the quantity available for each attribute. It seems that someone has worked this out but can't get it to not display attributes with zero qty. Does the attribute display show 0? If it does I'd be interested in making that addition. It's probably in this thread somewhere, anyone know how to find it or post it again?
Thanks a bunch.

10 Apr 2009, 10:54 AM
#675
website_rob avatar

website_rob

Inactive

Join Date:
Oct 2006
Location:
Alberta, Canada
Posts:
4,572
Plugin Contributions:
0

Re: Stocks by attributes

When customers place an item in their cart and then view the cart it tells the user that the item is no longer in stock and they must change either the amount or size before checking out.

It would be preferable that the module removes that attribute from the product detail page so that the customer can not add the product to the cart in the first place.

I have not read all 60+ pages of this thread so forgive me if it was already mentioned. Just point me to where.

Or, is this feature perhaps upcoming in a future release?

If a contribution is needed or desired to facilitate the coding required, just let me know. :smile:

12 Apr 2009, 1:35 AM
#676
laurenjj avatar

laurenjj

New Zenner

Join Date:
Sep 2008
Posts:
80
Plugin Contributions:
0

Re: Stocks by attributes

Please forgive me if this was answered somewhere in here but more than anything, I just want to know what I'm missing (if anything). I initially installed this mod so that I could make sure that no one added an item that was out of stock, into their shopping cart. The problem (as I believe was noted elsewhere in this thread...or not) is that while a warning comes up when they add the variant to their basket, it still allows the variant to be added...which I don't want...because I don't want to have to send emails to customers explaining why they were allowed to pay for an item that isn't in stock. The only way I have been able to get around this is to not use the mod at all, and rather I just go into the Attribute Controller and set whatever variant it is to 'display only'.

So I assumed the only real reason to use THIS mod was to track inventory for yourself, not really prevent items that are out of stock from being ordered.

The reason why I'm back trying to get it working now is because I'm trying to install the Drop Down Attributes mod and one of the requirements is that the Stock by Attributes mod be installed and working...and that's where I'm stuck.

??
Thanks,
Lauren

12 Apr 2009, 1:51 AM
#677
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Stocks by attributes

Website Rob:

When customers place an item in their cart and then view the cart it tells the user that the item is no longer in stock and they must change either the amount or size before checking out.

It would be preferable that the module removes that attribute from the product detail page so that the customer can not add the product to the cart in the first place.Indeed it would.

When there is only one attribute available it's relatively straightforward to link stock to an attribute on the product page and either display it or suppress it.

With two or more attributes on a product, it gets more difficult as the cart needs some knowledge of the selections being made by the customer. As the mod has its roots back in osCommerce and long before AJAX had been conceived, it wasn't really designed for this. But a few people have done things in this direction. Since Zen Cart 2.0, with attribute stock, is imminent, I have no plans to do further work on this mod, though it being open source, anybody else is welcome to do so.

12 Apr 2009, 1:55 AM
#678
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Stocks by attributes

laurenjj:

So I assumed the only real reason to use THIS mod was to track inventory for yourself, not really prevent items that are out of stock from being ordered.If properly installed, then the option to prevent customers from checking out is a key feature of the attribute stock mod. This can be set by tweaking the settings on the Admin > Configuration > Stock page.

12 Apr 2009, 5:28 AM
#679
laurenjj avatar

laurenjj

New Zenner

Join Date:
Sep 2008
Posts:
80
Plugin Contributions:
0

Re: Stocks by attributes

kuroi:

If properly installed, then the option to prevent customers from checking out is a key feature of the attribute stock mod. This can be set by tweaking the settings on the Admin > Configuration > Stock page.
:cry:
Well I guess mine isn't installed correctly because I set the option to 'false' and it's still letting me checkout :( Not sure where I could have gone wrong though... :(

14 Apr 2009, 11:58 PM
#680
laurenjj avatar

laurenjj

New Zenner

Join Date:
Sep 2008
Posts:
80
Plugin Contributions:
0

Re: Stocks by attributes

I installed (or believe I did correctly) the 'Stock by Attributes' mod. And things seemed to work. BUT, I wanted to make sure that a person couldn't check out with an unavailable item in their basket. So I made sure the option in the configuration -> stock 'Allow Checkout' was set to FALSE but this didn't do anything as I was able to still checkout.

So my next plan was to try and implement the 'make the specific stock item disappear from the drop down list when the stock for THAT attribute is 0.' And I followed directions and believe I pieced together the code as well as possible, but since nothing has changed, I have to assume that I messed up somewhere.

Since I have gone back and forth and from 'fix' to 'fix' I have no clue where I may or may not have made a mistake. Sooooo....I figure the best thing to do is reverse the entire process but since I've never reversed anything else, I have no idea the proper way to do this.

Can anyone help???????????????????????????:cry: