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

Results 2,581 to 2,600 of 3,609
20 Jul 2016, 6:33 PM
#2581
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

Found the solution like 2 hours ago, but haven't had a chance to write it up for others to reproduce. Involves changing a for loop into a foreach loop.

20 Jul 2016, 6:45 PM
#2582
badarac avatar

badarac

Totally Zenned

Join Date:
Aug 2009
Location:
Longs, SC
Posts:
635
Plugin Contributions:
0

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

mc12345678:

Found the solution like 2 hours ago, but haven't had a chance to write it up for others to reproduce. Involves changing a for loop into a foreach loop.
If you want to point me at it I'll test it here

20 Jul 2016, 7:00 PM
#2583
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

badarac:

If you want to point me at it I'll test it here
Let me see if I have enough resources immediately available.

I know it's in the includes/functions/extra_functions file.
Then in zen_get_sba_stock_attribute there is the ```
for ($j =0; $j < $k; $j++)


If changed to like:

foreach ($attribute_list as $j => $attrib_data)


I'm not sure if I'm set on the second part of the variable, but for current operation and coding it doesn't matter, the stock of a multi-attribute (combined) variant did get reduced. I had tried a couple of other things as well, but when I restored the for loop it broke it, when I used foreach it worked...
20 Jul 2016, 7:16 PM
#2584
badarac avatar

badarac

Totally Zenned

Join Date:
Aug 2009
Location:
Longs, SC
Posts:
635
Plugin Contributions:
0

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

mc12345678:

Let me see if I have enough resources immediately available.

I know it's in the includes/functions/extra_functions file.
Then in zen_get_sba_stock_attribute there is the ```
for ($j =0; $j < $k; $j++)

