Re: Stock by Attribute v4.0 for Zen Cart 1.3.5+
Hello...Zen Cart 1.5.4 - upgraded 1.3.x (can't remember)
We are using the Stock by Attribute and all seems goods - works as intended. BUT one situation is our inventory - when out could be out forever - so there is no back order.
1. So if customer A puts item size 12 in cart and checks out - item size 12 is no longer available to see at site - perfect -exactly as should be (thanks...good plug-in).
2. BUT if customer A puts item size 12 ins cart and customer B puts item size 12 in cart - this is also good - as we don't want inventory to change just because it's in a cart - but rather that it's been checkout then it's gone.
3. BUT if customer A checkouts and there is only one size 12 customer B can also check out - What I want is customer B to get a message at cart and not be able to check out if customer A already did. We were able to set this up for general inventory - it can be in two carts but only one can checkout - but couldn't get to this to work at the attributes level.
Questions:
1) Is this possible? (two attributes in cart but only one can checkout if attribute inventory is gone after that first checkout)
2) Anyone else solved this issue? Simple fix that you can describe here - or very complex that you hired someone to fix (and they actually fixed it)?
Thanks so much.
Re: Stock by Attribute v4.0 for Zen Cart 1.3.5+
Quote:
Originally Posted by
eyeb
Hello...Zen Cart 1.5.4 - upgraded 1.3.x (can't remember)
We are using the Stock by Attribute and all seems goods - works as intended. BUT one situation is our inventory - when out could be out forever - so there is no back order.
1. So if customer A puts item size 12 in cart and checks out - item size 12 is no longer available to see at site - perfect -exactly as should be (thanks...good plug-in).
2. BUT if customer A puts item size 12 ins cart and customer B puts item size 12 in cart - this is also good - as we don't want inventory to change just because it's in a cart - but rather that it's been checkout then it's gone.
3. BUT if customer A checkouts and there is only one size 12 customer B can also check out - What I want is customer B to get a message at cart and not be able to check out if customer A already did. We were able to set this up for general inventory - it can be in two carts but only one can checkout - but couldn't get to this to work at the attributes level.
Questions:
1) Is this possible? (two attributes in cart but only one can checkout if attribute inventory is gone after that first checkout)
2) Anyone else solved this issue? Simple fix that you can describe here - or very complex that you hired someone to fix (and they actually fixed it)?
Thanks so much.
Not sure about the "notification", but this condition is now addressed in this plugin as obtained from https://github.com/mc12345678/Stock_...butes_Combined. It still respects the "first-purchase" first "wins" philosphy.
In testing this condition has also been difficult to reproduce, but in following the code logic it is addressed such that if two persons have the same exact item in the cart and that the purchase by either results in stock being depeleted and no "backorder" or oversell is available, then the second individual will not be able to checkout with that item. I thought it actually either gets removed with thenotification that the stock quantity in the cart exceeds theavailable quantity or some similar message...
Re: Stock by Attribute v4.0 for Zen Cart 1.3.5+
zc 1.5.5 with SbyA from github
Apologies if I'm asking in wrong forum. I'm getting a log error that I think is SbyA related.
Quote:
-Apr-2016 02:16:07 UTC] Request URI: /index.php?main_page=product_info&products_id=10, IP address: 164.132.161.11
#1 queryFactoryResult->__construct() called at /xxxxxxxxxxxxx/tpl_modules_attributes.php:59]
#2 require(/xxxxxxxxxxxxx/templates/tpl_modules_attributes.php) called at [xxxxxxxxxxxx/templates/tpl_product_info_display.php:118]
#3 require(/xxxxxxxxx/templates/tpl_product_info_display.php) called at [xxxxxxxxxx/product_info/main_template_vars.php:178]
#4 require(/xxxxx/includes/modules/pages/product_info/main_template_vars.php) called at [/xxxxxxxxxxxx/tpl_main_page.php:251]
#5 require(/xxxxxx/common/tpl_main_page.php) called at [/xxxxx/public_html/index.php:97]
[09-Apr-2016 02:16:07 UTC] PHP Warning: Missing argument 1 for queryFactoryResult::__construct(), called in /xxxxxxxxx/tpl_modules_attributes.php on line 59 and defined in /xxxxxxx/includes/classes/db/mysql/query_factory.php on line 550
The bit in tpl_modules/attributes is:
PHP Code:
$inSBA = new queryFactoryResult;
$inSBA->EOF = true;
?>
<h3 id="attribsOptionsText"><?php echo TEXT_PRODUCT_OPTIONS; ?> </h3>
<?php } // END NON-SBA SPECIFIC: show please select unless all are readonly ?>
and the bit in query_factory is:
PHP Code:
* Constructs a new Query Factory Result
*/
function __construct($link) {
$this->is_cached = false;
$this->EOF = true;
$this->result = array();
$this->cursor = 0;
$this->link = $link;
}
I don't think this is causing me grief other than running up log files, so not sure what I should do about it.
Re: Stock by Attribute v4.0 for Zen Cart 1.3.5+
Quote:
Originally Posted by
soxophoneplayer
zc 1.5.5 with SbyA from github
Apologies if I'm asking in wrong forum. I'm getting a log error that I think is SbyA related.
The bit in tpl_modules/attributes is:
PHP Code:
$inSBA = new queryFactoryResult;
$inSBA->EOF = true;
?>
<h3 id="attribsOptionsText"><?php echo TEXT_PRODUCT_OPTIONS; ?> </h3>
<?php } // END NON-SBA SPECIFIC: show please select unless all are readonly ?>
and the bit in query_factory is:
PHP Code:
* Constructs a new Query Factory Result
*/
function __construct($link) {
$this->is_cached = false;
$this->EOF = true;
$this->result = array();
$this->cursor = 0;
$this->link = $link;
}
I don't think this is causing me grief other than running up log files, so not sure what I should do about it.
Already addressed/corrected in the current download, but add $db->link between ().
Re: Stock by Attribute v4.0 for Zen Cart 1.3.5+
Sorry, line in tpl_modules_attributes.php should read:
Code:
$inSBA = new queryFactoryResult($db->link);
Re: Stock by Attribute v4.0 for Zen Cart 1.3.5+
Quote:
Originally Posted by
mc12345678
Sorry, line in tpl_modules_attributes.php should read:
Code:
$inSBA = new queryFactoryResult($db->link);
Thank you, kind sir.
I added edited that bit. Also grabbed current github - I see there is quite a diff in includes/functions/extra_functions/products_with_attributes.php. So I replaced the previous version I had (January I think) with that while I was at it. (just sayin')
Re: Stock by Attribute v4.0 for Zen Cart 1.3.5+
Quote:
Originally Posted by
soxophoneplayer
Thank you, kind sir.
I added edited that bit. Also grabbed current github - I see there is quite a diff in includes/functions/extra_functions/products_with_attributes.php. So I replaced the previous version I had (January I think) with that while I was at it. (just sayin')
Yeah, I think it was around that time that I was trying to address several issues with compatibility of Dynamic Dropdowns and various in-stock out-of-stock options, identifying upon submitting a product to the cart whether the attributes were in stock or not, etc... and had made several changes. For what it's worth, recently product grid attributes has been updated to work on ZC 1.5.3 and above and integrate with SBA. There's still quite a bit to be done with that module, but it offers some basic functionality that works...
Re: Stock by Attribute v4.0 for Zen Cart 1.3.5+
I'm trying out the beta version of SbyA with a Zen Cart version 1.5.5 install. So far it seems to work, which is really cool! To anyone else who is trying it, does the jQuery live editing of quantities work for you? I'm not sure if I missed a merge somewhere or if that isn't supposed to work yet. Thanks!
Re: Stock by Attribute v4.0 for Zen Cart 1.3.5+
The big thing/difference in ZC 1.5.5 and the previous versions is that in ZC 1.5.5 in the admin jquery is loaded in one of the files after earlier versions would have loaded the necessary script which in turn disables/resets the already loaded script. Thought this had already been so incorporated, but then again there is a minor change that needs to be merged in from one of the GitHub branches.
Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9
I had the exact same error as below. I made the changes outlined, and now it is showing a different error, when viewing the order in orders.php (admin panel)
From error log,
Quote:
[26-Apr-2016 18:03:37 UTC] PHP Warning: implode(): Invalid arguments passed in /home/username/public_html/admindir/includes/classes/products_with_attributes_stock.php on line 771
[26-Apr-2016 18:03:37 UTC] PHP Fatal error: 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 4 :: select customid as products_model
from products_with_attributes_stock
where products_id = 336
and stock_attributes in () ==> (as called by) /home/username/public_html/admindir/includes/classes/products_with_attributes_stock.php on line 794 <== in /home/username/public_html/includes/classes/db/mysql/query_factory.php on line 155
When viewing the order in orders.php (admin panel) it shows,
Quote:
1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 4
in:
[select customid as products_model from products_with_attributes_stock where products_id = 336 and stock_attributes in ()]
Would you have any idea what might be the cause? Thanks
Quote:
Originally Posted by
mc12345678
Discovered while viewing a customer's order in admin:
criteria to reproduce:
product has attributes, but product is not tracked by SBA and STOCK_SBA_DISPLAY_CUSTOMID == 'true' (ie. expecting to have the custom_id displayed).
SQL error thrown at line 794 of admin/includes/classes/products_with_attributes_stock.php
Error is equivalent to below:
Code:
PHP Fatal error: 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 4 :: select customid as products_model
from products_with_attributes_stock
where products_id = 5
and stock_attributes in () ==> (as called by) path_to_admin/includes/classes/products_with_attributes_stock.php on line 794 <== in path_to_store_includes/classes/db/mysql/query_factory.php on line 155
Error may be slightly different on various ZC versions (ie. the line number associated to query_factory.php); however, the above was from running on ZC 1.5.3. The same issue would occur on any version of ZC that this code is run.
How to fix:
replace line 787 with:
Code:
if ($attribute_stock->RecordCount() > 0 && !$customid->RecordCount()){ // if a customid does not exist for the combination of attributes then perhaps the attributes are individually listed.
Original code in this "area":
Code:
if(is_array($attributes) and sizeof($attributes) > 0){
// check if attribute stock values have been set for the product
// if there are will we continue, otherwise we'll use product level data
$attribute_stock = $db->Execute("select stock_id
from " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . "
where products_id = " . (int)$products_id . ";");
if ($attribute_stock->RecordCount() > 0) {
// search for details for the particular attributes combination
$first_search = 'where options_values_id in ("'.implode('","',$attributes).'")';
// obtain the attribute ids
$query = 'select products_attributes_id
from '.TABLE_PRODUCTS_ATTRIBUTES.'
'.$first_search.'
and products_id='.$products_id.'
order by products_attributes_id;';
$attributes_new = $db->Execute($query);
while(!$attributes_new->EOF){
$stock_attributes[] = $attributes_new->fields['products_attributes_id'];
$attributes_new->MoveNext();
}
$stock_attributes_comb = implode(',',$stock_attributes);
}
//Get product model
$customid_model_query = 'select products_model
from '.TABLE_PRODUCTS.'
where products_id = '. (int)$products_id . ';';
//Get custom id as products_model
$customid_query = 'select customid as products_model
from '.TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK.'
where products_id = :products_id:
and stock_attributes in (:stock_attributes:);';
$customid_query = $db->bindVars($customid_query, ':products_id:', $products_id, 'integer');
$customid_query = $db->bindVars($customid_query, ':stock_attributes:', $stock_attributes_comb, 'string');
$customid = $db->Execute($customid_query); //moved to inside this loop as for some reason it has made
if (!$customid->RecordCount()){ // if a customid does not exist for the combination of attributes then perhaps the attributes are individually listed.
$customid_query = 'select customid as products_model
from '.TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK.'
where products_id = :products_id:
and stock_attributes in (:stock_attributes:)';
$customid_query = $db->bindVars($customid_query, ':products_id:', $products_id, 'integer');
$customid_query = $db->bindVars($customid_query, ':stock_attributes:', $stock_attributes_comb, 'passthru');
$customid = $db->Execute($customid_query); //moved to inside this loop as for some reason it has made
}
}
Revised Code:
Code:
if(is_array($attributes) and sizeof($attributes) > 0){
// check if attribute stock values have been set for the product
// if there are will we continue, otherwise we'll use product level data
$attribute_stock = $db->Execute("select stock_id
from " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . "
where products_id = " . (int)$products_id . ";");
if ($attribute_stock->RecordCount() > 0) {
// search for details for the particular attributes combination
$first_search = 'where options_values_id in ("'.implode('","',$attributes).'")';
// obtain the attribute ids
$query = 'select products_attributes_id
from '.TABLE_PRODUCTS_ATTRIBUTES.'
'.$first_search.'
and products_id='.$products_id.'
order by products_attributes_id;';
$attributes_new = $db->Execute($query);
while(!$attributes_new->EOF){
$stock_attributes[] = $attributes_new->fields['products_attributes_id'];
$attributes_new->MoveNext();
}
$stock_attributes_comb = implode(',',$stock_attributes);
}
//Get product model
$customid_model_query = 'select products_model
from '.TABLE_PRODUCTS.'
where products_id = '. (int)$products_id . ';';
//Get custom id as products_model
$customid_query = 'select customid as products_model
from '.TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK.'
where products_id = :products_id:
and stock_attributes in (:stock_attributes:);';
$customid_query = $db->bindVars($customid_query, ':products_id:', $products_id, 'integer');
$customid_query = $db->bindVars($customid_query, ':stock_attributes:', $stock_attributes_comb, 'string');
$customid = $db->Execute($customid_query); //moved to inside this loop as for some reason it has made
if ($attribute_stock->RecordCount() > 0 && !$customid->RecordCount()){ // if a customid does not exist for the combination of attributes then perhaps the attributes are individually listed.
$customid_query = 'select customid as products_model
from '.TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK.'
where products_id = :products_id:
and stock_attributes in (:stock_attributes:)';
$customid_query = $db->bindVars($customid_query, ':products_id:', $products_id, 'integer');
$customid_query = $db->bindVars($customid_query, ':stock_attributes:', $stock_attributes_comb, 'passthru');
$customid = $db->Execute($customid_query); //moved to inside this loop as for some reason it has made
}
}
FWIW, the above is expected to be revised again, there are some additional logic functions that can be applied to provide a smoother operation and would have prevented finding that error. Ie., the error was present because any check performed regarding if the products_id in question was tracked by SBA did not properly/promptly address that condition... Now there is actually a function that returns a true/false condition if a product is tracked by SBA and therefore, that can be incorporated up front and any "special" custom_id handling after that. To be addressed in a later change.