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

Results 2,901 to 2,920 of 3,609
27 Feb 2018, 10:11
#2901
mc12345678 avatar

mc12345678

Totally Zenned

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

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

mc12345678:

@madshaun1984, et al...

Ok, figured out what's going on.

There were two things, one was the additional encoding that caused £ to become $amp;pound; in the txtXXX section (should be addressed by the above change(s) though processing of the code may make that change unnecessary), the other is/was that when selecting a "parent" option, the child select options are added by pushing the content to the option list. This push (creating a new option) though populated the text of the option not the html of the option. I.e put £ directly in the output text instead of the more "inner" html. So, while this was tested for the change identified at line 1053 below it has not been tested in absence of the previously posed changes or other similar changes that I made on my test server. I do think the below changes would address the wrongful display of ```
£

> 
> I'm providing line numbers here working from the "bottom" to the "top" so that as each change is made the identified line numbers will still line up with the content on github at the moment (haven't pushed an update, just realized what needed to be done and proved that at least adding the change to line 1053 worked, though had also made some other changes as well that need to be validated as unnecessary.)
> 
> Between lines 1091 and 1092 having this content:
> ```
          $out.='), opt.substring(1));' . "\n";
          if ((STOCK_ALLOW_CHECKOUT == 'false' && ($curattr == count($attributes) - 2)) || PRODINFO_ATTRIBUTE_NO_ADD_OUT_OF_STOCK == 'True') {

Modify it to look like the below:

      $out.='), opt.substring(1));' . "\n";
      $out.='                        frm["id[' . $attributes[$nextattr]['oid'] . ']"].options[frm["id[' . $attributes[$nextattr]['oid'] . ']"].length - 1].innerHTML = frm["id[' . $attributes[$nextattr]['oid'] . ']"].options[frm["id[' . $attributes[$nextattr]['oid'] . ']"].length - 1].text;' . "\n";
      if ((STOCK_ALLOW_CHECKOUT == 'false' && ($curattr == count($attributes) - 2)) || PRODINFO_ATTRIBUTE_NO_ADD_OUT_OF_STOCK == 'True') {
> 
> and then again between lines 1066 and 1067 having this content:
> ```
          $out.='), opt.substring(1));' . "\n";
          if ((STOCK_ALLOW_CHECKOUT == 'false' && ($curattr == count($attributes) - 2)) || PRODINFO_ATTRIBUTE_NO_ADD_OUT_OF_STOCK == 'True') {

Modify it to look like:

      $out.='), opt.substring(1));' . "\n";
      $out.='                            frm["id[' . $attributes[$nextattr]['oid'] . ']"].options[frm["id[' . $attributes[$nextattr]['oid'] . ']"].length - 1].innerHTML = frm["id[' . $attributes[$nextattr]['oid'] . ']"].options[frm["id[' . $attributes[$nextattr]['oid'] . ']"].length - 1].text;' . "\n";
      if ((STOCK_ALLOW_CHECKOUT == 'false' && ($curattr == count($attributes) - 2)) || PRODINFO_ATTRIBUTE_NO_ADD_OUT_OF_STOCK == 'True') {
> 
> Between Lines 1052 and 1053 having this content:
> ```
        $out.=', opt.substring(1));' . "\n";
        $out.='                        }';

have it look like the following:

    $out.=', opt.substring(1));' . "\n";
    $out.='                            frm["id[' . $attributes[$nextattr]['oid'] . ']"].options[frm["id[' . $attributes[$nextattr]['oid'] . ']"].length - 1].innerHTML = frm["id[' . $attributes[$nextattr]['oid'] . ']"].options[frm["id[' . $attributes[$nextattr]['oid'] . ']"].length - 1].text;' . "\n";
    $out.='                        }';

Apparently my initial testing with the above change(s) was with a product condition that was incorrect. The testing involved a product that had prices in the first attribute (drawn by a different process) and not with a product that had attributes with prices in the second or subsequent attributes (option names). After testing with such a product the following was identified that corrected the reported issue (basically the array key addressing the "length" of the array should have had a '- 1' (in blue) in it in all cases.) Therefore, the following is recommended (and identified as functional):
Between lines 1091 and 1092 having this content:
      $out.='), opt.substring(1));' . "\n";
      if ((STOCK_ALLOW_CHECKOUT == 'false' && ($curattr ==  count($attributes) - 2)) || PRODINFO_ATTRIBUTE_NO_ADD_OUT_OF_STOCK ==  'True') {

Modify it to look like the below:
      $out.='), opt.substring(1));' . "\n";
      $out.='                        frm["id['  . $attributes[$nextattr]['oid'] . ']"].options[frm["id[' .  $attributes[$nextattr]['oid'] . ']"].length - 1].innerHTML = frm["id[' .  $attributes[$nextattr]['oid'] . ']"].options[frm["id[' .  $attributes[$nextattr]['oid'] . ']"].length - 1].text;' . "\n";
      if ((STOCK_ALLOW_CHECKOUT == 'false' && ($curattr ==  count($attributes) - 2)) || PRODINFO_ATTRIBUTE_NO_ADD_OUT_OF_STOCK ==  'True') {

and then again between lines 1066 and 1067 having this content:
      $out.='), opt.substring(1));' . "\n";
      if ((STOCK_ALLOW_CHECKOUT == 'false' && ($curattr ==  count($attributes) - 2)) || PRODINFO_ATTRIBUTE_NO_ADD_OUT_OF_STOCK ==  'True') {

Modify it to look like:
      $out.='), opt.substring(1));' . "\n";
      $out.='                             frm["id[' . $attributes[$nextattr]['oid'] . ']"].options[frm["id[' .  $attributes[$nextattr]['oid'] . ']"].length - 1].innerHTML = frm["id[' .  $attributes[$nextattr]['oid'] . ']"].options[frm["id[' .  $attributes[$nextattr]['oid'] . ']"].length - 1].text;' . "\n";
      if ((STOCK_ALLOW_CHECKOUT == 'false' && ($curattr ==  count($attributes) - 2)) || PRODINFO_ATTRIBUTE_NO_ADD_OUT_OF_STOCK ==  'True') {

Between Lines 1052 and 1053 having this content:
    $out.=', opt.substring(1));' . "\n";
    $out.='                        }';

have it look like the following:
    $out.=', opt.substring(1));' . "\n";
    $out.='                             frm["id[' . $attributes[$nextattr]['oid'] . ']"].options[frm["id[' .  $attributes[$nextattr]['oid'] . ']"].length - 1].innerHTML = frm["id[' .  $attributes[$nextattr]['oid'] . ']"].options[frm["id[' .  $attributes[$nextattr]['oid'] . ']"].length - 1].text;' . "\n";
    $out.='                        }';
27 Feb 2018, 23:14
#2902
madshaun1984 avatar

madshaun1984

New Zenner

Join Date:
Feb 2018
Posts:
19
Plugin Contributions:
0

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

mc12345678:

Apparently my initial testing with the above change(s) was with a product condition that was incorrect. The testing involved a product that had prices in the first attribute (drawn by a different process) and not with a product that had attributes with prices in the second or subsequent attributes (option names). After testing with such a product the following was identified that corrected the reported issue (basically the array key addressing the "length" of the array should have had a '- 1' (in blue) in it in all cases.) Therefore, the following is recommended (and identified as functional):
Between lines 1091 and 1092 having this content:

      $out.='), opt.substring(1));' . "\n";
      if ((STOCK_ALLOW_CHECKOUT == 'false' && ($curattr ==  count($attributes) - 2)) || PRODINFO_ATTRIBUTE_NO_ADD_OUT_OF_STOCK ==  'True') {
> 
> Modify it to look like the below:
> ```
          $out.='), opt.substring(1));' . "\n";
          $out.='                        frm["id['  . $attributes[$nextattr]['oid'] . ']"].options[frm["id[' .  $attributes[$nextattr]['oid'] . ']"].length - 1].innerHTML = frm["id[' .  $attributes[$nextattr]['oid'] . ']"].options[frm["id[' .  $attributes[$nextattr]['oid'] . ']"].length - 1].text;' . "\n";
          if ((STOCK_ALLOW_CHECKOUT == 'false' && ($curattr ==  count($attributes) - 2)) || PRODINFO_ATTRIBUTE_NO_ADD_OUT_OF_STOCK ==  'True') {

and then again between lines 1066 and 1067 having this content:

      $out.='), opt.substring(1));' . "\n";
      if ((STOCK_ALLOW_CHECKOUT == 'false' && ($curattr ==  count($attributes) - 2)) || PRODINFO_ATTRIBUTE_NO_ADD_OUT_OF_STOCK ==  'True') {
> 
> Modify it to look like:
> ```
          $out.='), opt.substring(1));' . "\n";
          $out.='                             frm["id[' . $attributes[$nextattr]['oid'] . ']"].options[frm["id[' .  $attributes[$nextattr]['oid'] . ']"].length - 1].innerHTML = frm["id[' .  $attributes[$nextattr]['oid'] . ']"].options[frm["id[' .  $attributes[$nextattr]['oid'] . ']"].length - 1].text;' . "\n";
          if ((STOCK_ALLOW_CHECKOUT == 'false' && ($curattr ==  count($attributes) - 2)) || PRODINFO_ATTRIBUTE_NO_ADD_OUT_OF_STOCK ==  'True') {

Between Lines 1052 and 1053 having this content:

    $out.=', opt.substring(1));' . "\n";
    $out.='                        }';
> 
> have it look like the following:
> ```
        $out.=', opt.substring(1));' . "\n";
        $out.='                             frm["id[' . $attributes[$nextattr]['oid'] . ']"].options[frm["id[' .  $attributes[$nextattr]['oid'] . ']"].length - 1].innerHTML = frm["id[' .  $attributes[$nextattr]['oid'] . ']"].options[frm["id[' .  $attributes[$nextattr]['oid'] . ']"].length - 1].text;' . "\n";
        $out.='                        }';

The lines didn't quite match up in the file on my server with those you specified, but once the lines had been found and edited, the drop down started working as expected immediately.

I haven't seen any debug logs generated since, so hopefully that will be that!

Thanks for the support on this! Much appreciated :)

06 Mar 2018, 16:34
#2903
athena avatar

athena

Totally Zenned

Join Date:
Jan 2006
Location:
NM
Posts:
740
Plugin Contributions:
0

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

Test site for 1.5.5f on Linux
I have latest SBA Combined from Github and Edit Orders installed. Stock seems to work fine unless I use Edit Orders to change a quantity of any item. The attributes disappear from the entire order in any further view of the order. The attributes disappear also from the invoice and the packing slip. I have a screen shot I will try and attach. Attachment 17726

06 Mar 2018, 17:55
#2904
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

What version of Edit Orders is being used?
Was product that was edited one tracked by SBA?
What of the other product were tracked by SBA?

When the feature was added such changes in quantity were tested for both SBA product as well as not and combinations including product being first in the list, middle and last, increase and decrease of product quantity.

06 Mar 2018, 18:45
#2905
athena avatar

athena

Totally Zenned

Join Date:
Jan 2006
Location:
NM
Posts:
740
Plugin Contributions:
0

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

mc12345678:

What version of Edit Orders is being used?
Was product that was edited one tracked by SBA?
What of the other product were tracked by SBA?

When the feature was added such changes in quantity were tested for both SBA product as well as not and combinations including product being first in the list, middle and last, increase and decrease of product quantity.

The vesion: Edit Orders v4.x for Zen Cart 1.5.x
I just went into edit an order with Edit Orders with several products, some with attributes and some without, and changed the color only of one product in the middle of the list. Pushed the update button and all attributes for all products in the order disappeared.

However: when I then, edit the same order with Edit Orders, to add an item with attributes it works and the item with attribute for that item shows up in the order and the math is corrected in the order total. If you can help me get this site up... been working on it too long now... I would employ you to do so. PM me.

06 Mar 2018, 19:06
#2906
athena avatar

athena

Totally Zenned

Join Date:
Jan 2006
Location:
NM
Posts:
740
Plugin Contributions:
0

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

SBA is tracking the stock. It will not let me add things that are out of stock through EditOrders. It does let me know that items were not updated because their attributes do not exist... since those attributes were eliminated in the previous test update; but it keeps the item in the order even though there is no attribute specified as required in the normal ordering process.

06 Mar 2018, 21:02
#2907
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

athena:

SBA is tracking the stock. It will not let me add things that are out of stock through EditOrders. It does let me know that items were not updated because their attributes do not exist... since those attributes were eliminated in the previous test update; but it keeps the item in the order even though there is no attribute specified as required in the normal ordering process.
Want to confirm. The product identified above that is shown as three different line items, that is a product tracked by SBA?

07 Mar 2018, 05:25
#2908
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

@athena, looks to me like there has been a change to edit orders that has caused this issue... Disabling the SBA portion of the code, a product/screen that is updated by selecting the update button has the attributes stripped from it... Still trying to work through that issue regardless.

07 Mar 2018, 11:38
#2909
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

mc12345678:

@athena, looks to me like there has been a change to edit orders that has caused this issue... Disabling the SBA portion of the code, a product/screen that is updated by selecting the update button has the attributes stripped from it... Still trying to work through that issue regardless.

Forgot to mention how to "disable the SBA portion". Renaming the file admin/includes/auto_loaders/config.eo_sba.php to have an extension other than .php ie: config.eo_sba.php.txt will prevent it from loading, without it loading, then the code related to SBA does not run when using edit orders. At least on the configuration I was running I had the same issue as described above where attributes of an existing product were stripped when selecting the update button from the edit orders screen. I didn't try modifying one of the attributes even or the quantity, just simply pressing the update button was enough to cause the issue.

07 Mar 2018, 19:28
#2910
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 above issue has been confirmed as being a result of a minor bug in Edit Orders version 4.3.1 and is to be corrected in the next release. The fix is posted here in the edit orders thread.

07 Mar 2018, 19:56
#2911
athena avatar

athena

Totally Zenned

Join Date:
Jan 2006
Location:
NM
Posts:
740
Plugin Contributions:
0

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

Thank you. Nice to know after years of working with SBA it is not the issue here. I can work on that edit to the edit-orders code myself but sent you some log in by pm so don't know if you are actively looking at it. Let's stay in touch. I had been over to the Edit-orders but worried I'd get chased off because it has always been an SBA issue for our cart over the years. ;)

23 Mar 2018, 16:41
#2912
athena avatar

athena

Totally Zenned

Join Date:
Jan 2006
Location:
NM
Posts:
740
Plugin Contributions:
0

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

155f install... live site.
I'm finding on admin/product.php or on my product pages in the admin that I am not seeing any reference to attributes for items with attributes. Previous to our upgrade from a very hacked version of SBA we did have a button on the product page, next to the quantity in stock, to take us to the attribute edit page for that item. There is a lot of code referring to attributes on the product.php page but I am not seeing the application for it. What does it do? Here is the SBA code edit but it does not seem to be related to the link to the product attribute edit page or do anything I can see on the admin/product.php page. Using Stock_By_Attributes_Combined-master folder for 1_5_6 ```
// BOF Added for Stock By Attributes SBA
$zco_notifier->notify('NOTIFY_ADMIN_PRODUCT_COPY_TO_ATTRIBUTES', $contents, $contents);
// EOF Added for Stock By Attributes SBA

23 Mar 2018, 21:47
#2913
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

athena:

155f install... live site.
I'm finding on admin/product.php or on my product pages in the admin that I am not seeing any reference to attributes for items with attributes. Previous to our upgrade from a very hacked version of SBA we did have a button on the product page, next to the quantity in stock, to take us to the attribute edit page for that item. There is a lot of code referring to attributes on the product.php page but I am not seeing the application for it. What does it do? Here is the SBA code edit but it does not seem to be related to the link to the product attribute edit page or do anything I can see on the admin/product.php page. Using Stock_By_Attributes_Combined-master folder for 1_5_6 ```
// BOF Added for Stock By Attributes SBA
$zco_notifier->notify('NOTIFY_ADMIN_PRODUCT_COPY_TO_ATTRIBUTES', $contents, $contents);
// EOF Added for Stock By Attributes SBA


As noted, the link that was previously seen was from modifications of some sort that had been applied to provide such a Stock By Attributes link from the product page.  (I think that I have seen such a link offered through one of Numinix' additional fields related modules.) 

The current implementation does not attempt to add such a link into that screen as perhaps the best user experience is to either offer the information  in the current screen or to open a separate window (new tab, new  browser, etc...) so as not to lose information already entered.  However, in following the ZC suggestions of accessing the admin, only one window to the admin should be open at any one time.  Adding a link directly on the product page that is always active (ie. not disabled once some change had been applied to the page and not yet saved) has not been a consideration within the current implementation.  There are changes afoot, I believe thanks to Design75, that will place all such content in tabs and allow a larger amount of product information to be edited in a single location rather than bouncing around.  To further take advantage of that "feature" whatever coding SBA would need would be incorporated into the SBA distribution to support that.  In the mean time, when viewing the products/categories listing, the SBA entry for a specific product can be found by a total of two bounces (requiring three clicks) by selecting the attributes icon, then selecting attributes controller (on the right) then selecting Stock By Attributes at the top of the screen which will open the SBA entry screen with the product selected for editing.

Regarding the notifier identified above which has been added in the respective product.php file for all supported versions, that notifier is included to support copying SBA attributes when copying a product (as a unique new item) tracked by SBA similar to copying the attributes of one product.  Note that the ZC code contained in the 1.5.6 files may not be up-to-date with the current alpha/beta distribution of ZC 1.5.6, but were identified as functional at the time of incorporation.  As development of ZC 1.5.6 continues, the SBA files are periodically updated to match.
26 Mar 2018, 14:15
#2914
athena avatar

athena

Totally Zenned

Join Date:
Jan 2006
Location:
NM
Posts:
740
Plugin Contributions:
0

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

Just thanking all who have worked on this. We can not upgrade without SBA: From Tom who uses it most: "There are three things I like about the New Stock By Attributes:

The list is sorted by model number, rather than product name. This helps as we update inventory. We use the model number to find items in the admin.

The list is searchable by model number. This helps us because we have so many items that are stocked by attributes.

We used to use a link to Stock By Attributes from the individual product admin page to go quickly to the attributes for a product. While this feature is now gone, the two features above make up for that. It would be nice to reestablish that link or make a tiny statement or icon next to the Products Quantity to help us know if the product has attributes or not. That “A” Icon is displayed on an admin product page that shows all the products in a category or in a search of the admin.

And there is now a link to Stock By Attributes from the Attributes Controller page. At least I think that is a new feature. That can come in handy when working with the option names and values and then jump right to Stock By Attributes to finish the product info."

27 Mar 2018, 15:59
#2915
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

athena:

Just thanking all who have worked on this. We can not upgrade without SBA: From Tom who uses it most: "There are three things I like about the New Stock By Attributes:

The list is sorted by model number, rather than product name. This helps as we update inventory. We use the model number to find items in the admin.

The list is searchable by model number. This helps us because we have so many items that are stocked by attributes.

We used to use a link to Stock By Attributes from the individual product admin page to go quickly to the attributes for a product. While this feature is now gone, the two features above make up for that. It would be nice to reestablish that link or make a tiny statement or icon next to the Products Quantity to help us know if the product has attributes or not. That “A” Icon is displayed on an admin product page that shows all the products in a category or in a search of the admin.

And there is now a link to Stock By Attributes from the Attributes Controller page. At least I think that is a new feature. That can come in handy when working with the option names and values and then jump right to Stock By Attributes to finish the product info."

Code that could be used to present a link/image based on data collected by SBA:
Does the product have attributes:

if (!empty((int)$_GET['pID']) && $products_with_attributes_stock_class->get_products_attributes((int)$_GET['pID']) !== false) {
  // Display icon/link for managing attributes of some type.
  // Link for Attributes Controller: zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'products_filter=' . (int)$_GET['pID'] . '&current_category_id=' . $current_category_id));
  // To determine if link should be associated with SBA:
  if ($_SESSION['pwas_class2']->zen_product_is_sba((int)$_GET['pID'])) {
    // Display icon/link for managing SBA attributes.
    // Link: zen_href_link(FILENAME_PRODUCTS_WITH_ATTRIBUTES_STOCK, 'seachPID=' . (int)$_GET['pID']);
  }

}

Where (int)$_GET['pID'] could be substituted with $pInfo->products_id depending where in the file this call is made and $current_category_id for use with the attributes controller is the category id associated with the product/current category in which the product is being edited.

From within the admin screen for filling in the product information (typically admin/includes/modules/PRODUCT_TYPE/collect_info.php), these variables are (int)$_GET['pID'] or $pInfo->products_id and (int)$current_category_id or $cInfo->categories_id, respectively. Though, until a product is stored, the only potentially useful data is the category related information. What this means is that a new product should not already have information in either the attributes controller nor in SBA (assuming database integrity for both tables) and that in the absence of either/both of those pieces of information that there would not be data available to identify the need for a link to either of those two locations for the current product.

Also note that currently once on the SBA product information screen, the product edit option is available to return to the product itself (selecting this option without first saving changes made to the onscreen data will result in loss of those changes). An option has not (yet) been added to go directly to the attributes controller from the SBA product information screen.

03 Jun 2018, 02:14
#2916
ttfan avatar

ttfan

Zen Follower

Join Date:
Jul 2010
Location:
Australia
Posts:
231
Plugin Contributions:
0

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

ZC 1.5.5d (live site in signature)
SBA 1.5.4
It's been working fine, but if you change the 'Quantity' of an attribute in admin, the "Quantity for all variants" does not update to reflect the total number of items. A "Sync Quantities" fixes this, but why does this not happen automatically?

03 Jun 2018, 04:52
#2917
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

ttfan:

ZC 1.5.5d (live site in signature)
SBA 1.5.4
It's been working fine, but if you change the 'Quantity' of an attribute in admin, the "Quantity for all variants" does not update to reflect the total number of items. A "Sync Quantities" fixes this, but why does this not happen automatically?

For some it is a feature, for others it can be a bug. A "clean" handling mechanism hasn't been developed, but there is this to consider and one of the things about continued development of this plugin.

There is no requirement that the sum of the individual variants must equal the sum of all possible products.

For example, a "product" could be made of a combination of individual attributes instead of a combination of attributes, take for example a product sold that has a size and a color of say a patch applied to it. There could be three sizes for example and a single patch quantity. When purchasing you can either add the patch or not. If there are 5 shirts of each of the three sizes and there happen to be only 8 patches. Should the total of the items be 23? Or really should it be15? What about for those that sell the item only if all options are available and therefore only 8?

Currently only variations that are fully defined by combination of attributes or those not having any combinations but instead all individual are best supported. There isn't yet a process incorporated to cleanly handle both on a single product.

03 Jun 2018, 05:55
#2918
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

mc12345678:

For some it is a feature, for others it can be a bug. A "clean" handling mechanism hasn't been developed, but there is this to consider and one of the things about continued development of this plugin.

There is no requirement that the sum of the individual variants must equal the sum of all possible products.

For example, a "product" could be made of a combination of individual attributes instead of a combination of attributes, take for example a product sold that has a size and a color of say a patch applied to it. There could be three sizes for example and a single patch quantity. When purchasing you can either add the patch or not. If there are 5 shirts of each of the three sizes and there happen to be only 8 patches. Should the total of the items be 23? Or really should it be15? What about for those that sell the item only if all options are available and therefore only 8?

Currently only variations that are fully defined by combination of attributes or those not having any combinations but instead all individual are best supported. There isn't yet a process incorporated to cleanly handle both on a single product.
Another way this can be used for store owners (until yet another feature is specifically added) is that the total quantity of product can be larger than the sum of the available variants so that the product can remain visible even when all of the current variants are sold out.

By having a quantity of product still available, a store set to disable product when the quantity is goes to zero (ie. Can not oversell product) will still show the product. The display of "normally" available attributes is controlled by other settings but could potentially display all possible variants with all being out-of-stock for those that wish to be able to show potential variants.

On the flip side, a product could be made to go out-of-stock after x product have been sold regardless the individual variant availability by only identifying the x quantity of product. Then after selling that many product it goes out-of-stock...

I'm aware that it would be helpful to also have the click to edit option on the admin screen and I believe there is sufficient code available to incorporate it, but I haven't yet.

At the moment I'm trying to incorporate some other development code to address strict php processing and some other minor user improvements/features that have been developed. Quite literally have been doing that today among other things with other software.

I'm sure I can think of other ways that the total quantity as compared to the individual variant quantity can be used to accomplish a goal. For now I've been trying to not to unnecessarily limit the capability even if it may require a little extra effort/thought for those just wanting basic stock control of attribute related product.

03 Jun 2018, 09:57
#2919
ttfan avatar

ttfan

Zen Follower

Join Date:
Jul 2010
Location:
Australia
Posts:
231
Plugin Contributions:
0

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

That makes perfect sense, thank you mc12345678!

22 Jun 2018, 16:04
#2920
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

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

This may be a bug/omission but given the complexities of this mod I wouldn't be surprised if I just didn't understand.

When adding a product to the cart my config settings are such that the cart is not displayed and I instead get a popup saying for example:

'Men's Red Shoe' was added to your basket

If I do the same with a product priced by attributes and SBA, I get:

was added to your basket

eventually I found that in includes\extra_cart_actions\stock_by_attributes.php

around line 1064

// display message if all is good and not on shopping_cart page
            if (DISPLAY_CART == 'false' && $_GET['main_page'] != FILENAME_SHOPPING_CART && $messageStack->size('shopping_cart') == 0) {
              $messageStack->add_session('header', ($_SESSION['cart']->display_debug_messages ? 'FUNCTION ' . __FUNCTION__ . ': ' : '') . SUCCESS_ADDED_TO_CART_PRODUCT, 'success');

needed to be changed to

  // display message if all is good and not on shopping_cart page
            if (DISPLAY_CART == 'false' && $_GET['main_page'] != FILENAME_SHOPPING_CART && $messageStack->size('shopping_cart') == 0) {
              $messageStack->add_session('header', ($_SESSION['cart']->display_debug_messages ? 'FUNCTION ' . __FUNCTION__ . ': ' : '') . '\'' . zen_get_products_name($_POST['products_id']) . '\'' . SUCCESS_ADDED_TO_CART_PRODUCT, 'success');

so that the zen_get_products_name function is called when adding a 'SBA' product to the cart.