> 
> If changed to like:
> ```
foreach ($attribute_list as $j => $attrib_data)

I'm not sure if I'm set on the second part of the variable, but for current operation and coding it doesn't matter, the stock of a multi-attribute (combined) variant did get reduced. I had tried a couple of other things as well, but when I restored the for loop it broke it, when I used foreach it worked...

That worked fine. Thanks!

Here's the code to change at line 243 from

    if (isset($attribute_list) && is_array($attribute_list) && ($k = sizeof($attribute_list) > 0)) {
      if ($from == 'order') {
        for ($j = 0; $j < $k; $j++) { // Change this line to fix update stock 
		if (true) { // mc12345678 Here is one place where verification can be performed as to whether a particular attribute should be added.  This is probably the best place to do the review because all aspects of the attribute are available.
            $temp_attributes[$attribute_list[$j]['option_id']] = $attribute_list[$j]['value_id'];
          }
        }
        $attribute_list = $temp_attributes;

Change it to

    if (isset($attribute_list) && is_array($attribute_list) && ($k = sizeof($attribute_list) > 0)) {
      if ($from == 'order') {
       		foreach ($attribute_list as $j => $attrib_data) { //Changed to fix update stock 
          if (true) { // mc12345678 Here is one place where verification can be performed as to whether a particular attribute should be added.  This is probably the best place to do the review because all aspects of the attribute are available.
            $temp_attributes[$attribute_list[$j]['option_id']] = $attribute_list[$j]['value_id'];
          }
        }
        $attribute_list = $temp_attributes;
20 Jul 2016, 8:18 PM
#2585
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

So I committed that solution to the github repo, though I continued to use spaces instead of tabs. :P Still need/want to verify that quantities for all entries decrease as expected if the product is made up of multiple individual attributes...

Again, thank you for the backup, comment, and testing... I did find a few other minor improvements, but that type of thing I think is going to continue as I now get more of a chance to review the code rather than either write new or rewrite existing code. Starting to slip little things in like buttons to move from one area to another to make manipulation/navigation easier, going to modify some of the admin portion of the SBA editing area so that can grow a little and maybe add some additional fields, either add a switch or an indicator if a set of attributes are using the simple SBA dropdown option and allow that setting to be modified (for all such attributes, or could specialize it for just that/those attributes on that product, etc), looking to move those extra functions into a class instead so that at least things are consolidated and since it seems the SBA "code" really is only used by SBA, otherwise there's a few pieces of information to be displayed which could come from SBA. Lot's of little things, but want to tidy up a little and get some additional consistency on the customid. :)

24 Jul 2016, 12:32 AM
#2586
helenewallis avatar

helenewallis

Totally Zenned

Join Date:
Jun 2016
Location:
Suffolk VA
Posts:
625
Plugin Contributions:
0

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

SBA is something I really could use, but do I understand that it's not compatible with Zencart v.155? Would it be better for me to wait until 1.6 is released? I don't have such huge inventory that it will be a major problem right now, but that is likely to change.

24 Jul 2016, 1:03 AM
#2587
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

HeleneWallis:

SBA is something I really could use, but do I understand that it's not compatible with Zencart v.155? Would it be better for me to wait until 1.6 is released? I don't have such huge inventory that it will be a major problem right now, but that is likely to change.

Umm... Did you happen to look back a "page" (assuming your view supports page viewing?) Or at post 2571?

It has not been issued to the ZC site yet for ZC 1.5.5, but that is because there are a few known things still being worked on, but in general it is pretty darn close. Trying to touch a few odds and ends that seem easy to address, and then should be able to get the instructions updated that potteryhouse worked on and submit as an updated plugin compatible with ZC 1.5.1 through 1.5.5.

Current location is on github.

24 Jul 2016, 7:58 PM
#2588
tjalling avatar

tjalling

New Zenner

Join Date:
Jul 2016
Location:
Amsterdam
Posts:
5
Plugin Contributions:
0

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

Help, I'm trying to get Stock_By_Attributes_Combined-master working on the new ZC 1.5.5.
But somewere I get stucked.

It's all working fine untill I try to put something in the basket. Then the store gives a faillure.

*Fatal error: 1054:Unknown column 'Array' in 'where clause' :: select products_attributes_id
from products_attributes
where options_values_id = Array
and products_id = 1

              order by products_attributes_id ==> (as called by) /customers/4/8/9/phaedram.nl/httpd.www/includes/functions/extra_functions/products_with_attributes.php on line 378 <== in /customers/4/8/9/phaedram.nl/httpd.www/includes/classes/db/mysql/query_factory.php on line 167*

Can someone please give me a hint where to look for?

24 Jul 2016, 11:04 PM
#2589
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

So, looking at the code that is available right now, it seems like that area of the includes/functions/extra_functions/products_with_attributes.php file is supposed to be provided a value that is fed to an array and then the array is imploded (which takes each array item, and puts it together with the previous) thus no array is left behind...

What is unique about the product? Is it some sort of special product type? What plugin(s) are also installed. Can't reproduce the issue unless the attribute(s) of the product are themselves some sort of array of additional attributes or the like.

How about a Web address?

25 Jul 2016, 7:11 PM
#2590
tjalling avatar

tjalling

New Zenner

Join Date:
Jul 2016
Location:
Amsterdam
Posts:
5
Plugin Contributions:
0

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

The webstore is: http://www.phaedram.nl

And other plugin's are: edit orders, super orders, ideal and dutch translation. These plugins work just fine.
And also Stock by attribute, that is until I try to put a item in the basket.

Tjalling

25 Jul 2016, 7:57 PM
#2591
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

Ahhh, check boxes... I can't say that I've done a lot of testing with them (yet)...

Is there a reason you have chosen to use check boxes instead of any of the other attribute types?

One reason I ask is because it is possible to add the product to the cart with no checkboxes marked (product is added with a cost of 0.00), it is also possible to add one product with 1 checkbox marked, but if two or more are marked from the same option name then sba has a problem (will work to resolve that regardless of your final decision in this matter.)

So, in testing the product referenced above, it is possible to add a product to the cart, but not two at the same time when using two or more check boxes.

If you would prefer to allow a customer to add x quantity of say Bramen & Mango and y quantity of Limoen & Koffie and press the add-to-cart button one time, then I would suggest adding product attributes grid to your installation instead of check boxes for this "arrangement".

25 Jul 2016, 9:49 PM
#2592
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

I was wrong in my previous post. I stated that checkboxes could at least be handled as part of being stock. So far, the testing that I have done, checkboxes alone do not track well with SBA in that when I had a store setup to not display the cart after adding product, one option name, had two option values. Selecting any combination of check boxes (or none) while stock was applied to one or more of the checked values, did not add the product to the cart.

Apparently what I saw in the above site, was still being modified as I was testing and the checkboxes had not had stock applied to them (therefore responding as a normal ZC operation). Anyways, I still need to test a few other cases to see what the limits are, but I have the following:

Okay. Checkboxes... I've started an issue on Github related to checkboxes. Looking for some input.

I'm beginning to think that checkboxes should not be treated as stock related quantities. Besides the complexity that can be added to the code, I'm thinking about this from the side of stock control...

A checkbox typically has two states, though it could have a third "intermittent" state at least in assignment. Generally only two states are considered, checked or not checked. Further, general usage seems to be such that, yes I agree/have read/etc... or please add this to the object/purchase. A perceived "normal" usage is like please make this with the added color, style, shape or I'll take that free item with it, or I do have something more to add. While it may be possible to consider each of those traits as something that could be tracked by stock, and actually part of the design/incorporation already is to consider the gift wrap condition (please add gift wrap to this product or not) such that the quantity of giftwrap is not actually tracked, just the fact that such a selection has been made or not.

By trying to track such items as stockable quantities, if 2 or more checkboxes are applied to a single option name or if two separate option names have checkboxes, then each combination of check/unchecked item must be considered. Now the other alternative is or could be that the checkboxed item itself is (or is not) tracked by stock, such that if someone does offer a checkbox item that represents a physical object (assume x number of "free" things to give away or first y people that select this get it) then the checked item could be tracked separately from the rest of the product. Now, there are certainly ever larger possibilities, but it seems that in the confines of the existing attribute system, that this may be the limit of what can be done without redeveloping the attribute system.

Anyways, there are obviously a few things to work out when using checkboxes, again I thought I was close to simply cleaning up code, simplifying some of the actions and adding a few features or at least working some of the code to make that easier to do. And along comes someone who is trying their best to setup their store their way and an issue is found. :P ahh well...

26 Jul 2016, 9:02 AM
#2593
kenton avatar

kenton

New Zenner

Join Date:
Sep 2011
Posts:
38
Plugin Contributions:
0

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

Without wanting to get slammed for not searching this thread, which I did, but obviously without the correct search terms, how do I get the stock level so show next to the attribute?

Ie, http://www.skysports.com.au/index.php?main_page=product_info&cPath=2_19&products_id=189 is currently showing 8 total units in stock, but I want it to show 3 black, 1 silver and 4 red

I am using SBA 1.5.4 and ZC 1.5.5a

Thanks
Kenton

26 Jul 2016, 10:02 AM
#2594
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

Kenton:

Without wanting to get slammed for not searching this thread, which I did, but obviously without the correct search terms, how do I get the stock level so show next to the attribute?

Ie, http://www.skysports.com.au/index.php?main_page=product_info&cPath=2_19&products_id=189 is currently showing 8 total units in stock, but I want it to show 3 black, 1 silver and 4 red

I am using SBA 1.5.4 and ZC 1.5.5a

Thanks
Kenton

Hard to say with only the version number as there is/was an issue with an option developed by potteryhouse getting added to the system setup. The problem was recently resolved in the version of SBA hosted/continued on at https://github.com/mc12345678/Stock_By_Attributes_Combined. So the long and short of it is if in the option names manager you have something like simple SBA select (dropdown) as an option, then that option supports reporting the quantity of that attribute remaining. If that is already active for your single dropdown, then the settings are in the stock/attribute settings of the configuration menu. If you are using multiple attributes (multiple option names) then that setting is in Dynamic Dropdowns and the first option name above doesn't matter. If using DD, the quantity only appears at the last available selection or in the case of an out-of-stock option at the point where no further stock is available below the current selection.

26 Jul 2016, 10:12 AM
#2595
kenton avatar

kenton

New Zenner

Join Date:
Sep 2011
Posts:
38
Plugin Contributions:
0

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

mc12345678:

So the long and short of it is if in the option names manager you have something like simple SBA select (dropdown) as an option, then that option supports reporting the quantity of that attribute remaining. If that is already active for your single dropdown, then the settings are in the stock/attribute settings of the configuration menu.

Bingo! .... (except I can't see the images of the different colours now) but I'd much rather have the stock levels shown.

Thanks for your timely reply

Kenton

26 Jul 2016, 10:56 AM
#2596
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

Kenton:

Bingo! .... (except I can't see the images of the different colours now) but I'd much rather have the stock levels shown.

Thanks for your timely reply

Kenton

That too is addressed in the latest update.

There is now an option in the configuration menu (again latest update) that permits display of attribute images as positioned/assigned in the option names manager, an option that allows swapping the image with the selected one (and display of the attribute images assigned) and a third position of allowing swapping but hiding the attributes images designated to the option name/values. Currently in the ZC options, there is no selection for hiding of images (requires CSS if an image is assigned to an option value), so instead, an option has been added to SBA to basically disable the attribute images.

Now before the crowds rejoice on the image swapping, it primarily works only with product with single attribute at the moment. I'm trying to work on a system for multiple attributes, but it is also possible to do/assign swapping through some other code changes for those with multiple attributes.

Otherwise, at the bottom of the includes/modules/YOUR_TEMPLATE/attributes.php file there is an if statement surrounding I think options_names_images or something similar. Because of that logic, your previous images are not displayed... Either clear that logic out or set the settings in the configuration menu to offer your attribute display.

30 Jul 2016, 8:46 AM
#2597
tjalling avatar

tjalling

New Zenner

Join Date:
Jul 2016
Location:
Amsterdam
Posts:
5
Plugin Contributions:
0

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

mc12345678:

Ahhh, check boxes... I can't say that I've done a lot of testing with them (yet)...

Is there a reason you have chosen to use check boxes instead of any of the other attribute types?

One reason I ask is because it is possible to add the product to the cart with no checkboxes marked (product is added with a cost of 0.00), it is also possible to add one product with 1 checkbox marked, but if two or more are marked from the same option name then sba has a problem (will work to resolve that regardless of your final decision in this matter.)

So, in testing the product referenced above, it is possible to add a product to the cart, but not two at the same time when using two or more check boxes.

If you would prefer to allow a customer to add x quantity of say Bramen & Mango and y quantity of Limoen & Koffie and press the add-to-cart button one time, then I would suggest adding product attributes grid to your installation instead of check boxes for this "arrangement".

Best mc12345678,

Thanks for poiting out towards "Grid".
This is perfect. I was just using checkboxes because in the older ZC 1.5 this works fine.
Only one comment by using the new SBA with ZC1.5.5!
The SBA ../admin/invoice is not working perfect. The attributes will not show up on the invoice by printing this invoice.
Just install the original ../admin/invoice of the ZC 1.5.5 and all is working fine.
SBA is already preparred in the invoice.

30 Jul 2016, 9:45 AM
#2598
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

Tjalling:

Best mc12345678,

Thanks for poiting out towards "Grid".
This is perfect. I was just using checkboxes because in the older ZC 1.5 this works fine.
Only one comment by using the new SBA with ZC1.5.5!
The SBA ../admin/invoice is not working perfect. The attributes will not show up on the invoice by printing this invoice.
Just install the original ../admin/invoice of the ZC 1.5.5 and all is working fine.
SBA is already preparred in the invoice.

Couple of things, the older SBA didn't have extra code to receive and process the selected options (extra_cart_actions file) and most older versions of this did not fully support mixed attributes which is where the consideration of multiple checkboxes could come to be a problem if allowed primarily in the case of multiple attributes where "mixed" checkboxes come into play. So, the base ZC code was able to handle a checkbox. Also, something I added to provide a better customer experience is a check of the attributes pushed to the cart when pushed. A check could be done when moving to checkout, but that seems to be too late in the process. Anyways, that check didn't consider checkboxes as part of the process. I've found some ways around it but am right now trying to address some deeper operations.

Yes, the admin/invoice.php file is the first one attempted to use some newer coding to provide the customid. It does appear to have a problem though an older version of it was functional (could use github to look back on the history of the admin/invoice file and see where the current code was first introduced and revert the changes back to that.) I'll be working on that functionality soon as well because the admin side of the customid needs some work to transition to using the data that it has been storing instead of using what currently exists for the catalog side.

Thank you though for reminding me of that one. I'm going to add it to my list of issues so that I can knock it out for new users to at least have a functional invoice with SBA.

30 Jul 2016, 1:45 PM
#2599
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:

Couple of things, the older SBA didn't have extra code to receive and process the selected options (extra_cart_actions file) and most older versions of this did not fully support mixed attributes which is where the consideration of multiple checkboxes could come to be a problem if allowed primarily in the case of multiple attributes where "mixed" checkboxes come into play. So, the base ZC code was able to handle a checkbox. Also, something I added to provide a better customer experience is a check of the attributes pushed to the cart when pushed. A check could be done when moving to checkout, but that seems to be too late in the process. Anyways, that check didn't consider checkboxes as part of the process. I've found some ways around it but am right now trying to address some deeper operations.

Yes, the admin/invoice.php file is the first one attempted to use some newer coding to provide the customid. It does appear to have a problem though an older version of it was functional (could use github to look back on the history of the admin/invoice file and see where the current code was first introduced and revert the changes back to that.) I'll be working on that functionality soon as well because the admin side of the customid needs some work to transition to using the data that it has been storing instead of using what currently exists for the catalog side.

Thank you though for reminding me of that one. I'm going to add it to my list of issues so that I can knock it out for new users to at least have a functional invoice with SBA.

Okay, found and corrected the issue(s).

For all versions of ZC supported by this plugin, on the admin side in admin/includes/classes/observers/class.products_with_attributes_stock.php at/around line 145, change:

$customid = $products_with_attributes_[B]with_[/B]stock_class->zen_get_customid($order->products[$i]['id'],$slipInLoopAttribs);

to:

$customid = $products_with_attributes_stock_class->zen_get_customid($order->products[$i]['id'],$slipInLoopAttribs);

By removing the additional with_

in the applicable ZC version, admin/invoice.php

Around line 190 depending on the ZC version, change:

$customid = ' ' . $products_with_attributes_class->zen_get_customid($order->products[$i]['id'],$attributes) . ' '; 

to:

$customid = ' ' . $products_with_attributes_stock_class->zen_get_customid($order->products[$i]['id'],$attributes) . ' '; 

by adding the word with underscore: stock_

Both of these issues were introduced when trying to incorporate/reference a variable that previously was individually declared adding more code changes to the files and while there already was a variable declared that just needed to be "shared". Github has been updated with the above edits applied.

These are the only places that I found the variable incorrectly referenced as above. The error in the logs directory should identify that there was a call to a member function XXX on null. The XXX represents the function attempted to be called. This also results in a partial blank screen the help for which is provided in the FAQ section of this forum.

20 Aug 2016, 5:36 PM
#2600
stellarweb avatar

stellarweb

Zen Follower

Join Date:
May 2006
Location:
Montana
Posts:
293
Plugin Contributions:
8

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

I am having an issue that is making me pull my hair out! lol

History... upgrading a 1.5.0 cart to 1.5.4
Installed latest "combo" version of SBA from github and get an error in logs as follows when going to a product page - which is blank:

[20-Aug-2016 13:21:11 America/New_York] PHP Parse error: syntax error, unexpected '[' in /home/elkkidsc/public_html/store2/includes/classes/observers/class.products_with_attributes_stock.php on line 671

When I look at it in Dreamweaver it shows two lines as "red" indicating an error:
Attachment 16599