Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Join Date
    Sep 2014
    Location
    Indiana
    Posts
    91
    Plugin Contributions
    0

    Default Attribute adding long code to product id

    We are experimenting a bit with product attributes (information only for now) and having an issue that i am unable to find addressed this in forum. I apologize if i'm repeating a topic.

    The order confirmation email has a long attribute code (looks like a GUID) added to the item ID. Not only is it confusing to the reader, but it also triggers an error because the product ID value is too long for the field.

    Click image for larger version. 

Name:	attribute_email_image.jpg 
Views:	182 
Size:	65.7 KB 
ID:	20124
    The yellow highlighted is the actual item Id and is appropriate shown. The long code highlighted in blue is unwanted. The second item on the order does not have any attributes assigned.

    I have looked for config settings to turn this off; and i have looked into the code to try to rem out the line. Two strikes so far.

    Is this presentation normal? Is there a way i can get rid of the code?

    Thanks,
    Last edited by apollowilcox; 18 Oct 2022 at 04:46 PM.

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

    Default Re: Attribute adding long code to product id

    In 1.5.7d, includes/classes/order.php line 1014, that line is supposed to show ordered quantity 'x' the product name.
    See if you have made changes to that file.
    That Software Guy. My Store: Zen Cart Support
    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.

  3. #3
    Join Date
    Sep 2014
    Location
    Indiana
    Posts
    91
    Plugin Contributions
    0

    Default Re: Attribute adding long code to product id

    Thanks swguy. Yes, we have made three minor touches to that file. And i have stared at that file long and hard trying to see if its the source of this current issue. I sense you are confirming that this is the right file, so maybe i'll upload a vanilla version, and see if it addresses this. Seem logical? I'm open to any ideas. Thanks much.

  4. #4
    Join Date
    Sep 2014
    Location
    Indiana
    Posts
    91
    Plugin Contributions
    0

    Default Re: Attribute adding long code to product id

    Specifically, one change we made was to remove the 'model' from our email as the model is a meaningless value (to our customer) in our setup. Instead, we have it list the Product ID and then the name.
    Vanilla Line 1021 from includes/classes/order.php is:
    Code:
     '<td class="product-details" align="right" valign="top" width="30">' . $this->products[$i]['qty'] . '&nbsp;x</td>' . "\n" .
          '<td class="product-details" valign="top">' . nl2br($this->products[$i]['name']) . ($this->products[$i]['model'] != '' ? ' (' . nl2br($this->products[$i]['model']) . ') ' : '') . "\n" .
          '<nobr>' .
          '<small><em> '. nl2br($this->products_ordered_attributes) .'</em></small>' .
          '</nobr>' .
          '</td>' . "\n" .
    And our code is:
    Code:
    '<td class="product-details" align="right" valign="top" width="30">' . $this->products[$i]['qty'] . '&nbsp;x</td>' . "\n" .
          '<td class="product-details" valign="top">' . '<strong>' . nl2br($this->products[$i]['id']) . '</strong>' . ($this->products[$i]['name'] != '' ? ' (' . nl2br($this->products[$i]['name']) . ') ' : '') . "\n" .
          '<nobr>' .
          '<em> '. nl2br($this->products_ordered_attributes) .'</em>' .		//MMW: removed <small> tags.
          '</nobr>' .
          '</td>' . "\n" .
    Its like this additional attribute code is being somehow attached to the ID field, since both are being presented as bold (<strong>). As mentioned, unless something here gets your attention as being wrong, i'll copy the vanilla and see what happens. Thanks.

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

    Default Re: Attribute adding long code to product id

    Then just change

    $this->products[$i]['id']
    to
    (int)$this->products[$i]['id']

    Be sure to hit both plain text and HTML.
    This is lines 1014 and 1021 in a vanilla copy of includes/classes/order.php
    That Software Guy. My Store: Zen Cart Support
    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
    Sep 2014
    Location
    Indiana
    Posts
    91
    Plugin Contributions
    0

    Default Re: Attribute adding long code to product id

    Quote Originally Posted by swguy View Post
    Then just change

    $this->products[$i]['id']
    to
    (int)$this->products[$i]['id']

    Be sure to hit both plain text and HTML.
    This is lines 1014 and 1021 in a vanilla copy of includes/classes/order.php
    Yeah, that's an efficient solution. Much appreciated!

  7. #7
    Join Date
    Sep 2014
    Location
    Indiana
    Posts
    91
    Plugin Contributions
    0

    Default Re: Attribute adding long code to product id

    Follow up questions on same issue: We are using a few options/values/attributes and with v1.5.8a, when adding a product (with an option attached) to a shopping cart, we get an error:
    pzen_addpro_cart() called at [/..../store/pzen_ajx_cart.php:46]
    --> PHP Fatal error: 1406ata too long for column 'products_id' at row 1 :: INSERT INTO zen_customers_basket
    (customers_id, products_id, customers_basket_quantity,
    customers_basket_date_added)
    VALUES (19517, '88348:f5a65b2fbfe9247f559dd4c029afff79', '4', '20230414') ==> (as called by) /..../store/includes/classes/shopping_cart.php on line 294 <== in
    It seems (to my php-handicapped eye) that the long option-addon code after the product_id does not fit into the products_id field of the zen customer basket.

    Leveraging the elegant solution offered above in the thread, I tried tweaking \includes\classes\shopping_cart.php line 292 to add (int)$product_id to the zen_customer_basket and that worked. And a similar tweak at line 580 to find and REMOVE the item from the basket.

    What i cannot get to work is a CHANGE of quantity to an (option-assigned) product in the cart/ basket. The shopping-cart page freezes. Adding (int) to line 407 in the update_quantity failed to work.

    Is there an easier way around all of this? Am i on the right track?

    Thank you.

  8. #8
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,508
    Plugin Contributions
    88

    Default Re: Attribute adding long code to product id

    Quote Originally Posted by apollowilcox View Post
    Follow up questions on same issue: We are using a few options/values/attributes and with v1.5.8a, when adding a product (with an option attached) to a shopping cart, we get an error:


    It seems (to my php-handicapped eye) that the long option-addon code after the product_id does not fit into the products_id field of the zen customer basket.

    Leveraging the elegant solution offered above in the thread, I tried tweaking \includes\classes\shopping_cart.php line 292 to add (int)$product_id to the zen_customer_basket and that worked. And a similar tweak at line 580 to find and REMOVE the item from the basket.

    What i cannot get to work is a CHANGE of quantity to an (option-assigned) product in the cart/ basket. The shopping-cart page freezes. Adding (int) to line 407 in the update_quantity failed to work.

    Is there an easier way around all of this? Am i on the right track?

    Thank you.
    The {zen_}customers_basket:roducts_id field is, in a standard Zen Cart distribution, defined as a tinytext field. That field type can hold up to 255 characters and the uprid (i.e. for an attributed product) you'd posted is only 39 characters.

    Don't add that (int) cast, since that will result in the truncation/loss of the attributes' reference. Check, instead, that the database field hasn't been mangled by that Themeforest template.

  9. #9
    Join Date
    Sep 2014
    Location
    Indiana
    Posts
    91
    Plugin Contributions
    0

    Default Re: Attribute adding long code to product id

    Quote Originally Posted by lat9 View Post
    The {zen_}customers_basket:roducts_id field is, in a standard Zen Cart distribution, defined as a tinytext field. That field type can hold up to 255 characters and the uprid (i.e. for an attributed product) you'd posted is only 39 characters.

    Don't add that (int) cast, since that will result in the truncation/loss of the attributes' reference. Check, instead, that the database field hasn't been mangled by that Themeforest template.
    Thanks much for this info. You were exactly right. The product_id field type was incorrect / non-vanilla, and it is unclear how / why it was changed.

    As I prepare to change customers_basket.products_id to type TinyText, where might I find all the original vanilla settings for this field so that all values for this field end up as correct/ vanilla? I can easily change it to tinytext, but it is also asking for length, collation, etc. Trying to do this exactly right...

    Click image for larger version. 

Name:	customers_basket field change.jpg 
Views:	18 
Size:	24.2 KB 
ID:	20264

    Thank you so much for your help.
    Last edited by apollowilcox; 18 Apr 2023 at 02:43 PM.

  10. #10
    Join Date
    Sep 2014
    Location
    Indiana
    Posts
    91
    Plugin Contributions
    0

    Default Re: Attribute adding long code to product id

    Also, will i need to change this key?

    Click image for larger version. 

Name:	customers_basket key records.jpg 
Views:	25 
Size:	17.8 KB 
ID:	20265

    Thank you much.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. deny Coupon Code by Product Attribute?
    By bobcnj in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 0
    Last Post: 24 Jan 2011, 03:21 AM
  2. Adding a product code to each indivdual ATTRIBUTE?
    By GRSC1 in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 18 May 2010, 05:27 PM
  3. Long (very long!) product names break Tell A Friend page + FIX
    By Ryk in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 24 Feb 2007, 02:10 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