Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1
    Join Date
    Oct 2019
    Location
    UK
    Posts
    17
    Plugin Contributions
    0

    Default Problem with decimal places in Sort Order field

    Hi

    I need to be able to store numbers with decimal places in the Sort Order field for products (this will also be the case with the V1.5.6 system we are currently modifying).

    I have ensured that the field in the database can store numbers to decimal places.

    Our situation is that a book series can have books that rung (for instance): 1, 1.5, 1.75, 2 etc,

    Please can some one advise how I may achieve this.

    At the moment if we enter 1.5 then it is stored as 1.00

    Thanks in advance

  2. #2
    Join Date
    Jul 2012
    Posts
    14,471
    Plugin Contributions
    17

    Default Re: Problem with decimal places in Sort Order field

    Doesn't directly answer the question, but why not use say multiples of 100 or some value that will ensure all the decimals are addressed?
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...
    Upgraded to Zen Cart V1.5.3 from V1.5.1 from V1.5.0 from V1.3.9h

  3. #3
    Join Date
    Oct 2019
    Location
    UK
    Posts
    17
    Plugin Contributions
    0

    Default Re: Problem with decimal places in Sort Order field

    I did have this working once before our server crashed so I'm guessing it is the same route as adding product prices? Just cannot get my head round it at the moment!!!!

  4. #4
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    6,634
    Plugin Contributions
    260

    Default Re: Problem with decimal places in Sort Order field

    The sort order field is an integer field. Even if you modified the database to make them decimal, the software still converts them to integer before storing them. You're way better off to follow @MC's advice and multiply by 100 so you can use integer values.
    That Software Guy, Plugin Moderator. Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Contributions: Quantity Discounts, Better Together, SMS on Sale, Gift Wrap at Checkout, and more.

  5. #5
    Join Date
    Oct 2019
    Location
    UK
    Posts
    17
    Plugin Contributions
    0

    Default Re: Problem with decimal places in Sort Order field

    Quote Originally Posted by swguy View Post
    The sort order field is an integer field. Even if you modified the database to make them decimal, the software still converts them to integer before storing them. You're way better off to follow @MC's advice and multiply by 100 so you can use integer values.
    I have changed the sort order field to decimal (15,2)

  6. #6
    Join Date
    Oct 2019
    Location
    UK
    Posts
    17
    Plugin Contributions
    0

    Default Re: Problem with decimal places in Sort Order field

    How do the product prices get stored as decimal places please?

  7. #7
    Join Date
    Jul 2012
    Posts
    14,471
    Plugin Contributions
    17

    Default Re: Problem with decimal places in Sort Order field

    Really trying to help here. Not just to get through this one time "fix" but to make things easier for the future.

    Note that if the existing convention of applying sort order as an integer was used, then wouldn't be trying to find the code change to support a decimal value. As far as existing values, they could all be updated to such a new numbering scheme by the following sql:
    Code:
    UPDATE products SET products_sort_order = products_sort_order * 100;
    This would retain the existing sort order results and assuming that all previous entries had at most 2 decimal places, then they would have become integers.

    Anything "uniquely" written to handle the sort order can be modified to divide by the same 100. Considering that code is outside the normal Zen Cart code, in future upgrades, it could be carried over as necessary to retain operation and the core ZC code and database setup need not be updated/modified.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...
    Upgraded to Zen Cart V1.5.3 from V1.5.1 from V1.5.0 from V1.3.9h

  8. #8
    Join Date
    Oct 2019
    Location
    UK
    Posts
    17
    Plugin Contributions
    0

    Default Re: Problem with decimal places in Sort Order field

    Quote Originally Posted by mc12345678 View Post
    Really trying to help here. Not just to get through this one time "fix" but to make things easier for the future.

    Note that if the existing convention of applying sort order as an integer was used, then wouldn't be trying to find the code change to support a decimal value. As far as existing values, they could all be updated to such a new numbering scheme by the following sql:
    Code:
    UPDATE products SET products_sort_order = products_sort_order * 100;
    This would retain the existing sort order results and assuming that all previous entries had at most 2 decimal places, then they would have become integers.

    Anything "uniquely" written to handle the sort order can be modified to divide by the same 100. Considering that code is outside the normal Zen Cart code, in future upgrades, it could be carried over as necessary to retain operation and the core ZC code and database setup need not be updated/modified.
    OK thanks .. I will try that out with v.1.5.6. Because we managed it somehow previously we do have sot orders stored as 2.50 etc so this change may screw a little with what we have already done but can be fixed as the point 5 books are few and far between

  9. #9
    Join Date
    Oct 2019
    Location
    UK
    Posts
    17
    Plugin Contributions
    0

    Default Re: Problem with decimal places in Sort Order field

    I did try to replicate the way that prices are handled in update_product.php but no matter what you enter returns as 656.00 !!!!!

  10. #10
    Join Date
    Oct 2019
    Location
    UK
    Posts
    17
    Plugin Contributions
    0

    customer issue Re: Problem with decimal places in Sort Order field

    Quote Originally Posted by OwenB View Post
    I did try to replicate the way that prices are handled in update_product.php but no matter what you enter returns as 656.00 !!!!!
    I have performed the * 100 update to the database and reset it to Integer but when I edit a record it saves as '0'. Obviously something wrong now in the Admin console????

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Currency Setting of Decimal Places vs pricing to 5 decimal places?
    By GoldBuckle in forum Customization from the Admin
    Replies: 0
    Last Post: 20 Aug 2013, 05:16 PM
  2. v150 Confirmation Email Order Total displaying three decimal places
    By PMguy2004 in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 14 Sep 2012, 07:50 PM
  3. Decimal Places
    By fredmccay in forum Basic Configuration
    Replies: 0
    Last Post: 27 Jan 2011, 03:19 AM
  4. Decimal Places
    By Davx in forum Customization from the Admin
    Replies: 2
    Last Post: 20 Apr 2010, 04:36 PM

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