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,563

Results 2,481 to 2,500 of 3,609
7 Apr 2016, 2:13 PM
#2481
eyeb avatar

eyeb

New Zenner

Join Date:
Aug 2013
Location:
United States
Posts:
37
Plugin Contributions:
0

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

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.

7 Apr 2016, 2:20 PM
#2482
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

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_By_Attributes_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...

12 Apr 2016, 12:05 PM
#2483
soxophoneplayer avatar

soxophoneplayer

Totally Zenned

Join Date:
Feb 2008
Posts:
534
Plugin Contributions:
0

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

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.

-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:

 $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:

   * 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.

12 Apr 2016, 12:08 PM
#2484
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

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:

$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
   * 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 ().

12 Apr 2016, 12:15 PM
#2485
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

Sorry, line in tpl_modules_attributes.php should read:

$inSBA = new queryFactoryResult($db->link);
12 Apr 2016, 2:30 PM
#2486
soxophoneplayer avatar

soxophoneplayer

Totally Zenned

Join Date:
Feb 2008
Posts:
534
Plugin Contributions:
0

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

mc12345678:

Sorry, line in tpl_modules_attributes.php should read:

$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')
12 Apr 2016, 2:38 PM
#2487
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

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...

19 Apr 2016, 1:08 AM
#2488
fbroz avatar

fbroz

New Zenner

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

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

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!

19 Apr 2016, 1:56 AM
#2489
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

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.

26 Apr 2016, 6:06 PM
#2490
ivopivo avatar

ivopivo

New Zenner

Join Date:
Apr 2016
Posts:
18
Plugin Contributions:
0

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,

[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,

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

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:

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:
> ```
        if ([B]$attribute_stock->RecordCount() > 0 && [/B]!$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":

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:
> 
> ```
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 ([B]$attribute_stock->RecordCount() > 0 && [/B]!$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.

26 Apr 2016, 6:53 PM
#2491
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

ivopivo:

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,

When viewing the order in orders.php (admin panel) it shows,

Would you have any idea what might be the cause? Thanks

Would be very helpful to have additional information.

  1. ZC version.
  2. Source of the SBA files (and possibly when they were downloaded).
  3. The product in question, is it tracked by SBA?
  4. If it is, how is/are the associated variants populated?
  5. How many option names are associated with the product?
  6. What type of option name(s) are they? (ie. read only, radio, etc...)

In just looking at the code and the above error message(s), it may be that a variable falls out of scope which is why the empty (), but that also depends on some of the above. I do note that a similar function is in the store side of the fileset and the particular area that is causing that problem in the admin where it starts with an if statement to the end of that if statement is in the admin only side. Makes me somewhat wonder if it is even necessary, but it got added in at some point and with purpose, so would rather make it work than make it go away. :)

26 Apr 2016, 7:18 PM
#2492
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

Still be nice to get the above requested information in case there is something else that needs to be addressed; however, please also see the proposed "fix" posted here.
If that works, it would be great to know. :) Again, difficult thing here is being able to reproduce the problem which can pretty much only do with sufficient information being provided.

26 Apr 2016, 7:25 PM
#2493
ivopivo avatar

ivopivo

New Zenner

Join Date:
Apr 2016
Posts:
18
Plugin Contributions:
0

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

mc12345678:

Would be very helpful to have additional information.

  1. ZC version.
  2. Source of the SBA files (and possibly when they were downloaded).
  3. The product in question, is it tracked by SBA?
  4. If it is, how is/are the associated variants populated?
  5. How many option names are associated with the product?
  6. What type of option name(s) are they? (ie. read only, radio, etc...)

In just looking at the code and the above error message(s), it may be that a variable falls out of scope which is why the empty (), but that also depends on some of the above. I do note that a similar function is in the store side of the fileset and the particular area that is causing that problem in the admin where it starts with an if statement to the end of that if statement is in the admin only side. Makes me somewhat wonder if it is even necessary, but it got added in at some point and with purpose, so would rather make it work than make it go away. :)

Hello, thank you for the prompt reply!

  1. ZC Version: v1.5.4

  2. Source of the SBA files: Version: 1.5.3 from pottery house, downloaded here - https://www.zen-cart.com/downloads.php?do=file&id=202

  3. The product in question, is it tracked by SBA? Yes (no custom id, sort order or description set)

