Zen Cart Logo
Forums / All Other Contributions/Addons / Sequenced attributes based on stock addon...

Sequenced attributes based on stock addon...

Views: 10,473

Results 1 to 20 of 52
11 Mar 2008, 3:24 PM
#1
modernm avatar

modernm

New Zenner

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

Sequenced attributes based on stock addon...

I have been able to build a mod re-using code from other projects that will give sequenced drop downs for attributes based on stock. If anyone is interested in testing please PM me. I would like to contribute my work to the Zen Cart project even if it is only a temp fix until 1.4 comes out. This requires the Stock by Attributes mod installed and working.

Single drop down based on stock... (can be setup in multiple ways but currently setup to prevent adding items to cart and still show all attributes. Medium is out of stock if you want to test)

http://www.modernmunchkin.com/boys-1/accessories-12/knuckleheads-pub-hat-in-plaid-27.html

Sequenced drop downs based on stock...

http://www.modernmunchkin.com/gift-certificates-49/test-product-193.html

Cal

11 Mar 2008, 3:48 PM
#2
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,616
Plugin Contributions:
0

Re: Sequenced attributes based on stock addon...

Please package your code and add it to the downloads section.

11 Mar 2008, 5:17 PM
#3
modernm avatar

modernm

New Zenner

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

Re: Sequenced attributes based on stock addon...

I attempted to upload but got a warning saying no file uploaded. Tried twice with no luck.

Cal

26 Apr 2008, 12:15 PM
#4
kuroi avatar

kuroi

Totally Zenned

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

Re: Sequenced attributes based on stock addon...

It's certainly there now and is a useful extension of Stock by Attributes. The current version (1.3) seems to have a bit of a bug however, as line 87 of the pad_sequenced_dropdowns.php class calls up data from a table that doesn't exist in Zen Cart or Stock by Attributes.

26 Apr 2008, 8:48 PM
#5
modernm avatar

modernm

New Zenner

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

Re: Sequenced attributes based on stock addon...

kuroi:

It's certainly there now and is a useful extension of Stock by Attributes. The current version (1.3) seems to have a bit of a bug however, as line 87 of the pad_sequenced_dropdowns.php class calls up data from a table that doesn't exist in Zen Cart or Stock by Attributes.

Thanks, I will try and update the contrib tonight.

Modify includes/database_tables.php

define('TABLE_PRODUCTS_STOCK', 'products_with_attributes_stock');
28 Apr 2008, 1:41 PM
#6
heathenmagic avatar

heathenmagic

Totally Zenned

Join Date:
May 2005
Location:
England
Posts:
733
Plugin Contributions:
0

Re: Sequenced attributes based on stock addon...

Hello there,

This is a fine extension. Just wondered, am I to define this message in the enlgish.php file:-

TEXT_OUT_OF_STOCK_MESSAGE

also, if an item is out of stock, it shows TEXT_OUT_OF_STOCK next to it.

Regards,

Heathenmagic

29 Apr 2008, 5:48 PM
#7
modernm avatar

modernm

New Zenner

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

Re: Sequenced attributes based on stock addon...

HeathenMagic:

Hello there,

This is a fine extension. Just wondered, am I to define this message in the enlgish.php file:-

TEXT_OUT_OF_STOCK_MESSAGE

also, if an item is out of stock, it shows TEXT_OUT_OF_STOCK next to it.

Regards,

Heathenmagic

Heathenmagic,

I am uploading a update for that now. Please check the contrib later tonight.

Cal

13 May 2008, 11:50 PM
#8
dscott1966 avatar

dscott1966

Zen Follower

Join Date:
Apr 2005
Posts:
298
Plugin Contributions:
0

Re: Sequenced attributes based on stock addon...

I installed the mod but cant seem to get it work properly. To get the sequence to work, i added the different options but it does not come up with the correct it says that i have all in stock. Should it be if i have say 3 gold shoes in size 6 but none in 6.5, then the 6.5 should not show, if correct in saying right.

also it does not display the out of stock message

you can see it here:http://dealz-r-us.com/index.php?main_page=product_info&cPath=1_2&products_id=5

how do i go about fixing this?

9 Jul 2008, 11:22 PM
#9
blackjm75 avatar

blackjm75

New Zenner

Join Date:
May 2008
Posts:
20
Plugin Contributions:
0

Re: Sequenced attributes based on stock addon...

Cal,

This is excellent and very close to what I am looking for! I wanted to look at how the 'Sequenced drop downs based on stock...' worked but the link below was broken

http://www.modernmunchkin.com/gift-c...oduct-193.html

