Forums / General Questions / Another Expected Products question

Another Expected Products question

Views: 470

Results 1 to 4 of 4
25 Jan 2016, 9:27 PM
#1
digibooks avatar

digibooks

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

3 Feb 2016, 6:15 AM
#2
t1000 avatar

t1000

New Zenner

Join Date:
Jun 2014
Location:
Vancouver, Canada
Posts:
7
Plugin Contributions:
0

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 Feb 2016, 6:34 AM
#3
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

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 Feb 2016, 6:26 AM
#4
davewest avatar

davewest

Totally Zenned

Join Date:
Dec 2007
Location:
Payson, AZ
Posts:
1,075
Plugin Contributions:
7

Re: Another Expected Products question

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.

    $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:

   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!