Re: Stock by Attribute v4.0 for Zen Cart 1.5.1+
Quote:
Originally Posted by
mc12345678
Looks like in admin/includes/classes/products_with_attributes_stock.php Line 557 should change: isset to !empty
Seems the same applies to line 564 as well.
Changing
isset(
To:
!empty(
Alternatively could go ahead and initialize that variable from the code making the call. Instead of defaulting its value to an array, it could be defaulted to null and then made whatever is desired on that.
Confirmed, for those two locations, changing isset to !empty fixed the issue.
in admin/includes/classes/products_with_attributes_stock.php
from:
Code:
if (isset($ReturnedProductID) && is_array($ReturnedProductID)) {
foreach ($ReturnedProductID as $key => &$singleID) {
$singleID = (int)zen_db_input($singleID);
}
unset($singleID);
$w = " AND (p.products_id IN (" . implode(',', $ReturnedProductID) . " )) ";
$ReturnedProductID = array_pop($ReturnedProductID);
} elseif (isset($ReturnedProductID)) {
To:
Code:
if (!empty($ReturnedProductID) && is_array($ReturnedProductID)) {
foreach ($ReturnedProductID as $key => &$singleID) {
$singleID = (int)zen_db_input($singleID);
}
unset($singleID);
$w = " AND (p.products_id IN (" . implode(',', $ReturnedProductID) . " )) ";
$ReturnedProductID = array_pop($ReturnedProductID);
} elseif (!empty($ReturnedProductID)) {
Re: Stock by Attribute v4.0 for Zen Cart 1.5.1+
Quote:
Originally Posted by
mc12345678
Confirmed, for those two locations, changing isset to !empty fixed the issue.
I was just about to confirm the same.
Thanks for your assistance on this McNumbers
Re: Stock by Attribute v4.0 for Zen Cart 1.5.1+
Quote:
Originally Posted by
strelitzia
I was just about to confirm the same.
Thanks for your assistance on this McNumbers
Thanks for pointing it out and look forwards to the admin revisions. I updated the github fileset around the time I posted my verification.
I was able to confirm operation because I have/had a record that triggers the alternate group of information (which was showing when I went through testing). I "disabled" capturing the information to validate that the expected text "place holder" was shown. Not saying I really like the default text that is there, but I wanted something to be shown so that if/when a problem occurred one may recognize the discrepancy.
Further note that generally speaking I don't expect that this area of code will need to be accessed in a store that implemented SBA at/after the point that option names/values were monitored for deletion. It was prior to that point in time that deletion of option names/values from the standard part of the store did not carry into SBA. As a result a product that was previously tracked by SBA and had variants present before attribute deletion would appear to still be tracked by SBA even if it no longer had attributes. (When that happens a mydebug log gets generated during attempts to checkout) A little more can be read up on that in dbltoe's recent posts a few pages back (337 based on my current use of 10 posts per page).
Re: Stock by Attribute v4.0 for Zen Cart 1.5.1+
Quote:
Originally Posted by
mc12345678
Thanks for pointing it out and look forwards to the admin revisions
I have a quick query regarding the initial products_with_attributes_stock page.
Below the text Stock By Attributes - Top there is a dropdown where I can select a category. Making a selection here will open the products_filter select which displays all the products within that category.
I'm trying to figure out the difference between the 'Search' button above the select, and the 'display' button to the right of the select.
Both seem to have the same end result of displaying the selected product. Can one of these be removed, or is there another purpose for one or the other that I am unaware of?
If one can be removed, which button label would you prefer to stay. IMO, 'display' seems to make more sense as you are not actually searching for anything at this point, merely making an option selection from what's presented in the select.
1 Attachment(s)
Re: Stock by Attribute v4.0 for Zen Cart 1.5.1+
@mc12345678
A quick preview of the modified layout for the first section of the page (pending your response re the 'search' button.
Attachment 19591
Re: Stock by Attribute v4.0 for Zen Cart 1.5.1+
I've come across an issue that appears to be SBA related as prior to it being installed there was no such problem.
Site is running ZC 1.5.7c with the latest version of SBA from Github
Admin>Configuration>Stock>Allow Checkout set to 'false'
If there are any products in the cart that DO NOT have variants set, these can be either products with, or without attributes, it is not possible to proceed from shopping cart to checkout.
The following error gets logged.
[08-Jun-2021 22:39:26 Europe/London] Request URI: /index.php?main_page=checkout_shipping, IP address: 82.5.203.28
#1 explode() called at [/home/mysite/public_html/includes/functions/functions_general_shared.php:147]
#2 zen_get_prid() called at [/home/mysite/public_html/includes/functions/functions_lookups.php:174]
#3 zen_get_products_stock() called at [/home/mysite/public_html/includes/classes/observers/class.products_with_attributes_stock.php:1869]
#4 products_with_attributes_stock->updateNotifyHeaderStartCheckoutShipping() called at [/home/mysite/public_html/includes/classes/class.base.php:118]
#5 base->notify() called at [/home/mysite/public_html/includes/modules/pages/checkout_shipping/header_php.php:11]
#6 require(/home/mysite/public_html/includes/modules/pages/checkout_shipping/header_php.php) called at [/home/mysite/public_html/index.php:35]
--> PHP Warning: explode() expects parameter 2 to be string, array given in /home/mysite/public_html/includes/functions/functions_general_shared.php on line 147.
Any suggestions on this issue?
Re: Stock by Attribute v4.0 for Zen Cart 1.5.1+
Quote:
Originally Posted by
strelitzia
I've come across an issue that appears to be SBA related as prior to it being installed there was no such problem.
Site is running ZC 1.5.7c with the latest version of SBA from Github
Admin>Configuration>Stock>Allow Checkout set to 'false'
If there are any products in the cart that DO NOT have variants set, these can be either products with, or without attributes, it is not possible to proceed from shopping cart to checkout.
The following error gets logged.
Code:
[08-Jun-2021 22:39:26 Europe/London] Request URI: /index.php?main_page=checkout_shipping, IP address: 82.5.203.28
#1 explode() called at [/home/mysite/public_html/includes/functions/functions_general_shared.php:147]
#2 zen_get_prid() called at [/home/mysite/public_html/includes/functions/functions_lookups.php:174]
#3 zen_get_products_stock() called at [/home/mysite/public_html/includes/classes/observers/class.products_with_attributes_stock.php:1869]
#4 products_with_attributes_stock->updateNotifyHeaderStartCheckoutShipping() called at [/home/mysite/public_html/includes/classes/class.base.php:118]
#5 base->notify() called at [/home/mysite/public_html/includes/modules/pages/checkout_shipping/header_php.php:11]
#6 require(/home/mysite/public_html/includes/modules/pages/checkout_shipping/header_php.php) called at [/home/mysite/public_html/index.php:35]
--> PHP Warning: explode() expects parameter 2 to be string, array given in /home/mysite/public_html/includes/functions/functions_general_shared.php on line 147.
Any suggestions on this issue?
Reproduced with same setting of limiting stock to what is available (not allowing checkout if stock is out).
Brief review of the code of the observer indicates that because I've changed to using an array internally for this area of code, that at/before any return from the function should set the products_quantity and the handled flag. Further, because of the early escape reasons for leaving the function and that there is a reason within SBA code to effectively duplicate the return logic from zen_get_products_stock, I will create a separate internal class method that will effectively use the code from the ZC software. Not at all what I really want(ed) to do, but doing this removed(s) the need to modify the core code. Anyways, I expect to have something in a few hours. Have some other things to which to tend.
I can say that testing of product with/without variants and attributes was performed it appears with the above configuration set to true. That works, but... does not support all stores and would permit overselling when that is not acceptable/desired...
Re: Stock by Attribute v4.0 for Zen Cart 1.5.1+
Quote:
Originally Posted by
strelitzia
I've come across an issue that appears to be SBA related as prior to it being installed there was no such problem.
Site is running ZC 1.5.7c with the latest version of SBA from Github
Admin>Configuration>Stock>Allow Checkout set to 'false'
If there are any products in the cart that DO NOT have variants set, these can be either products with, or without attributes, it is not possible to proceed from shopping cart to checkout.
The following error gets logged.
Code:
[08-Jun-2021 22:39:26 Europe/London] Request URI: /index.php?main_page=checkout_shipping, IP address: 82.5.203.28
#1 explode() called at [/home/mysite/public_html/includes/functions/functions_general_shared.php:147]
#2 zen_get_prid() called at [/home/mysite/public_html/includes/functions/functions_lookups.php:174]
#3 zen_get_products_stock() called at [/home/mysite/public_html/includes/classes/observers/class.products_with_attributes_stock.php:1869]
#4 products_with_attributes_stock->updateNotifyHeaderStartCheckoutShipping() called at [/home/mysite/public_html/includes/classes/class.base.php:118]
#5 base->notify() called at [/home/mysite/public_html/includes/modules/pages/checkout_shipping/header_php.php:11]
#6 require(/home/mysite/public_html/includes/modules/pages/checkout_shipping/header_php.php) called at [/home/mysite/public_html/index.php:35]
--> PHP Warning: explode() expects parameter 2 to be string, array given in /home/mysite/public_html/includes/functions/functions_general_shared.php on line 147.
Any suggestions on this issue?
Quote:
Originally Posted by
mc12345678
Reproduced with same setting of limiting stock to what is available (not allowing checkout if stock is out).
Brief review of the code of the observer indicates that because I've changed to using an array internally for this area of code, that at/before any return from the function should set the products_quantity and the handled flag. Further, because of the early escape reasons for leaving the function and that there is a reason within SBA code to effectively duplicate the return logic from zen_get_products_stock, I will create a separate internal class method that will effectively use the code from the ZC software. Not at all what I really want(ed) to do, but doing this removed(s) the need to modify the core code. Anyways, I expect to have something in a few hours. Have some other things to which to tend.
I can say that testing of product with/without variants and attributes was performed it appears with the above configuration set to true. That works, but... does not support all stores and would permit overselling when that is not acceptable/desired...
How about this commit: https://github.com/mc12345678/Stock_...4432003eba31ca
Re: Stock by Attribute v4.0 for Zen Cart 1.5.1+
I'll have a look at that in a moment and report back .
One other question. In the shopping cart it displays the image assigned to the attribute for the selected variant. Unless I missed it in admin somewhere, I don't see any way to override this as an option. The site where SBA is being used has icons to represent different strengths of a product, so having this display as the product image in cart is not a desirable option in this use case.
If it's not admin switchable, can you point me to the file where this is controlled so I can modify the behaviour? Perhaps add it as a configurable option if not already.
Re: Stock by Attribute v4.0 for Zen Cart 1.5.1+
Quote:
Originally Posted by
strelitzia
I'll have a look at that in a moment and report back .
One other question. In the shopping cart it displays the image assigned to the attribute for the selected variant. Unless I missed it in admin somewhere, I don't see any way to override this as an option. The site where SBA is being used has icons to represent different strengths of a product, so having this display as the product image in cart is not a desirable option in this use case.
If it's not admin switchable, can you point me to the file where this is controlled so I can modify the behaviour? Perhaps add it as a configurable option if not already.
General design consideration had been to use/consider attribute swap to replace the main product image with the image for the selected attribute(s). The only control at the moment on the above particular feature was whether to show the image of the product on the shopping cart or not. Seeing as it is desired to show the image on the cart, an alternative "test" is/would be necessary to accomodate.
At the moment the "easiest" fix without touching the database (either adding options onto an existing switch or adding another admin option) would be to comment out one line of code:
In includes/classes/observers/class.products_with_attributes_stock.php line 1796 in the old version or 1833
Code:
// $productArray[$i]['productsImage'] = (IMAGE_SHOPPING_CART_STATUS == 1 ? zen_image(DIR_WS_IMAGES . $productArray[$i]['attributeImage'][count($productArray[$i]['attributeImage']) - 1], $productArray[$i]['productsName'], IMAGE_SHOPPING_CART_WIDTH, IMAGE_SHOPPING_CART_HEIGHT) : '');