do you have an example of it working?

I want to have 'my site' 'look' at the attributes selected and if the combination selected is out of stock display a message in a sidebox but still allow them to purchase the product if they wish - we will order it in for them.

I presume that as you select the 1st attribute the site 'looks' at the stock and decides what to display as in or out of stock? If so it shouldnt be too hard to convert it to what I want.

Joe

19 Jul 2008, 3:25 PM
#10
dashton avatar

dashton

New Zenner

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

Re: Sequenced attributes based on stock addon...

I just installed Sequenced Attributes and I have this error-

1146 
Table 'jalansty_zc1.products_with_attributes_stock' doesn't exist
in:
[SELECT quantity FROM products_with_attributes_stock AS a LEFT JOIN 
products_attributes AS b ON (b.options_id=2 AND b.options_values_id=19) 
WHERE a.products_id = '5' AND a.stock_attributes = b.products_attributes_id 
AND a.quantity > 0 order by b.products_options_sort_order]

I noticed that in Modify "includes/database_tables.php" by adding...

define('TABLE_PRODUCTS_STOCK', 'products_with_attributes_stock');

there is no DB_PREFIX, so I tried changing it to

define('TABLE_PRODUCTS_STOCK', DB_PREFIX .'products_with_attributes_stock');

That seemed to fix it.

19 Oct 2008, 4:05 PM
#11
fbroz avatar

fbroz

New Zenner

Join Date:
Mar 2008
Posts:
35
Plugin Contributions:
1

Re: Sequenced attributes based on stock addon...

Thanks for the great module. This has been very helpful to me.

I ran into one small problem after installation because I hadn't defined "TEXT_SELECT_OPTIONS" in product_info.php along with the other two language definitions in the instructions. I may have missed something, but I believe the instructions step six which currently reads:

  1. Modify "includes/languages/english/YOUR_TEMPLATE/product_info.php" by adding...

define('TEXT_OUT_OF_STOCK', 'Out of stock');
define('TEXT_OUT_OF_STOCK_MESSAGE', 'The combination of options you have selected is currently out of stock. Please select another combination.');

should read:

  1. Modify "includes/languages/english/YOUR_TEMPLATE/product_info.php" by adding...

define('TEXT_OUT_OF_STOCK', 'Out of stock');
define('TEXT_OUT_OF_STOCK_MESSAGE', 'The combination of options you have selected is currently out of stock. Please select another combination.');
define('TEXT_SELECT_OPTIONS', 'Plese select your product.');

That small change to the installation instructions might save others some time.

Thanks again, this is a great addition to zen cart and greatly improved my store.

Frank

19 Oct 2008, 4:27 PM
#12
fbroz avatar

fbroz

New Zenner

Join Date:
Mar 2008
Posts:
35
Plugin Contributions:
1

Re: Sequenced attributes based on stock addon...

One last tip for others who have their store configured the same way I do:

Product Info Single Attribute Display Plugin	multiple_dropdowns	 
Product Info Multiple Attribute Display Plugin	sequenced_dropdowns	 
Show Out of Stock Attributes	                False	 
Mark Out of Stock Attributes	                None	 
Display Out of Stock Message Line	        False	 
Prevent Adding Out of Stock to Cart	        True

With my dropdowns configured that way, customers who clicked "add to cart" before making a selection would end up with the wrong product in their cart. There would be a version of their product with no attributes and an out of stock message. Obviously what I wanted instead was an error message reminder to choose an attribute instead of letting them add to cart. To achieve this, I made one small change in pad_sequenced_dropdowns.php.

it was originally like this:

        
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";
[B][I]$out.="    if (!instk) alert('".TEXT_OUT_OF_STOCK_MESSAGE."');\n";[/I][/B]
$out.="    return instk;\n";
$out.="  }\n";
$out.="  document.cart_quantity.onsubmit=chksel;\n";
}

and I changed it to this:

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";
[B][I]$out.="    if (!instk) alert('".TEXT_SELECT_OPTIONS."');\n";[/I][/B]
$out.="    return instk;\n";
$out.="  }\n";
$out.="  document.cart_quantity.onsubmit=chksel;\n";
}

For my store, this prevented customers from accidentally adding a non-product to the cart, and instead gave them a javascript error window telling them to select which product they want.

Thanks again for the great contribution.

Frank

26 Oct 2008, 2:33 PM
#13
angeli avatar

angeli

New Zenner

Join Date:
Aug 2007
Posts:
43
Plugin Contributions:
0

Re: Sequenced attributes based on stock addon...

