Zen Follower
- Join Date:
- May 2014
- Location:
- UK
- Posts:
- 317
- Plugin Contributions:
- 0
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