4) If it is, how is/are the associated variants populated? There is an option for colour (radio) with only one option that is selected by default. The other option is for size and there are 6 choices in drop-down format.

5) How many option names are associated with the product? 2

6) What type of option name(s) are they? Radio and drop-down

Its ironic that no errors are generated from the store-side and the flow is seamless, however, it is causing issues when trying to view the order/make updates to it in the admin section.

The rest of the process works fine. The purchased stock is correctly deducted by SBA, etc.

Thanks again.

26 Apr 2016, 7:34 PM
#2494
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

ivopivo:

Hello, thank you for the prompt reply!

  1. ZC Version: v1.5.4

  2. Source of the SBA files: Version: 1.5.3 from pottery house, downloaded here - https://www.zen-cart.com/downloads.php?do=file&id=202

  3. The product in question, is it tracked by SBA? Yes (no custom id, sort order or description set)

4) If it is, how is/are the associated variants populated? There is an option for colour (radio) with only one option that is selected by default. The other option is for size and there are 6 choices in drop-down format.

5) How many option names are associated with the product? 2

6) What type of option name(s) are they? Radio and drop-down

Its ironic that no errors are generated from the store-side and the flow is seamless, however, it is causing issues when trying to view the order/make updates to it in the admin section.

The rest of the process works fine. The purchased stock is correctly deducted by SBA, etc.

Thanks again.

Thank you for those answers. Item 4 could use some clarification, by variant I am referring to how information is populated in the admin under the catalog drop down and data entry for SBA. Do you have 6 lines of items each with a stock quantity where each row shows like: colour followed by size "1", colour followed by size "2", colour followed by size "3", etc... or do you have one entry with colour and six entries one for each size?