I have this awesome mod loaded up - all looking good except for some or the other reason, out of stock options don't show up, even though I have it set to "show out of stock attributes".

Any ideas?

26 Oct 2008, 3:02 PM
#14
angeli avatar

angeli

New Zenner

Join Date:
Aug 2007
Posts:
43
Plugin Contributions:
0

Re: Sequenced attributes based on stock addon...

Oh yes, just to clarify - this problem only seems to be occurring on products with multiple attributes. The single ones show up fine.

7 Nov 2008, 5:51 AM
#15
mylildarlings avatar

mylildarlings

New Zenner

Join Date:
Oct 2008
Posts:
21
Plugin Contributions:
0

Re: Sequenced attributes based on stock addon...

I just set up this addon tonight and I'm not getting any errors, but nothing is showing up on site. I get the configuration setup in admin and I can make change with no errors. But when i look at my site, I don't see any OOS labels on individual attributes. It's as if it's not there.

I'm running Zen ver 1.3.8a, have the stock by attr 4.7 add on.

A little history about my Stock by attr add on. It was the first add on I installed when I set up this site in Sept. Everything worked great. About a week after I went live in Oct, I decided to switch my primary domain and had to buy a new SSL cert. In the process, I had to rebuild my site. I loaded a fresh Zen cart, and then restored my dbase files from the site I had before. But because I was running under a new primary domain, I couldn't restore my php files. So, I had to reload everything. But becuase the dbase was restored based on before, the Stock by Attr in the catalog showed up so I assume that didn't get erased. 2 weeks go by and I sold a few items that were sold out and I couldn't figure out why. Eventually, I figured that I needed to reload the addon eventhough the dbase was correct. I did that and it's been working fine ever since. So all that history to say that I wonder if my Stock by Attr isn't quite right and causing the Dynamic drop downs to not show up? Any ideas?

20 Feb 2009, 7:33 AM
#16
swamyg1 avatar

swamyg1

Zen Follower

Join Date:
Dec 2008
Location:
San Fran
Posts:
382
Plugin Contributions:
0

Re: Sequenced attributes based on stock addon...

I'm trying to use multiple dropdowns instead of sequenced, but it's just duplicating the first dropdown set. So I have two of the same dropdowns with the same options... I need to have one for lenth and one for color. But with multiple dropdowns selected I have 2 for length and none for color! Any idea how to fix?

Also, I would like to just show the first available attribute in the dropdown rather than "First select..." any idea how to do this?

22 Feb 2009, 5:28 AM
#17
swamyg1 avatar

swamyg1

Zen Follower

Join Date:
Dec 2008
Location:
San Fran
Posts:
382
Plugin Contributions:
0

Re: Sequenced attributes based on stock addon...

Please disregard my previous post... I realized what sequenced dropdowns are and it seems ideal for my situation.

I do however have another problem. The sort order for my attributes is all out of wack. It sorts fine without this mod installed. Any idea where to go to determine the sort order for sequenced dropdowns?

Here's a screenshot to demonstrate what I mean.

15 Mar 2009, 8:22 PM
#18
modernm avatar

modernm

New Zenner

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

Re: Sequenced attributes based on stock addon...

swamyg1:

Please disregard my previous post... I realized what sequenced dropdowns are and it seems ideal for my situation.

I do however have another problem. The sort order for my attributes is all out of wack. It sorts fine without this mod installed. Any idea where to go to determine the sort order for sequenced dropdowns?

Here's a screenshot to demonstrate what I mean.

There was a recent update to my contrib that modified pad_base.php to resolve sorting issues. Make sure you are using the latest version.

Check the SQL in pad_base.php...

$products_options_name = $db->Execute("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_track_stock from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$this->products_id . "' and patrib.options_id = popt.products_options_id and popt.language_id =". (int)$_SESSION['languages_id'] ." " . $stocked_where . " order by popt.products_options_sort_order");
      $attributes=array();

Note the "order by".

Cal

17 Apr 2009, 9:59 PM
#19
laurenjj avatar

laurenjj

New Zenner

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

Re: Sequenced attributes based on stock addon...

I could have sworn I saw this mentioned somewhere but now I can't find it :(

I've got things working...errrr....kind of.... My problem is that when I have a single drop down, the attribute isn't showing up .... I saw on modernm's site that this was indeed working.... Where is the bug in the code??

Thanks!

18 Apr 2009, 7:33 PM
#20
laurenjj avatar

laurenjj

New Zenner

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

Re: Sequenced attributes based on stock addon...

I'm soooooooo gonna be persistent..... HELP!