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

Stocks by attributes

Locked

Views: 251,330

Results 361 to 380 of 1,126
This thread is locked. New replies are disabled.
30 Dec 2007, 11:08 AM
#361
kuroi avatar

kuroi

Totally Zenned

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

Stocks by attributes

osdude:

Is there a way to make new products add 'X' stock by default when adding attributes? I hadn't thought of this, but I will dig into the code to see if anything jumps out at me...Zen Cart's attributes system (in 1.3 and earlier) knows nothing about stock. Moreover, stock by attributes holds stock for combinations of attributes, rather than for each attribute.

So to add stock at the same time as adding an attribute, would require custom coding that reflects the specific way in which you are defining your products.

30 Dec 2007, 11:16 AM
#362
kuroi avatar

kuroi

Totally Zenned

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

Re: Stocks by attributes

cropinstop:

New (?) problem with version 4.7 on ZC1.3.8.

Did a new install of Stock by attributes 4.7 in ZC 1.3.8. Setup up the following attribute stock:

8" Scrapbook
Blue - quantity = 1
Ivory - quantity = 3

Did a test buy, and was able to order without an out of stock warning:
Blue - qty = 4, and concurrently
Ivory, qty = 4

Received an out of stock warning for Blue if I ordered 5 or Ivory if I ordered 5.
I expected it to block attempts to order more than 1 Blue. or 3 Ivory. Is this a bug in the new release, or what is wrong?In every case that I have investigated it has been due to an FTP or installation error.

Please take a look at this post and this post for an example of each. For version 4.7, the version info is updated to > * @version $Id: order.php 0000 2007-12-02 00:00:00Z kuroi $

30 Dec 2007, 11:24 AM
#363
kuroi avatar

kuroi

Totally Zenned

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

Re: Stocks by attributes

crankyjim:

frustrating problem with ver 4.3 on 1.3.6.

The quantity discounts is not calculating correctly.

item x should be 18.00 for quantity > 6. If I order 3 of one attribute set and 3 of another, the second 3 items receives the discount correctly, but the first 3 stay at the non discount price (18.50).

Have I set something incorrectly?Sorry crankyjim, I've no idea. This is the stock by attributes support thread which doesn't affect discounts, with or without attributes, in any way. I recommend doing a forum search on quantity discounts.

30 Dec 2007, 6:20 PM
#364
crankyjim avatar

crankyjim

New Zenner

Join Date:
Nov 2006
Posts:
20
Plugin Contributions:
0

Re: Stocks by attributes

Thanks for the reply.

I was thinking it might have something to do with the Stocks By Attributes add-on, since it seems to be affected by choosing the different attribute combinations. When only one attribute combination is selected, then the discounts calculate correctly.

I will keep looking. Thanks again! :)

30 Dec 2007, 9:01 PM
#365
gfunk avatar

gfunk

New Zenner

Join Date:
Mar 2007
Posts:
10
Plugin Contributions:
0

Re: Stocks by attributes

In post 188 from http://www.zen-cart.com/forum/showthread.php?t=25987&page=19 is explained how to add stock quantities to attributes on the stock info page. I just want to have the text 'in stock' or 'out of stock' next to it.

Can somebody explain me how to implement this code:

       if ($products_options->fields['quantity']) > 0) {
        $products_options_details = $products_options->fields['products_options_values_name'] . ' [' . TEXT_ATTRIBUTES_IN_STOCK . ']';
       } else {
        $products_options_details = $products_options->fields['products_options_values_name'] . ' [' . TEXT_ATTRIBUTES_NOT_IN_STOCK . ']';
       }
