
Originally Posted by
DigiBooks
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..