Also, if using ZC 1.5.4, the version currently available for download from this site is technically for ZC 1.5.1 and hasn't been updated (that I'm aware of) with the changes that have been ongoing on github (https://github.com/mc12345678/Stock_By_Attributes_Combined).

Lastly, based on the provided information the change that I made to the code and linked above is not expected to correct your issue. The change I made was based on the "notes" that I left at the bottom of that previous post and were to exit out of the customid "loop" if the product was not tracked by SBA, but had attributes. Still might be back to the "out-of-scope" variable... Let me know if you did/did not apply the previous patch so that I can give line numbers appropriately to try something.

26 Apr 2016, 8:00 PM
#2495
ivopivo avatar

ivopivo

New Zenner

Join Date:
Apr 2016
Posts:
18
Plugin Contributions:
0

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

mc12345678:

Thank you for those answers. Item 4 could use some clarification, by variant I am referring to how information is populated in the admin under the catalog drop down and data entry for SBA. Do you have 6 lines of items each with a stock quantity where each row shows like: colour followed by size "1", colour followed by size "2", colour followed by size "3", etc... or do you have one entry with colour and six entries one for each size?

I have attached a screenshot to provide more clarity. (easier than my attempts at explaining)

mc12345678:

Also, if using ZC 1.5.4, the version currently available for download from this site is technically for ZC 1.5.1 and hasn't been updated (that I'm aware of) with the changes that have been ongoing on github (https://github.com/mc12345678/Stock_By_Attributes_Combined).

Actually, upon second look, I installed it from a zip file titled "Stock_By_Attributes_Combined-master.zip". The stock by attributes file has * Stock by Attributes 1.5.4 15-11-14 mc12345678 in the opening.

mc12345678:

Lastly, based on the provided information the change that I made to the code and linked above is not expected to correct your issue. The change I made was based on the "notes" that I left at the bottom of that previous post and were to exit out of the customid "loop" if the product was not tracked by SBA, but had attributes. Still might be back to the "out-of-scope" variable... Let me know if you did/did not apply the previous patch so that I can give line numbers appropriately to try something.

I have restored the original file (without the changes from the bottom of the post). Thanks

26 Apr 2016, 10:41 PM
#2496
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

ivopivo:

I have attached a screenshot to provide more clarity. (easier than my attempts at explaining)

Actually, upon second look, I installed it from a zip file titled "Stock_By_Attributes_Combined-master.zip". The stock by attributes file has * Stock by Attributes 1.5.4 15-11-14 mc12345678 in the opening.

I have restored the original file (without the changes from the bottom of the post). Thanks
Okay, and in a way good... Hmm.. Two options of potential solutions... Based on no customid being defined, I'm thinking the query may be returning nothing when asking for the customid on the product because no customid is defined, the other is the potential out-of-scope issue...

So first to try to address the potential out-of-scope variable... At line 727 of admin/includes/classes/products_with_attributes_stock.php, please add:

$stock_attributes_comb = null;

This would be just below:

$products_id = zen_get_prid($products_id);

Clear your cache/logout of the admin screen then return to the order and see if the error remains.

Okay I should have posted this a while back when I first wrote it, but I wanted an opportunity to run some of the code basically through some sql tests to see if there was an issue with the sql queries specifically, but have again come back to the fact that $stock_attributes_comb is "empty" within the second query loop... One way around that is to join the values differently so that worst case there would be a series of values like ("","") but ultimately that shouldn't even happen either, because $stock_attributes_comb ought to have values in it if the product 1) has attributes (obviously it does) and 2) is tracked by SBA... So, try the above first and then I may have to modify how the check is done, but that also seems like it will not return any values...

26 Apr 2016, 11:10 PM
#2497
ivopivo avatar

ivopivo

New Zenner

Join Date:
Apr 2016
Posts:
18
Plugin Contributions:
0

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

Cheers for the help.

Tried the changes, the same error remains in the admin section. Log below:

[26-Apr-2016 23:03:45 UTC] PHP Warning: implode(): Invalid arguments passed in products_with_attributes_stock.php on line 781
[26-Apr-2016 23:03:45 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 = 334
and stock_attributes in () ==> (as called by)
products_with_attributes_stock.php on line 804 <== in query_factory.php on line 155

Contents of my products_with_attributes_stock.php - http://paste.ofcode.org/i2gJ2XegqNfZaMVXgNw2dW

26 Apr 2016, 11:19 PM
#2498
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

Now, I just tried in ZC 1.5.5 to purchase a product that has two option names (each having more than one option value), no customid assigned to the product, I have the admin set to display customid, and when I go to the admin customers->orders page, I am not having a problem with the "customid" and my store's files are the same as what has been uploaded to github as the current version (where version control/documentation hasn't been the best). Almost better off basing the date of the fileset on the date of the download. :) I have a 1.5.4 and 1.5.3 store with it installed at some level, but don't see how that part of the versioning plays a factor. The 1.5.5 fileset was basically made from the 1.5.4 and 1.5.3 set and then trimmed back based on changes made to ZC that made incorporation of this plugin easier/better. So, thing is I haven't yet been able to re-duplicate this issue after the post from this January.

Is the purchased item in some way at the beginning or end of the listings for that product?

I'm grasping at straws (assuming that your fileset is up-to-date with the current file set) because I don't yet (again?) know what conditions are fully causing this. May have to ask for some additional testing if the above doesn't work. If this is causing a problem to be able to do what you need, I can provide direction about how to comment out that section that is causing the problem. Considering you are using combined option names, it wouldn't pose a problem for your store when using multiple option name or single option name product.

26 Apr 2016, 11:50 PM
#2499
ivopivo avatar

ivopivo

New Zenner

Join Date:
Apr 2016
Posts:
18
Plugin Contributions:
0

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

Upon further testing, It is happening to every single product that is SBA tracked. If the product isn't SBA tracked, there is no issue at all (displays perfectly fine).

When viewing customers -> orders in the admin panel, the products will display in the panel to right correctly without any error.

The error only appeals in the sections like "Display order details", "Display invoice", etc.

I have checked the files that I used from the master zip, It was installed in the last 2 months - I don't think there were any changes?

27 Apr 2016, 12:00 AM
#2500
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

ivopivo:

Upon further testing, It is happening to every single product that is SBA tracked. If the product isn't SBA tracked, there is no issue at all (displays perfectly fine).

When viewing customers -> orders in the admin panel, the products will display in the panel to right correctly without any error.

The error only appeals in the sections like "Display order details", "Display invoice", etc.

I have checked the files that I used from the master zip, It was installed in the last 2 months - I don't think there were any changes?

Would have to look at the commit history to identify changes. What if you applied a customid to eitherone of the purchased product or just any at all? I've made some changes to other aspects like supporting the product attribute grid plugin, but also work on a number of other things and cannot recall specifics