Zen Cart Logo
Forums / All Other Contributions/Addons / Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Views: 658,733

Results 341 to 360 of 3,609
25 Jan 2008, 12:28 PM
#341
vivaraquel avatar

vivaraquel

Zen Follower

Join Date:
Sep 2004
Location:
Australia
Posts:
305
Plugin Contributions:
0

Stock by Attribute v4.0 addon for v1.3.5-1.3.9

I just installed this on a new site I am working on.

When I did the SPL query I got th1 error message and 1 note as follows:
Error: Cannot create table product_with _attributes_stock because it already exists ( I am assuming this is because I tried a diff mod for this earlier which uses the same table)
Note: 1 statement ignored. See upgrade exceptions table for additional details ( I assume this is because I wasn't upgrading)

I then proceeded to install the files which I did manually one at a time via FTP to make sure they were all uploaded correctly. The renamed the ones that would be overriden by adding a 1 at the end of the file name and then uploading the file of the same name. This way it will be easily undone.

Then I looked at the site http://www.cheechababy.com.au and it still looked the same so that was promising. I went to admin and the products with attributes stock option/tab is there.

I then added stock to a product (headbands) but only to the blush attribute. I then went to buy the cloud-blue for which I hadn't added any stock. I went to my cart and hit the checkout button but nothing happened, I tried again with the same result so I assume it is because that attribute has no stock so it's not allowing me to chekc it out. But it isn't telling anything.

So then I emtied the cart and added the blush attribute for which I had added 1 stock and when I went to checkout it came up with this error message:

Fatal error: Cannot redeclare class order in /home/cheechab/public_html/includes/classes/order.php on line 20
Obviously it has something to do line 20 on order.php which says this: class order extends base {

What's wrong with it?

27 Jan 2008, 1:06 PM
#342
manage_it avatar

manage_it

Inactive

Join Date:
May 2006
Posts:
80
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Is there any functionality available to restock the attributes when an order is deleted? An option appears to restock, but only the stock of the article is set back to the right value and not in the attributes stock.

I think the general.php in admin\includes\functions need to be changed?
Kuroi, is this a functionality you would like to build in?

We are selling clothes and a lot of orders are returned (clothes do not always fit) and then it is a lot of work to restock it manually.

Regards,

Bram:smile:

27 Jan 2008, 1:10 PM
#343
kuroi avatar

kuroi

Totally Zenned

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

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

vivaraquel:

I went to checkout it came up with this error message:

Fatal error: Cannot redeclare class order in /home/cheechab/public_html/includes/classes/order.php on line 20
Obviously it has something to do line 20 on order.php which says this: class order extends base {

What's wrong with it?See posts 334-337 just above.

27 Jan 2008, 1:12 PM
#344
kuroi avatar

kuroi

Totally Zenned

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

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

manage-it:

Is there any functionality available to restock the attributes when an order is deleted? An option appears to restock, but only the stock of the article is set back to the right value and not in the attributes stock.

I think the general.php in admin\includes\functions need to be changed?
Kuroi, is this a functionality you would like to build in?No. I'm afraid so., And no (please see post #1 in this thread).

27 Jan 2008, 1:36 PM
#345
vivaraquel avatar

vivaraquel

Zen Follower

Join Date:
Sep 2004
Location:
Australia
Posts:
305
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Thanks Kuroi, that did it. I had left the original order.php file ther just renamed it order1.php. Sounds absurd but hey, such are these things sometimes.

30 Jan 2008, 12:53 PM
#346
barryboy avatar

barryboy

New Zenner

Join Date:
Jan 2008
Posts:
5
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

I would like to simpy add a stock of 1 for each attribute defined for a product. Is there an easy way to do this without going through the admin screen, selecting each attribute, adding 1, submitting and then going to the next attribute?

Cheers.

31 Jan 2008, 5:56 AM
#347
yellow1912 avatar

yellow1912

Totally Zenned

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

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Kuroi, can you give me a hand here?

I'm trying to modify the order history page, so that users can add the products from previous order back to cart.

The idea is to use the multiple add to cart form of Zen, then calculate the amount in stock of each products and draw an add-to-cart input form if the stock is available.

However, I'm having a hard time with the products that have attributes. In the orders_products table they are stored like this: id:attribute_string, ie:
19:1asdjaj1902ie9ajdaodj1092iasd
Do you have any idea how to know exactly which attribute id to get the stock?

Regards

31 Jan 2008, 7:15 AM
#348
kuroi avatar

kuroi

Totally Zenned

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

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

@yellow1912

That can be done, though it's a bit complicated - no surprise there, I suspect.

Firstly, I don't believe that there's any encoding of attributes in the product_prid field used in order processing.

However there is a table dedicated to this, i.e. orders_products_attributes. Unfortunately it holds information frozen for display in the order history. It does this in case you change or delete your products after the order is completed. The customer will still be able to see details of what they purchased.

However, if you have changed or deleted a product, the customer would have a problem reloading it to their shopping cart anyway, so that's something you need to deal with, but not a show stopper.

So, your first step would be to work backwards from the products_options_values to get the relevant products_options_values_ids in the products_options_values table, then concatenate them as a common-separated string and search for that string in the stock_attributes field of the products_with_attributes_stock table.

If you find it all is fine. If you don't this could mean that the stock is being managed at product level, so you would need to check whether there are any other attribute combinations with stock for that product.

If there are, it would indicate that this attribute combination no longer exists for this product. If there are not, you would need to check whether there is a non-zero value for stock in the product table. If so, it would show that stock is being managed managed at the product level for this product.

31 Jan 2008, 9:43 AM
#349
kuroi avatar

kuroi

Totally Zenned

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

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

barryboy:

I would like to simpy add a stock of 1 for each attribute defined for a product. Is there an easy way to do this without going through the admin screen, selecting each attribute, adding 1, submitting and then going to the next attribute?Depends what you call easy. I do this by either writing SQL scripts to bulk populate the attribute stock, or more frequently by creating spreadsheets for import to the table.

31 Jan 2008, 11:02 AM
#350
kuroi avatar

kuroi

Totally Zenned

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

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Clarification

The following response to yellow1912 was rather badly worded ...

kuroi:

I don't believe that there's any encoding of attributes in the product_prid field used in order processing.should have read > I don't believe that there's any way of decoding attributes from the product_prid field used in order processing.Apologies for any confusion.

31 Jan 2008, 12:07 PM
#351
flobster avatar

flobster

New Zenner

Join Date:
Sep 2006
Posts:
76
Plugin Contributions:
1

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

I have installed this contribution and it works very well,
i have 2 questions.

i have a slight problem, on my test site i have a product which has around 10 attributes, some are in stock and some are out of stock,
when i go to the product on the cart as a customer, if i select one which is in stock on the drop down and click add to cart all is fine,

if i select one which is not in stock and then hit add to cart it goes to the cart and says out of stock which i guess i also fine,

however is it possible to update the page when each attribute is selected by the customer to display the add to cart or to display out of stock,

another way would be to have (In Stock) or (Out Of Stock) after the attribute name in the drop down.

are the above possible?

2nd question.

Is it possible to update more than one stock level at once, currently you have to select each product to update the stock level, is it possible to list the products to update all at once?

Thanks in advance
Rob

31 Jan 2008, 12:13 PM
#352
kuroi avatar

kuroi

Totally Zenned

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

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

flobster:

I have installed this contribution and it works very well,
i have 2 questions.Both of your questions have been asked and answered repeatedly in the thread above. The answers can be boiled to "it depends" and "no". There's much more detail and explanation in the earlier posts.

31 Jan 2008, 12:33 PM
#353
flobster avatar

flobster

New Zenner

Join Date:
Sep 2006
Posts:
76
Plugin Contributions:
1

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Ok i will have a good look through, sorry about that.

31 Jan 2008, 12:37 PM
#354
kuroi avatar

kuroi

Totally Zenned

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

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

flobster:

Ok i will have a good look through, sorry about that.No problem. Tips - use the search this thread facility for localised searches. For the first question, search on "Grayson" or look in the Wiki, where I think there may be a link to the specific post from which to start. Also, for historic reasons, this mod has two support threads, so some of what you want may be covered in the other one too.

31 Jan 2008, 5:15 PM
#355
yellow1912 avatar

yellow1912

Totally Zenned

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

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Thanks Kuroi, I think I get the basic ideas now:

  1. first we need to get the attribute id by using the products_id, option name and value (we dont want to use option id here for a specific reason) from the orders_products_attributes table

  2. then we need to check if the TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK exists (in case users are not using this mod), if it is we check if the stock info for that attribute is there. If not, we then assuming it is using the product stock instead.

  3. the problem is with product associated with multiple attributes tho. Since my test site is not using any product with more than 1 attribute, I dont know how it is stored in TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK and orders_products_attributes tables.

1 Feb 2008, 6:21 PM
#356
yellow1912 avatar

yellow1912

Totally Zenned

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

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Kuroi,

There is a problem with searching for the "string" as you suggested here:
"So, your first step would be to work backwards from the products_options_values to get the relevant products_options_values_ids in the products_options_values table, then concatenate them as a common-separated string and search for that string in the stock_attributes field of the products_with_attributes_stock table."

How would we get the exact order of the ids in the string? 19,29,30 and 29,19,30 contains the same ids but the string are different.

1 Feb 2008, 10:16 PM
#357
kuroi avatar

kuroi

Totally Zenned

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

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

yellow1912:

How would we get the exact order of the ids in the string?I don't recall having ever seen them in any order other than sorted by numerical value from low to high.

2 Feb 2008, 10:25 AM
#358
vivaraquel avatar

vivaraquel

Zen Follower

Join Date:
Sep 2004
Location:
Australia
Posts:
305
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

vivaraquel:

Thanks Kuroi, that did it. I had left the original order.php file ther just renamed it order1.php. Sounds absurd but hey, such are these things sometimes.

Ok, I had this fixed. But as I was checking on other stuff I went to my cart and hit the checkout button and got this error message again;

Fatal error: Cannot redeclare class order in /home/cheechab/public_html/includes/classes/order.php on line 20

However, I don't have any backed up order.php files in that folder now, just the one. I uploaded it fresh but it still does it.

Also, does the fix on post 46 work on ZC v.1.3.7.1 with this mod v.4.7? I need to figure out why when I try to add an attribute with 0 stock to the cart, no message comes up to say it's out of stock and if i go to checkout, the shopping cart page simply reloads.

The site I'm working on is http://www.cheechababy.com.au
Thank you.

2 Feb 2008, 11:09 AM
#359
kuroi avatar

kuroi

Totally Zenned

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

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

vivaraquel:

I don't have any backed up order.php files in that folder now, just the one. I uploaded it fresh but it still does it.If a class is instantiated twice that either means that there are two instances of it, or the code that instantiates it is being called twice. So where else might you have left backup files ......

2 Feb 2008, 11:51 AM
#360
vivaraquel avatar

vivaraquel

Zen Follower

Join Date:
Sep 2004
Location:
Australia
Posts:
305
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

hehe Thanks Kuroi, I had a couple more blasted things. Now the out of stock is working as well.

Have a good night,
Raquel.