Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 28
  1. #11
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: products_date_available no longer NULL

    Quote Originally Posted by DigiBooks View Post
    I have come across this line in admin/includes/unctions/general.php:

    return preg_replace('/2037$/', $year, date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, 2037)));

    which comes with the standard installation but I'm not sure why it's there or what it means!
    Quote Originally Posted by mc12345678 View Post
    Allows a date beyond the php cutoff... There were some in the last year that needed to be able to address dates greater than 21 years away. That will take the year 2037 out of the "string" and substitute the applicable date if you understand it correctly...
    More specifically, somewhat working from the right first, create a date formatted as desired, but make it show the year 2037. Then the left part of the statement, replace 2037 with the part in the middle (the actual year that is being "displayed".) It has to do with bits and bytes etc... There are only so large of a number available. The time that is measured is like in milli seconds from some fixed point in "time". Once the largest number is met, it flips back around to the "beginning". So a little trickier is used. Get the parts of the date except the year, but force the year to be what is desired to be displayed by controlling the "solution". :)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  2. #12
    Join Date
    May 2014
    Location
    UK
    Posts
    317
    Plugin Contributions
    0

    Default Re: products_date_available no longer NULL

    Quote Originally Posted by mc12345678 View Post
    So, something is different about the files for the product than product_document... And more than likely that difference may be seen by comparing your files against a vanilla set... There's not many files to compare in that sub-folder...
    So check admin/includes/modules/document_general files and admin/includes/modules/document_product files against a fresh donwload is where I think you're advising me to check?

    I know we haven't changed anything in these sections but it's a starting point :)

  3. #13
    Join Date
    May 2014
    Location
    UK
    Posts
    317
    Plugin Contributions
    0

    Default Re: products_date_available no longer NULL

    Quote Originally Posted by DigiBooks View Post
    So check admin/includes/modules/document_general files and admin/includes/modules/product files against a fresh donwload is where I think you're advising me to check?

    I know we haven't changed anything in these sections but it's a starting point :)
    Sorry I think these are the two folders you meant?

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

    Default Re: products_date_available no longer NULL

    Quote Originally Posted by DigiBooks View Post
    Sorry I think these are the two folders you meant?
    Those last two would be my suggestion though I would start with product, because document_general is working as expected... The other thing, do you have any plugins installed that possibly modify the number of fields in the products table or display "extra" fields on the data input screen?
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #15
    Join Date
    May 2014
    Location
    UK
    Posts
    317
    Plugin Contributions
    0

    Default Re: products_date_available no longer NULL

    Quote Originally Posted by mc12345678 View Post
    Those last two would be my suggestion though I would start with product, because document_general is working as expected... The other thing, do you have any plugins installed that possibly modify the number of fields in the products table or display "extra" fields on the data input screen?
    Thank you for pointing me in the right direction ... with your advice and trusty old Winmerge I found one difference in admin/includes/modules/preview_info.php

    Instead of:

    if ($pInfo->products_date_available > date('Y-m-d')) {

    it read:

    if (true || $pInfo->products_date_available > date('Y-m-d')) {

    Now I remember changing this because we didn't want our site to say books will be available on a specific date but we use it as an EXPECTED date (they don't necessarily publish on time).

    So I reset it to the vanilla setting and all seemed to work. The other thing we don't want is when a book goes past it's due date that it automatically gets set to available (products_date_available set to NULL). So I changed it back and all seemed OK - no zeroes in the field but the past due date was reset to null.

    My conclusion is that I didn't make that (true || ... statement correct in the first instance.

    So digging further I find that the field is reset in admin/includes/modules/update_product.php where it states:

    $products_date_available = (date('Y-m-d') < $products_date_available) ? $products_date_available : 'null';

    so I have replaced this with:

    // Stop removing past due by dates
    // $products_date_available = (date('Y-m-d') < $products_date_available) ? $products_date_available : 'null';
    if ($products_date_available == '') { $products_date_available = 'null'; }
    //


    That works a treat - no more zeroes in the database and past due dates are retained until we manually remove them!

    All I have to do now is find the product info page and stop any past due book from allowing Add To Cart,

    Thank you for your patience and assistance to someone to whom certain PHP statements are actually NOT logical!!!!

  6. #16
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: products_date_available no longer NULL

    Quite welcome. Whatcha mean though about having to find the product info page? The "start" of it is the header in includes/modules/pages/product_info then the chase starts with the applicable tpl file. :)

    Don't forget tools such as the developer's toolkt, the resulting web page source, etc... :)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #17
    Join Date
    May 2014
    Location
    UK
    Posts
    317
    Plugin Contributions
    0

    Default Re: products_date_available no longer NULL

    Quote Originally Posted by mc12345678 View Post
    Quite welcome. Whatcha mean though about having to find the product info page? The "start" of it is the header in includes/modules/pages/product_info then the chase starts with the applicable tpl file. :)

    Don't forget tools such as the developer's toolkt, the resulting web page source, etc... :)
    Found the page I need .. just need to work out where to switch off Add To Cart for past Due Date books.

    Now forgive me if this seems wrong but from what I can gather certain PHP statments are totally REVERSE LOGIC!!!

    OK I was brought up on BASIC, FORTRAN, PERL etc...... so when I see a statement that says:

    case ($zc_current_date > 0 && $zc_current_date >= $upcoming_date_check):
    $return_button = 'AVAILABLE: ' . zen_date_short($button_check->fields['products_date_available']);
    break;

    I interpret that as: Today is not zero and Today is greater than or equal to the Expected date therefore it means that the Expected date has past and should not be showing the product as Available on a particular date.

    then I add the statement:

    case ($zc_current_date > 0 && $zc_current_date <= $upcoming_date_check):
    $return_button = 'OVERDUE: ' . zen_date_short($button_check->fields['products_date_available']);
    break;

    which to me means: Today is not zero but is less than or equal to the Expected date and should not, therefore, show the product as Overdue.

    What am I missing, please?

    To me this is totally (at a logical level) in reverse because it actually works .. but in reverse.

    I'm guessing there is something in PHP that I have yet to grasp?????
    Last edited by DigiBooks; 27 Jan 2016 at 10:51 PM.

  8. #18
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: products_date_available no longer NULL

    So it's not php, but the programmer that put that series of statements together... That code isn't part of the base install as I couldn't find it... The important part in that section is understanding what the value of $upcoming_date_check is based on... The series of case statements will be evaluated from top to bottom, typically whichever is true first is executed...

    The only thing I see about the added code is that basically both are true if they are equal, which means that whichever is first would be the one to "win"...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  9. #19
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: products_date_available no longer NULL

    You know, since this has all started, I've been trying to think of a way to make some of this easier for you. Right now you're process is, apply an expected due date, leave the date alone until the product arrives at which point you have to manually go and clear that date... This is a smidge of an override of the way ZC works as a default... The problem with this override is what if you have say an event or something that you "refuse" to allow being sold until a certain date (publisher prevents release until for example).... Now though you are chomping at the bit and have to manually login at "midnight" to do that mod...

    If though you had an addtional piece of data, say an on/off switch that when off, then all this additional logic applied, but when on (default for example) then the date auto-cleared and the product was "magically" available, it seems like it would make the best of both worlds...

    Part of the reason I suggest this also, is because it could be relatively easy to "add" to the cart. Check this thread out: https://www.zen-cart.com/showthread....inued-products

    The code provided there (though on a todo list for me to take a little further) would offer a "button" that could be clicked from the admin products listing, the effect of being a controller for using the modified code in one state and the default code in the other... Anyways, the todo part is to incorporate it into the product_info sections as well... Rather than just on the products listing page.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  10. #20
    Join Date
    May 2014
    Location
    UK
    Posts
    317
    Plugin Contributions
    0

    Default Re: products_date_available no longer NULL

    Quote Originally Posted by mc12345678 View Post
    You know, since this has all started, I've been trying to think of a way to make some of this easier for you. Right now you're process is, apply an expected due date, leave the date alone until the product arrives at which point you have to manually go and clear that date... This is a smidge of an override of the way ZC works as a default... The problem with this override is what if you have say an event or something that you "refuse" to allow being sold until a certain date (publisher prevents release until for example).... Now though you are chomping at the bit and have to manually login at "midnight" to do that mod...

    If though you had an addtional piece of data, say an on/off switch that when off, then all this additional logic applied, but when on (default for example) then the date auto-cleared and the product was "magically" available, it seems like it would make the best of both worlds...

    Part of the reason I suggest this also, is because it could be relatively easy to "add" to the cart. Check this thread out: https://www.zen-cart.com/showthread....inued-products

    The code provided there (though on a todo list for me to take a little further) would offer a "button" that could be clicked from the admin products listing, the effect of being a controller for using the modified code in one state and the default code in the other... Anyways, the todo part is to incorporate it into the product_info sections as well... Rather than just on the products listing page.

    Thanks on both points .. firstly a former programmer seems to have added this reverse logic (which works) and I'm still trying to get my head around !!!!!

    On your second point a switch would be the answer (I will check out the link you sent shortly).

    I guess we are operating slightly differently to the norm so just to clarify:

    Book 1 and Book 2 in THE TRILOGY are available, loaded on site and downloadable by subscribed members.

    Book 3 is still being written and will be published in 9 months time .. but we have a description and often a book cover that we can load as 'teaser' with an Expected publication date of, say 1st September 2016. Book fails to publish by that date so under normal Zen-Cart rules it disappears from Expected Books because the date is set back to Null. As users we suddenly lose the teaser .. as Admins we no longer get reminded to seek Book 3 out - hence the reason we need to see it as Overdue.

    When Book 3 is eventually published us Admins can load it for the members and remove the Expected Date and it all goes live.

    Nothing can magically appear as it has to be manually made live in the catalog as a downloadable file.

    Hopefully our simplistic method helps with what we're trying to achieve.

    And thanks again :)

 

 
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. Replies: 7
    Last Post: 4 May 2016, 01:59 AM
  2. Get products_date_available
    By mprough in forum General Questions
    Replies: 4
    Last Post: 10 Sep 2014, 01:40 PM
  3. Replies: 3
    Last Post: 24 Sep 2012, 07:08 PM
  4. Replies: 11
    Last Post: 15 Jan 2010, 04:44 PM
  5. Adding products_date_available field in product_listing.php
    By Camel in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 29 Nov 2006, 08:41 AM

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