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.
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.
Kuroi Web Design and Development | Twitter
(Questions answered in the forum only - so that any forum member can benefit - not by personal message)
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.
I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me
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
I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me
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 Code:
<?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;
}
}
}
?>
I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me
@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.
Kuroi Web Design and Development | Twitter
(Questions answered in the forum only - so that any forum member can benefit - not by personal message)
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...
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.
Kuroi Web Design and Development | Twitter
(Questions answered in the forum only - so that any forum member can benefit - not by personal message)
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?
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.
Kuroi Web Design and Development | Twitter
(Questions answered in the forum only - so that any forum member can benefit - not by personal message)
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.....
Bookmarks