Results 1 to 4 of 4
  1. #1
    Join Date
    May 2014
    Location
    UK
    Posts
    317
    Plugin Contributions
    0

    Default Another Expected Products question

    Hi All.

    A while back I implemented Ajeh's patch in /includes/functions/functions_general.php to prevent books that were described on the site as Coming Soon so that the Add to Cart button didn't display but the customers could read the book synopsis:

    Change: $button_check = $db->Execute("select product_is_call, products_quantity, products_date_available from " . TABLE_PRODUCTS . " where products_id = '" . (int)$product_id . "'");
    // upcoming date not available to purchase
    $upcoming_date_check = time();
    $upcoming_date_check = date('Ymd', $upcoming_date_check);
    $zc_current_date = (int)str_replace('-','',substr($button_check->fields['products_date_available'],0,10));



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


    This works a dream until the Due Date falls behind today's date so with advice from you guys we implemented another patch that prevented from the Due Date being cleared automatically by the system until we could actually find and upload the book ready to Add to Cart. Once we do then we remove the Due Date manually.

    The only other problem we have now is that, whilst the due date is not cleared, the Available on <<DATE>> message gets replaced in the Product Listing with the Add to Cart button .. even though we don't have the book available for downloading. .. So I tried to set about (in these cases) replacing the Available on message with something like Currently Unavailable in place of the Add to Cart button.

    I have looked in the Product Listing file and also the Functions General file around this area:

    // DB#1 BEGIN

    // $button_check = $db->Execute("select product_is_call, products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . (int)$product_id . "'");

    $button_check = $db->Execute("select product_is_call, products_quantity, products_date_available from " . TABLE_PRODUCTS . " where products_id = '" . (int)$product_id . "'");
    // upcoming date not available to purchase
    $upcoming_date_check = time();
    $upcoming_date_check = date('Ymd', $upcoming_date_check);
    $zc_current_date = (int)str_replace('-','',substr($button_check->fields['products_date_available'],0,10));
    // END DB#1

    switch (true) {
    // cannot be added to the cart



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

    case (zen_get_products_allow_add_to_cart($product_id) == 'N'):
    return $additional_link;
    break;
    case ($button_check->fields['product_is_call'] == '1'):
    $return_button = '<a href="' . zen_href_link(FILENAME_CONTACT_US, '', 'SSL') . '">' . TEXT_CALL_FOR_PRICE . '</a>';
    break;
    case ($button_check->fields['products_quantity'] <= 0 and SHOW_PRODUCTS_SOLD_OUT_IMAGE == '1'):
    if ($_GET['main_page'] == zen_get_info_page($product_id)) {
    $return_button = zen_image_button(BUTTON_IMAGE_SOLD_OUT, BUTTON_SOLD_OUT_ALT);
    } else {
    $return_button = zen_image_button(BUTTON_IMAGE_SOLD_OUT_SMALL, BUTTON_SOLD_OUT_SMALL_ALT);
    }
    break;
    default:
    $return_button = $link;
    break;
    }
    if ($return_button != $link and $additional_link != false) {
    return $additional_link . '<br />' . $return_button;
    } else {
    return $return_button;
    }
    }


    to see if I can recode it to recognise when the due date is past but the due date is still on the database. The attempts I have made so far just switches off the Add to Cart button for every product!!!!!!

    Any suggestions would be very helpful please

    Thanks

  2. #2
    Join Date
    Jun 2014
    Location
    Vancouver, Canada
    Posts
    7
    Plugin Contributions
    0

    Default Re: Another Expected Products question

    Could you please clarify the conditions from which you want your new button to appear?

    products_date_available is not null or not empty (is set)
    AND
    products_date_available > today (past)

    Is that correct?

  3. #3
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,755
    Plugin Contributions
    9

    Default Re: Another Expected Products question

    This works a dream until the Due Date falls behind today's date
    For those that fall behind can't you change the due date??
    Zen-Venom Get Bitten

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

    Default Re: Another Expected Products question

    Quote Originally Posted by DigiBooks View Post
    Hi All.

    A while back I implemented Ajeh's patch in /includes/functions/functions_general.php to prevent books that were described on the site as Coming Soon so that the Add to Cart button didn't display but the customers could read the book synopsis:

    Change: $button_check = $db->Execute("select product_is_call, products_quantity, products_date_available from " . TABLE_PRODUCTS . " where products_id = '" . (int)$product_id . "'");
    // upcoming date not available to purchase
    $upcoming_date_check = time();
    $upcoming_date_check = date('Ymd', $upcoming_date_check);
    $zc_current_date = (int)str_replace('-','',substr($button_check->fields['products_date_available'],0,10));



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

    Any suggestions would be very helpful please

    Thanks
    I couldn't get this to work for me on a ZC1.5.4 using PHP5.5, something about a change in how date and time no longer can use string format.

    This is what I did, I use a count down of days to when its available. Once the days hit 0, its becomes available to buy.
    Code:
        $button_check = $db->Execute("select product_is_call, products_quantity, products_date_available from " . TABLE_PRODUCTS . " where products_id = '" . (int)$product_id . "'");
        
        $date_available = $button_check->fields['products_date_available'];
        $productdate = new DateTime($date_available);
        $currentdate = new DateTime();
        $diff=date_diff($productdate, $currentdate);
    //echo $diff->format("%R%a Days");
        switch (true) {
    Then the case:
    Code:
       case ($diff->format("%R%a") < '0' ):
          $return_button = zen_image_button(BUTTON_IMAGE_SOLD_OUT, BUTTON_COMING_SOON_ALT . $diff->format("%R%a Days"));
          break;
    I use css buttons so you may have to make some changes there..
    Dave
    Always forward thinking... Lost my mind!

 

 

Similar Threads

  1. v154 Expected Products
    By DigiBooks in forum Upgrading to 1.5.x
    Replies: 3
    Last Post: 1 Jan 2016, 06:46 PM
  2. Products Expected adds 2034 expected date
    By RobertG in forum General Questions
    Replies: 1
    Last Post: 6 Feb 2011, 01:00 AM
  3. A new? question about Products expected
    By horsetags in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 18 Oct 2010, 11:29 AM
  4. Products Expected Date Question
    By mlm2005 in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 10 Jul 2006, 03:43 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