Page 246 of 359 FirstFirst ... 146196236244245246247248256296346 ... LastLast
Results 2,451 to 2,460 of 3589
  1. #2451
    Join Date
    Aug 2009
    Location
    Longs, SC
    Posts
    626
    Plugin Contributions
    2

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

    Quote Originally Posted by mc12345678 View Post
    I thought your day job might be golfing.

    Well, would say latest from http://www.github.com/mc12345678/Sto...butes_Combined. I hadn't done any special download this tag arrangement. It's been quiet there I think for 24 hours now.
    If I hit the lottery this weekend it could be. In the absence of a small fortune I suppose I'll need to keep working to pay the bills. I'll download the most recent and test it out.

  2. #2452
    Join Date
    Jul 2012
    Posts
    16,798
    Plugin Contributions
    17

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

    @jnabird333

    At last swing by of the sample product in your store, I saw that you had overcome the issue of dynamic dropdowns. But (and it's been a few days) I noticed that it doesn't quite work right...

    Once the first or greater choice has been selected, a change of any selection before the last available should reset all options "below" that one... In your case, you have a two attribute selecter, the first size, the second color. Once each of those have been selected, if the first is changed, the second is not reset... Watching the operations on the page, there was also a javascript error that occurred in that process...

    Now I'm not sure which of the many javascripts on that page was causing the issue, but I'm guessing that it is the one that deals with selectors (something like that in the filename). I didn't spend much more time troubleshooting it, but thought I would let you know the expected operation and how it isn't following that "process".
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #2453
    Join Date
    Jul 2012
    Posts
    16,798
    Plugin Contributions
    17

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

    @michael_rebreathe,

    Your siteat last check was still presenting three attributes when it appears that only 2 are defined. Based on the source code of the displaayed page it appears as if there might have been some code merging performed with the tpl_modules_attributes.php file as there is code present only introduced in this version/ZC 1.5.5 and only to be displayed when dynamic dropdowns is disabled which makes the situation even odder as it is acting as both enabled in full and disabled in part...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  4. #2454
    Join Date
    Jul 2015
    Posts
    43
    Plugin Contributions
    0

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

    Quote Originally Posted by mc12345678 View Post
    @michael_rebreathe,

    Your siteat last check was still presenting three attributes when it appears that only 2 are defined. Based on the source code of the displaayed page it appears as if there might have been some code merging performed with the tpl_modules_attributes.php file as there is code present only introduced in this version/ZC 1.5.5 and only to be displayed when dynamic dropdowns is disabled which makes the situation even odder as it is acting as both enabled in full and disabled in part...
    Which is why I've been banging my head trying to figure it out. It makes no sense to me, either. Since this is only one of >400 products, we didn't let this delay release. We are now live!

    I haven't touched tpl_modules_attributes.php, it doesn't appear to be a partial copy of the content, and the time stamp is synced with the other files included in the last update. I'm considering completely deleting the product and its attributes links and then recreating the product from scratch (kind of shotgun, but it's only three minutes wasted).

    Something I thought I solved, but only half way...The day after we went live, a customer reiterated a concern I saw and thought I fixed. Turns out, I only fixed it on single-attribute dropdowns. We really want the quantity available to display on the product page, but "Black Qty 2" can be perceived as forcing the customer to order in pairs. I updated \includes\classes\observers\class.products_with_attributes_stock.php [161] to change it to say "Black: 2 Available" Since this is a change to the actual construction of the content of the dropdown, this isn't just a change to a language define file. Thoughts on where this is is for multi-attributes in the sea of pages?

  5. #2455
    Join Date
    Jul 2012
    Posts
    16,798
    Plugin Contributions
    17

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

    Quote Originally Posted by michael_rebreathe View Post
    Which is why I've been banging my head trying to figure it out. It makes no sense to me, either. Since this is only one of >400 products, we didn't let this delay release. We are now live!

    I haven't touched tpl_modules_attributes.php, it doesn't appear to be a partial copy of the content, and the time stamp is synced with the other files included in the last update. I'm considering completely deleting the product and its attributes links and then recreating the product from scratch (kind of shotgun, but it's only three minutes wasted).

    Something I thought I solved, but only half way...The day after we went live, a customer reiterated a concern I saw and thought I fixed. Turns out, I only fixed it on single-attribute dropdowns. We really want the quantity available to display on the product page, but "Black Qty 2" can be perceived as forcing the customer to order in pairs. I updated \includes\classes\observers\class.products_with_attributes_stock.php [161] to change it to say "Black: 2 Available" Since this is a change to the actual construction of the content of the dropdown, this isn't just a change to a language define file. Thoughts on where this is is for multi-attributes in the sea of pages?
    Yup, and I'll look at how "best" such a statement can be easily added in the future. (Have an idea, but want to try to keep it easy for those that choose to modify it such as the above request.)

    File: includes/classes/pad_sba_sequenced_dropdowns.php

    Line 508:
    Can change from:

    Code:
                $out.=" + '" . PWA_STOCK_QTY . "' + stk2";
    to:
    Code:
                $out.=" + '" . PWA_STOCK_QTY . "' + stk2" . " Available";
    For the fix, I'm looking at modifying PWA_STOCK_QTY and the remainder of that statement to possibly sprint the value, or more simply to have it defined as the entire text that follows the current PWA_STOCK_QTY, such that the define in: includes/languages/english/extra_definitions/products_with_attributes.php
    Line 15 would be changed from:
    Code:
    define('PWA_STOCK_QTY', ' Qty: ');
    to (untested):
    Code:
    define('PWA_STOCK_QTY', ' + " Qty: " + stk2 + " Available"');
    Might have to reverse all the quotes on the right side of the define changing single quotes into double and double into single to support the javascript portion, and then line 508 of the previous file would be simply:

    Code:
                $out.= PWA_STOCK_QTY;
    Or some variation on that "thought"...

    Or since I see the constant is used in the class, that it would need to be a different constant in order to work or back to the previous "thought" of using sprint to provide the data... Again, the reason behind at least offering such a "prefix"/"suffix" option is to handle multiple languages as well where the word(s) may need to follow the number instead and further why an sprint option may be better so that the code can be consistent, but the resulting text be as desired/formed.

    Anyways, more than you needed, but there ya' go. :)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  6. #2456
    Join Date
    Jul 2012
    Posts
    16,798
    Plugin Contributions
    17

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

    @michael_rebreathe

    I have some other non-SBA related things to do, but took a look at tpl_modules_attributes, while I don't think there is an issue there, some of the coding pre-existed functionality that has been added. Basically there is an internal check for the product being an SBA controlled product, and then the variable is set and used for later checks. Problem might be that in the global aspect, the variable might be revised... Anyways, thinking of changing the tests in that file so that only the status as determined at that point is possible to affect operation...

    I had been trying to get "creative" and rely on certain data being maintained to minimize function calls, database searches, etc... But if it the current code is potentially affecting results, first need to ensure functionality.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #2457
    Join Date
    Jul 2015
    Posts
    43
    Plugin Contributions
    0

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

    Quote Originally Posted by mc12345678 View Post
    Yup, and I'll look at how "best" such a statement can be easily added in the future. (Have an idea, but want to try to keep it easy for those that choose to modify it such as the above request.)

    File: includes/classes/pad_sba_sequenced_dropdowns.php

    Line 508:
    Can change from:

    Code:
                $out.=" + '" . PWA_STOCK_QTY . "' + stk2";
    to:
    Code:
                $out.=" + '" . PWA_STOCK_QTY . "' + stk2" . " Available";
    For the fix, I'm looking at modifying PWA_STOCK_QTY and the remainder of that statement to possibly sprint the value, or more simply to have it defined as the entire text that follows the current PWA_STOCK_QTY, such that the define in: includes/languages/english/extra_definitions/products_with_attributes.php
    Line 15 would be changed from:
    Code:
    define('PWA_STOCK_QTY', ' Qty: ');
    to (untested):
    Code:
    define('PWA_STOCK_QTY', ' + " Qty: " + stk2 + " Available"');
    Might have to reverse all the quotes on the right side of the define changing single quotes into double and double into single to support the javascript portion, and then line 508 of the previous file would be simply:

    Code:
                $out.= PWA_STOCK_QTY;
    Or some variation on that "thought"...

    Or since I see the constant is used in the class, that it would need to be a different constant in order to work or back to the previous "thought" of using sprint to provide the data... Again, the reason behind at least offering such a "prefix"/"suffix" option is to handle multiple languages as well where the word(s) may need to follow the number instead and further why an sprint option may be better so that the code can be consistent, but the resulting text be as desired/formed.

    Anyways, more than you needed, but there ya' go. :)
    Not quite so simple as just changing line 508, but I got it.
    To allow any combination of prefixes and suffixes, I added
    Code:
    define('PWA_STOCK_QTY_PFX', ' :');
    define('PWA_STOCK_QTY_SFX', ' Available');
    to /includes/languages/english/extra_definitions/products_with_attributes.php

    Changed /includes/classes/pad_sba_sequenced_dropdowns.php (lines 506 +)
    Code:
            if ($curattr == sizeof($attributes) - 2) {
              if (STOCK_SHOW_ATTRIB_LEVEL_STOCK == 'true') {
              //$out.=" + '" . PWA_STOCK_QTY . "' + stk2";
                $out.=" + '" . PWA_STOCK_QTY_PFX . "' + stk2";//Put prefix here
                $out.=$outArray;
                $out.="[opt]";
              }
            }
          //$out.=",opt.substring(1));\n";
            $out.="+ '" . PWA_STOCK_QTY_SFX . "',opt.substring(1));\n";//Added the suffix here
            $out.="        } else {\n";
    Now for the second dropdown it shows
    Black :2 Available
    Blue :4 Available
    Green :2 Available
    Red :3 Available

    ...which works for us and is flexible should our passions change.

    Quote Originally Posted by mc12345678 View Post
    Code:
    define('PWA_STOCK_QTY', ' + " Qty: " + stk2 + " Available"');
    This will totally puke, since "stk2" is the name of the array holding the second-tier attributes stock quantities, which has to be accessed to determine the quantity. Once I got it to work with Prefix and Suffix, this is how the relevant line of Java is put together:
    Code:
    frm['id[6]'].options[frm['id[6]'].length]=new Option(htmlEnDeCode.htmlDecode(txt6[opt]) + ' :' + stk2['_'+frm['id[1]'].value][opt]+ ' Available',opt.substring(1));
    It worked fine with just a prefix, but the suffix gets in the way of accessing the array.

  8. #2458
    Join Date
    Jul 2015
    Posts
    43
    Plugin Contributions
    0

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

    Quote Originally Posted by michael_rebreathe View Post
    Not quite so simple as just changing line 508, but I got it.
    To allow any combination of prefixes and suffixes, I added
    Code:
    define('PWA_STOCK_QTY_PFX', ' :');
    define('PWA_STOCK_QTY_SFX', ' Available');
    to /includes/languages/english/extra_definitions/products_with_attributes.php

    Changed /includes/classes/pad_sba_sequenced_dropdowns.php (lines 506 +)
    Code:
            if ($curattr == sizeof($attributes) - 2) {
              if (STOCK_SHOW_ATTRIB_LEVEL_STOCK == 'true') {
              //$out.=" + '" . PWA_STOCK_QTY . "' + stk2";
                $out.=" + '" . PWA_STOCK_QTY_PFX . "' + stk2";//Put prefix here
                $out.=$outArray;
                $out.="[opt]";
              }
            }
          //$out.=",opt.substring(1));\n";
            $out.="+ '" . PWA_STOCK_QTY_SFX . "',opt.substring(1));\n";//Added the suffix here
            $out.="        } else {\n";
    Now for the second dropdown it shows
    Black :2 Available
    Blue :4 Available
    Green :2 Available
    Red :3 Available

    ...which works for us and is flexible should our passions change.


    This will totally puke, since "stk2" is the name of the array holding the second-tier attributes stock quantities, which has to be accessed to determine the quantity. Once I got it to work with Prefix and Suffix, this is how the relevant line of Java is put together:
    Code:
    frm['id[6]'].options[frm['id[6]'].length]=new Option(htmlEnDeCode.htmlDecode(txt6[opt]) + ' :' + stk2['_'+frm['id[1]'].value][opt]+ ' Available',opt.substring(1));
    It worked fine with just a prefix, but the suffix gets in the way of accessing the array.
    Pushed this solution to single attribute dropdowns as well...Once implemented, any changes to prefix or suffix will hit single and multi-attribute dropdowns simultaneously

    /includes/classes/observers/class.products_with_attributes_stock.php (line ~158 +)
    Code:
                  if (STOCK_SHOW_ATTRIB_LEVEL_STOCK == 'true' && $products_options->fields['pasqty'] > 0) {
                    //test, only applicable to products with-out the read-only attribute set
                    if ($products_options_DISPLAYONLY->fields['attributes_display_only'] < 1) {
                    //$PWA_STOCK_QTY = PWA_STOCK_QTY . $products_options->fields['pasqty'] . ' ';
                      $PWA_STOCK_QTY = PWA_STOCK_QTY_PFX . $products_options->fields['pasqty'] . PWA_STOCK_QTY_SFX .' ';//Changed to Prefix, added Suffix
                      //show custom ID if flag set to true
                      if (STOCK_SBA_DISPLAY_CUSTOMID == 'true' AND ! empty($products_options->fields['customid'])) {
                        $PWA_STOCK_QTY .= ' (' . $products_options->fields['customid'] . ') ';//We have this commented out to prevent customids in the dropdowns, but allow them on shopping cart and pick lists
                      }
                    }

  9. #2459
    Join Date
    Jul 2012
    Posts
    16,798
    Plugin Contributions
    17

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

    Thanks for doing all the leg work, I did kind of think it wouldn't quite be as easy as I described, but I still think it can be... More to follow on that. :) glad that the issue was resolved and shared with others...

    As to the customid on the multiple attributes, I actually thought I hadn't included it yet, but am wrong based on the commenting out of the code above... Need an if statement surrounding that line to evaulate against the same constant that was added in the other file where it was presented in three rows of the file... Also need to incorporate a prefix/suffix to the model# as well to expand on user modification options...

    Thanks again!!!
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  10. #2460
    Join Date
    Jul 2012
    Posts
    16,798
    Plugin Contributions
    17

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

    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.
    Last edited by mc12345678; 17 Jan 2016 at 05:12 PM.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. Problems with addon: Dynamic Drop Downs for Stock By Attribute
    By Dunk in forum All Other Contributions/Addons
    Replies: 56
    Last Post: 30 Apr 2014, 07:55 PM
  2. MySQL Problem with Product with Attribute Stock addon
    By rtwingfield in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 20 Sep 2011, 03:35 PM
  3. Hide Zero Quantity Attributes with attribute-stock addon
    By leevil123 in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 11 Feb 2010, 05:06 PM
  4. Replies: 4
    Last Post: 22 Jan 2010, 10:43 PM
  5. Price Products in the grid by 'Stock by Attribute' addon?
    By Salixia in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 27 Oct 2009, 06:03 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR