Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,492
    Plugin Contributions
    88

    Default Setting up a product with a single, required file-upload attribute

    zc156b, created a simple product with a maximum quantity of 1 and added the demo products' Logo Back file-upload attribute as the product's single, required attribute.

    Unfortunately, when the product is added to the order the requirement of that file-upload attribute isn't enforced and the shopping_cart class throws a couple of warnings:
    Code:
    [03-Jun-2019 13:35:20 America/New_York] Request URI: /zc156posm/index.php?main_page=product_info&cPath=83&products_id=228&number_of_uploads=1&action=add_product, IP address: ::1
    #1  shoppingCart->actionAddProduct() called at [C:\xampp\htdocs\zc156posm\includes\main_cart_actions.php:43]
    #2  require(C:\xampp\htdocs\zc156posm\includes\main_cart_actions.php) called at [C:\xampp\htdocs\zc156posm\includes\init_includes\init_cart_handler.php:44]
    #3  require(C:\xampp\htdocs\zc156posm\includes\init_includes\init_cart_handler.php) called at [C:\xampp\htdocs\zc156posm\includes\autoload_func.php:48]
    #4  require(C:\xampp\htdocs\zc156posm\includes\autoload_func.php) called at [C:\xampp\htdocs\zc156posm\includes\application_top.php:170]
    #5  require(C:\xampp\htdocs\zc156posm\includes\application_top.php) called at [C:\xampp\htdocs\zc156posm\index.php:26]
    --> PHP Warning: Illegal string offset 'txt_7' in C:\xampp\htdocs\zc156posm\includes\classes\shopping_cart.php on line 1991.
    
    [03-Jun-2019 13:35:20 America/New_York] Request URI: /zc156posm/index.php?main_page=product_info&cPath=83&products_id=228&number_of_uploads=1&action=add_product, IP address: ::1
    #1  shoppingCart->actionAddProduct() called at [C:\xampp\htdocs\zc156posm\includes\main_cart_actions.php:43]
    #2  require(C:\xampp\htdocs\zc156posm\includes\main_cart_actions.php) called at [C:\xampp\htdocs\zc156posm\includes\init_includes\init_cart_handler.php:44]
    #3  require(C:\xampp\htdocs\zc156posm\includes\init_includes\init_cart_handler.php) called at [C:\xampp\htdocs\zc156posm\includes\autoload_func.php:48]
    #4  require(C:\xampp\htdocs\zc156posm\includes\autoload_func.php) called at [C:\xampp\htdocs\zc156posm\includes\application_top.php:170]
    #5  require(C:\xampp\htdocs\zc156posm\includes\application_top.php) called at [C:\xampp\htdocs\zc156posm\index.php:26]
    --> PHP Warning: Cannot assign an empty string to a string offset in C:\xampp\htdocs\zc156posm\includes\classes\shopping_cart.php on line 1991.
    Is there something 'special' that needs to be included in that product's configuration to get that attribute to be required?

    Noting that this issue has been present as far back as the zc155 series, if not further.
    Last edited by lat9; 3 Jun 2019 at 07:20 PM. Reason: Added note

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,492
    Plugin Contributions
    88

    Default Re: Setting up a product with a single, required file-upload attribute

    I'll note also that with a fresh zc156b installation with demo products, if I mark the Logo Front file attribute as required for the A Bug's Life "Multi Pak" Special 2003 Collectors Edition product, an add-to-cart action without that required upload successfully adds to the cart.

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

    Default Re: Setting up a product with a single, required file-upload attribute

    Not sure why I feel like this is a "loaded" question as in, the reasoning is understood but development hasn't been done to make it work, but there are a few things to note at least as relates to the attributes.

    The current definition of the required attribute in the attributes controller in ZC 1.5.6b is that it is for text fields.

    Within the attributes controller, the option name will show [file] adjacent to the option name, but the option value reflects TEXT/FILE which could be misleading, but even more so it seems that after adding the option name [FILE] that the option name appears as TEXT which is not entirely true about the attribute. Yes, a text field is generated on the product info page, but it isn't really one that is treated as a text input for downstream processing "per se". There is content "reposted" when the product is visited back from the shopping cart which is used to match/confirm that the product is the same if no new upload is provided, but it isn't used in relation to verifying that *something* has been uploaded. (This area appears to need a little work so that the option name will show as a file type attribute rather than a text type attribute.)

    The verification of attributes being uploaded is performed in the actionAddProduct method of the shopping_cart class which inspects the items provided via $_POST and specifically that have an id array key. While the input file field on the product information page is identified as that of the id array, because it is a file and not some other input type, the information related to it does not appear to be provided in the posted information, but is provided in the $_FILES related information if an upload has occurred, otherwise the pre-existing information is attempted. The presence of an uploaded (or matching entry) file can be detected; however, is not currently treated/performed. As a result of that absence, that is why the attributes controller can "safely" state required for a text field.

    Also, as a result of stricter processing, it does appear that there are some aspects of this area that need some tending.



    It appears then that in reference to the original question of "is there something special in the product configuration" to address this? My assessment of the code as provided is that no, there is not some specific configuration that would support the practice of requiring a file upload. Instead, code needs to be changed and/or added to support that option/capability.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  4. #4
    Join Date
    Jul 2012
    Posts
    16,734
    Plugin Contributions
    17

    Default Re: Setting up a product with a single, required file-upload attribute

    Initiated Issue on this topic: https://github.com/zencart/zencart/issues/2407
    and potential solution: https://github.com/zencart/zencart/pull/2408

    There is one "caveat" identified that I haven't figured out how to deal with/address. That being, if a product has two or more required files and the customer attempts to upload only one of the files as part of submission, then the one file "shows" as successfully uploading the other as not being uploaded and when returning to the product information page, no files are shown as being uploaded... It would seem that the ideal solution would be for the successfully uploaded file to remain associated with the product and the not uploaded file to still require entry; however, that seems like it would require a little more core code modification to support... At least it requires more investigation to try to accomplish.

    Some of the "review" is to try to cycle through all uploaded files before identifying a successful upload so that at least if *nothing* is done with the successful file that it doesn't make it to the server, whereas if the file is successfully stored, that its association is carried back to the product information page even though the shopping cart doesn't have that product's attributes populated (this I believe is also part of the issue, though in my testing I did not review/validate the change/difference of other attribute settings).

    Something else that I just realized is that in includes/modules/attributes.php probably need to add some sort of upfront customer indication that the associated file attribute is required...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,696
    Plugin Contributions
    123

    Default Re: Setting up a product with a single, required file-upload attribute

    Quote Originally Posted by lat9 View Post
    zc156b, created a simple product with a maximum quantity of 1 and added the demo products' Logo Back file-upload attribute as the product's single, required attribute.

    Unfortunately, when the product is added to the order the requirement of that file-upload attribute isn't enforced and the shopping_cart class throws a couple of warnings...
    I saw this last night in transit and was thinking "does Zen Cart even have a required file attribute?" Then I got up this morning and saw @mc had added it. LOL! Life comes at you fast.
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  6. #6
    Join Date
    Dec 2007
    Location
    Payson, AZ
    Posts
    1,076
    Plugin Contributions
    15

    Default Re: Setting up a product with a single, required file-upload attribute

    If I remember right, some time back I used a plugin to get the file upload attribute to be required...
    https://www.zen-cart.com/downloads.php?do=file&id=1133
    Dave
    Always forward thinking... Lost my mind!

 

 

Similar Threads

  1. v155 Adding a custum attribute with required customer upload.
    By anklebiterwoodworks in forum Setting Up Categories, Products, Attributes
    Replies: 8
    Last Post: 7 Jan 2018, 04:35 PM
  2. v151 File Upload required addon problem
    By chriscctx in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 4 Mar 2014, 02:45 PM
  3. File Upload Required addon [Support Thread]
    By 1100101 in forum All Other Contributions/Addons
    Replies: 21
    Last Post: 10 Dec 2011, 03:00 AM
  4. Automatically setting an attribute with a single value?
    By jack7890 in forum General Questions
    Replies: 0
    Last Post: 20 Apr 2009, 12:15 AM
  5. Single Product with Multiple Quantities of the Same Attribute
    By jalaco in forum Setting Up Categories, Products, Attributes
    Replies: 5
    Last Post: 24 Apr 2008, 04:46 AM

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