**deleted -- nevermind -- I think I get it now**:laugh::laugh:
Printable View
**deleted -- nevermind -- I think I get it now**:laugh::laugh:
From the WIKI:
This wiki page points to posts that are not publicly viewable. I have one attribute in a dropdown for a product and here is how I did it, hopefully this saves someone a little bit of time.Quote:
How can I show the amount of stock available next to each attribute on the product information page?
zen cart version = 1.3.8a
in includes\modules\attributes.php
after
add the following:Code:die('Illegal Access');
}
Code://START PWA EDIT
function zen_draw_pull_down_menu_disableable($name, $values, $default = '', $parameters = '', $required = false) {
$field = '<select name="' . zen_output_string($name) . '"';
if (zen_not_null($parameters)) $field .= ' ' . $parameters;
$field .= '>' . "\n";
if (empty($default) && isset($GLOBALS[$name])) $default = stripslashes($GLOBALS[$name]);
for ($i=0, $n=sizeof($values); $i<$n; $i++) {
$field .= ' <option value="' . zen_output_string($values[$i]['id']) . '"';
if ($default == $values[$i]['id']) {
$field .= ' selected="selected"';
}
if ($values[$i]['disabled'] == true) $field .= ' disabled="disabled"';
$field .= '>' . zen_output_string($values[$i]['text'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')) . '</option>' . "\n";
}
$field .= '</select>' . "\n";
if ($required == true) $field .= TEXT_FIELD_REQUIRED;
return $field;
}
//END PWA EDIT
after
add the following:Code:if ($pr_attr->fields['total'] > 0) {
find the following:Code://START PWA EDIT
$PWALookup = array();
$PWAQ = $db->Execute("
select
products_with_attributes_stock.quantity as q,
products_attributes.options_values_id as id
from products_with_attributes_stock
left join products_attributes on products_with_attributes_stock.stock_attributes = products_attributes.products_attributes_id
where products_with_attributes_stock.products_id='".(int)$_GET['products_id']."'
");
if ($PWAQ->RecordCount() > 0) {
do {
$PWALookup[$PWAQ->fields['id']] = $PWAQ->fields['q'];
$PWAQ->MoveNext();
} while (!$PWAQ->EOF);
}
//END PWA EDIT
replace with:Code:$products_options_array[] = array('id' => $products_options->fields['products_options_values_id'],
'text' => $products_options->fields['products_options_values_name']);
find the following codeCode://START PWA EDIT
$PWAkey = $products_options->fields['products_options_values_id'];
$PWAAppend = "";
$PWADisabled = false;
if (array_key_exists($PWAkey ,$PWALookup)) {
if ($PWALookup[$PWAkey] == 0) {
//out of stock message
$PWAAppend = " (Out of stock)";
$PWADisabled = true;
} else {
//your IN STOCK message goes here
$PWAAppend = " (".$PWALookup[$PWAkey]." in stock)";
}
}
$products_options_array[] = array('id' => $products_options->fields['products_options_values_id'].$PWAHack,
'text' => $products_options->fields['products_options_values_name'].$PWAAppend,'disabled'=>$PWADisabled);
//END PWA EDIT
replace with:Code:$options_menu[] = zen_draw_pull_down_menu('id[' . $products_options_names->fields['products_options_id'] . ']', $products_options_array, $selected_attribute, 'id="' . 'attrib-' . $products_options_names->fields['products_options_id'] . '"') . "\n";
Code://START PWA EDIT
$options_menu[] = zen_draw_pull_down_menu_disableable('id[' . $products_options_names->fields['products_options_id'] . ']', $products_options_array, $selected_attribute, 'id="' . 'attrib-' . $products_options_names->fields['products_options_id'] . '"') . "\n";
//END PWA EDIT
This appears to be geared towards showing stock for products with only one attribute.. I don't see how this works if you have product attribute variants.. Am I missing something??? Is this found on the Zen Cart Wiki??
**goes off to look @ Zen Wiki**
Hi
I'm using 1.3.8a and stock_by_attributes_4-7ajax
other addons include, image handler, google checkout and a cherry_zen template.
I think I installed the module correctly and it seems to work. I select a product variant in the products with attribute tab, add stock and sync. On checking the parent product stock level all is well it shows the added stock quantity of all the variants.
On testing the checkout end, when I select an attribute, e.g. tie colour, and then add to basket, it and all other varients show as no stock.
any ideas as to what I have done wrong????
thanks
Richard
I'm using the newest version of Zencart and the newest version of this mod, I've also got the Multiadd and I think I've added all the right files.
Problem I'm having is, I've got the stock attributes with stock levels and those are working fine, but in the shop the attributes box is empty, so it's not displaying s,m,l,xl,xxl etc I'm sure it's something simple but I've been through this thread and can't find something specifically relating to my issue.
Any help would be great.
Thanks
To quote a line I heard in a movie once.. "Drop that zero and get yourself a hero"
Let me repeat again, what I have said in this thread (just one page up..)
Of the three flavors of this mod:I could never get the last two to work.. and since the contributors of both of these versions (MultiAdd or Ajax) have NOT ONCE supported their version of this mod, I do not use them.
- Kuroi's version 4.7
- MultiAdd version 4.7
- Ajax version 4.7
My research of the support threads for SBA (there are two pretty active ones) shows that the MultiAdd and Ajax versions are the ones with MULTIPLE problems. Most of the functional PROBLEMS people have with this mod all come from either the MultiAdd or the Ajax versions of Stock By Attributes.
The ORIGINAL is still the best IMO.. So I use ONLY the version 4.7 of SBA that Kuroi wrote. Why deal with problematic mods which bring VERY little beneficial features to the table??) Kuroi is the ONLY mod author still actively answering questions in these support threads, so for my money this is the ONLY version of Stock By Attributes that I will use. (where are the authors of the troubled Multiadd and Ajax versions of this mod???) However I do like and use the stylesheets from the MultiAdd version because it visually makes a nice seperation between the parent product and the variants. However, THAT'S ALL that I used from that version!:smile:
That said if you used Kuroi's version, it's a VERY straight forward install and should work right away.. No hacks or "adjustments" to this mod needed AT ALL! It just works as described..
Kuroi's version of Stocks By Attributes is in the downloads section where you found the (IMO) half/non working MultiAdd and Ajax versions of this mod. The downloads preserves previous versions of add ons below the most current submissions. So if you scroll down and you will see version 4.7 (WITHOUT MultiAdd or Ajax after the version number) and a download link for that version.
ETA
Let me just add the link -- some folks have a hard time "finding" previous versions in the add-on section: http://www.zen-cart.com/index.php?main_page=download_contrib&contrib_id=310&update_id=9
Does this work with text as i installed it and it doesnt appear to be working just comes up showing it as a drop down. Do i need to do anything to change it so i can use text?
OK Thanks I've installed Kuroi's version but I still have the same problem, but I wasn't able to install his sql file as it said duplicate already there and like a total noob I can't figure out how to delete tables in MySQL all I can do is drop the table.
So if anyone can instruct me on how to remove this mod completely and then do a fresh install (more so in the database) as I think overwriting all the files will mean I'm completely on Kuroi's version now.
Here is a link to my one and only product :D you can see whats wrong with the attribute, maybe it's not this mod but any help would be greatly appreciated
http://www.irbsandc.com/cart/index.p...products_id=13
Cheers
I haven't checked explicitly, but I'd be surprised if the other variants of the mod were using a different table structure, so you shouldn't need to re-install the SQL. If you did need to drop database tables you would use a tool such as phpMyAdmin.
I fear that you may be looking for the problem with your attribute display in the wrong place. My version of stock by attributes doesn't go near that and nor does the multiadd version. I wondered if the AJAX version might have an impact (I haven't used it) but can't see anything on the page you gave that would do so.
So I'm left wondering whether the problem is actually that there's something a little off in the way your option, the option values, or the product attribute have been set up.