```with this code for drop down menus

$products_options_array[] = array('id' => $products_options->fields['products_options_values_id'],
'text' => $products_options->fields['products_options_values_name'] .' [' . $products_options->fields['quantity'] . ' '. TEXT_ATTRIBUTES_PIECES . ']');


I just need an if command to have either 
TEXT_ATTRIBUTES_IN_STOCK or TEXT_ATTRIBUTES_NOT_IN_STOCK when not in stock.

Thanks
1 Jan 2008, 12:25 AM
#366
nectarina avatar

nectarina

New Zenner

Join Date:
Dec 2007
Posts:
13
Plugin Contributions:
0

Re: Stocks by attributes

Hi i am a new Zencart user and have just intalled the Stock by attributes. Everything seem to be working correctly except that i can checkout with no stock. Does anyone know the cause and correction for this? I would be very greatful for any help.

Even though i have the Configuration>Stock>"Allow Check Out" to FALSE, i still appear to be able to check out on attributes that have no stock? Even though the warning that the out of stock warning appears ok, you can still proceed to the checkout.

I think this because i have to total stock updating (automatically) in the Catelog>Categories / Products sections. i.e if i add 10 units for size small, the total stock in Catelog>Categories / Products sections changes to 10.

Could this be something to do with running the stock attribute SQL? in the Tools>run SQL patches. When i try to run this i get the following:

" 1062 Duplicate entry 'STOCK_SHOW_LOW_IN_CART' for key 2
in:
[INSERT INTO zen_configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ('Show available stock level in cart when less than order', 'STOCK_SHOW_LOW_IN_CART', 'false', 'When customer places more items in cart than are available, show the available amount on the shopping cart page:', '9', '6', NULL, now(), NULL, "zen_cfg_select_option(array('true', 'false')," );]
If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you left no blank fields. "

1 Jan 2008, 12:29 AM
#367
kuroi avatar

kuroi

Totally Zenned

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

Re: Stocks by attributes

Nectarina

The SQL error is just telling you that you have run it once and don't need to run it again. As to the checkout issues, please read post 366 just a little way above yours.

1 Jan 2008, 5:23 AM
#368
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Stocks by attributes

I encounter a minor problem here: stock by attribute work great until I add a second att, which is readonly type. Now I always get the out of stock msg when I try to check out, any idea?

Thanks.

1 Jan 2008, 5:41 AM
#369
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Stocks by attributes

Well, I get why it doesnt work: when I add stock, this mod kinda forces me to include that readonly att as well, but on the store side, since it's a readonly att, it doesnt have any value to be passed along with the form.

Now we have to exclude readonly attributes to be counted for stock. Huhm

1 Jan 2008, 5:53 AM
#370
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Stocks by attributes

Hah, I solved my own problem, I rewrote the code a bit to put in a switch so that I can exclude readonly attributes. A quick dirty hack which can be further improved:
file edited: admin/includes/classes/products_with_attributes_stock.php
There can be a better way to do this, like putting a checkbox next to each attribute so we can check off to exclude it, but well, I need a quick solution for now.

<?php
    class products_with_attributes_stock
    {    
        function get_products_attributes($products_id, $languageId=1, $exclude_hidden=true)
        {
            global $db;
        
            $query = '    select 
                            patrib.products_attributes_id, patrib.options_values_price, patrib.price_prefix,
                             popt.products_options_name, pval.products_options_values_name
                         from '.TABLE_PRODUCTS_ATTRIBUTES.' as patrib, '.TABLE_PRODUCTS_OPTIONS.' as popt, '.TABLE_PRODUCTS_OPTIONS_VALUES.' as pval
                         where
                             patrib.products_id = "'.$products_id.'" AND patrib.options_id = popt.products_options_id
                             AND popt.language_id = "'.$languageId.'" and popt.language_id = pval.language_id
                            and patrib.options_values_id = pval.products_options_values_id';
            if($exclude_hidden)
                $query .= ' AND popt.products_options_type <> 5';
            $attributes = $db->Execute($query);
            
            if($attributes->RecordCount()>0)
            {
                while(!$attributes->EOF)
                {
                    $attributes_array[$attributes->fields['products_options_name']][] =
                        array('id' => $attributes->fields['products_attributes_id'],
                              'text' => $attributes->fields['products_options_values_name']
                                          . ' (' . $attributes->fields['price_prefix']
                                        . '$'.zen_round($attributes->fields['options_values_price'],2) . ')' );
                    $attributes->MoveNext();
                }
    
                return $attributes_array;
    
            }
            else
            {
                return false;
            }
        }
    
        function update_parent_products_stock($products_id)
        {
            global $db;

            $query = 'select sum(quantity) as quantity from '.TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK.' where products_id = "'.(int)$products_id.'"';
            $quantity = $db->Execute($query);
            $query = 'update '.TABLE_PRODUCTS.' set  products_quantity="'.$quantity->fields['quantity'].'" where products_id="'.(int)$products_id.'"';
            $db->Execute($query);
        }
    
    
        function get_attributes_name($attribute_id, $languageId=1)
        {
            global $db;

            $query = 'select patrib.products_attributes_id, popt.products_options_name, pval.products_options_values_name
                         from '.TABLE_PRODUCTS_ATTRIBUTES.' as patrib, '.TABLE_PRODUCTS_OPTIONS.' as popt, '.TABLE_PRODUCTS_OPTIONS_VALUES.' as pval
                         where patrib.products_attributes_id = "'.$attribute_id.'"
                            AND patrib.options_id = popt.products_options_id
                             AND popt.language_id = "'.$languageId.'"
                            and popt.language_id = pval.language_id
                            and patrib.options_values_id = pval.products_options_values_id';
                            
            $attributes = $db->Execute($query);
            if(!$attributes->EOF)
            {        
                $attributes_output = array('option' => $attributes->fields['products_options_name'],
                                           'value' => $attributes->fields['products_options_values_name']);
                return $attributes_output;
            }
            else
            {
                return false;
            }
        }
    }

?>
3 Jan 2008, 12:56 PM
#371
kuroi avatar

kuroi

Totally Zenned

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

Re: Stocks by attributes

@yellow1912

Thanks for posting your solution. There's plenty of scope to improve this mod. But I wouldn't recommend that anybody spend too much time on it, unless absolutely necessary (as it was for you here), as it will be rendered obsolete by Zen Cart 1.4.

3 Jan 2008, 6:54 PM
#372
arkwright avatar

arkwright

Zen Follower

Join Date:
Oct 2007
Posts:
95
Plugin Contributions:
0

Re: Stocks by attributes

Ok...

Installed this mod....

Then realised I had installed wrong version (installed version for Zen 1.38)...

Mod doesn't work, allows me to check out with more products than I have told Zen are available. Assume the problems lies with installing the wrong version...

How do I uninstall the wrong version so I can start again with the correct version...

Many thanks

Arkie...

3 Jan 2008, 7:46 PM
#373
kuroi avatar

kuroi

Totally Zenned

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

Re: Stocks by attributes

Arkwright:

realised I had installed wrong version (installed version for Zen 1.38)...

Mod doesn't work, allows me to check out with more products than I have told Zen are available. Assume the problems lies with installing the wrong version...

How do I uninstall the wrong version so I can start again with the correct version...Although there would be problems arising from installing version 4.7 instended for Zen cart 1.3.8 onto your 1.3.7 cart, from the symptoms that you describe, it sounds more like you have an incomplete installation.

Seen a few of these recently, where FTP programs appear to have copied all of the files across, but in practise haven't overwitten existing files.

The good news is that since the only changes for 1.3.8 were to files that were also in 1.3.7 and the were no database changes, you don't need to uninstall, you can simply copy the files from version 4.6 onto your site. But do check that they arrive safely by checking your FTP programs error log and the dates modified on your server.

3 Jan 2008, 9:31 PM
#374
modernm avatar

modernm

New Zenner

Join Date:
Dec 2007
Location:
Hoboken, NJ
Posts:
97
Plugin Contributions:
1

Re: Stocks by attributes

Is it possible to have the drop downs be dynamic based on stock? For example if I have shirts in sizes large and small but only have green in the small and not orange. Could the color drop downs on the product display only green if I have selected small?

3 Jan 2008, 10:05 PM
#375
kuroi avatar

kuroi

Totally Zenned

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

Re: Stocks by attributes

You might want to try the latest version of StockAttribute by danielcor which uses AJAX to dynamically update the stock levels depending upon customer selections. However, it's based on an older version of Zen Cart and a slightly buggy version of the Attribute Stock mod from which the mod to which this thread refers was derived.

3 Jan 2008, 10:06 PM
#376
arkwright avatar

arkwright

Zen Follower

Join Date:
Oct 2007
Posts:
95
Plugin Contributions:
0

Re: Stocks by attributes

kuroi:

Although there would be problems arising from installing version 4.7 instended for Zen cart 1.3.8 onto your 1.3.7 cart, from the symptoms that you describe, it sounds more like you have an incomplete installation.

Seen a few of these recently, where FTP programs appear to have copied all of the files across, but in practise haven't overwitten existing files.

The good news is that since the only changes for 1.3.8 were to files that were also in 1.3.7 and the were no database changes, you don't need to uninstall, you can simply copy the files from version 4.6 onto your site. But do check that they arrive safely by checking your FTP programs error log and the dates modified on your server.

Thanks for the reply Kuroi...

I've uploaded all the files from 4.6. Checked my FTP error log and dates modified and everything checks out ok. No errors, dates modified as they should be...

Unfortunately hasn't made any difference whatsoever to my problem.

Zencart still allows a buyer to add more products than are available and allows them to go through checkout with them..

As an aside which may or may not be connected to my problem, I assume when I add a product from scratch, I put 0 in the quantity box and then add the attribute to the product and then add stock quantities to each attribute?

If this is the correct way to list a product and it's stock levels for each attribute, then I'm at a loss as to why I'm still having this problem...

Any ideas?

Thanks
Arkie.....

3 Jan 2008, 10:10 PM
#377
kuroi avatar

kuroi

Totally Zenned

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

Re: Stocks by attributes

What settings do you have on the Admin > Configuration > Stock page?

Can you provide stock values (for product and individual attribute combinations) before and after from a purchase such as you have described?

3 Jan 2008, 10:34 PM
#378
modernm avatar

modernm

New Zenner

Join Date:
Dec 2007
Location:
Hoboken, NJ
Posts:
97
Plugin Contributions:
1

Re: Stocks by attributes

Is it possible to get what code needs to be change for tpl_shopping_cart_default.php? I have a custom template and I would like to just add what is needed. Maybe diff the default template and the file in the stock by attributes zip?

Cal

3 Jan 2008, 10:37 PM
#379
kuroi avatar

kuroi

Totally Zenned

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

Re: Stocks by attributes

modernm:

Maybe diff the default template and the file in the stock by attributes zip?Sounds like a good plan. I don't recall the changes being very big in that file, just the addition of low stock messages, I think.

4 Jan 2008, 7:25 AM
#380
arkwright avatar

arkwright

Zen Follower

Join Date:
Oct 2007
Posts:
95
Plugin Contributions:
0

Re: Stocks by attributes

kuroi:

What settings do you have on the Admin > Configuration > Stock page?

Can you provide stock values (for product and individual attribute combinations) before and after from a purchase such as you have described?

With regard to Admin>Config>Stock settings, I have them set as below:

Check stock level true
Subtract stock ** true**
Allow Checkout false
Mark product out of stock Out of stock
Stock Re-order level 5
Show available stock level in cart when less than order **true **
Products status in Catalog when out of stock should be set to **0 **
Show Sold Out Image in place of Add to Cart **1 **
Product Quantity Decimals 0 **
Show Shopping Cart - Delete Checkboxes or Delete Button 3 **
Show Shopping Cart - Update Cart Button Location 3
Show New Products on empty Shopping Cart Page ** 1

Show Featured Products on empty Shopping Cart Page 2
Show Special Products on empty Shopping Cart Page ** 3

Show Upcoming Products on empty Shopping Cart Page 4

Stock levels before purchasing a product:

Total stock 17 items broken down as follows:
Size 8 = 3
Size 10 = 3
Size 12 = 3
Size 14 = 3
size 16 = 2
Size 20 = 3

I have just carried out a test purchase on Size 10 and have ordered 6 of the 3 available.

Toatal stock now reads 11 items, but my stock figures for each attribute haven't changed at all they still read as above.

With regard to my last post, was I correct in the way I was adding a product and adding the stock levels afterwards?

The mystery deepens....

Arkie....