Zen Cart Logo
Forums / Managing Customers and Orders / Resetting Download Links

Resetting Download Links

Locked

Views: 1,479

Results 1 to 9 of 9
This thread is locked. New replies are disabled.
5 Nov 2008, 9:50 PM
#1
lissae avatar

lissae

Totally Zenned

Join Date:
Oct 2007
Location:
Australia
Posts:
814
Plugin Contributions:
0

Resetting Download Links

I need some help with something and if the answer is already here somewhere I cannot find it LOL

When I need to reset a download link...if I click the green button to reactivate it, it gives 17 days....if I use the drop down to change the order status to Update it gives 41 days...how can I change both those values to only allow resetting to 7 days?

6 Nov 2008, 4:08 AM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Resetting Download Links

Actually there is a little bug in the code that I am working on ...

It should be taking the number of days of the original attribute and changing it based on the order date to be the same thing ...

Right now, it is taking the default days for downloads and using that to change the date based on the original orders date ...

If you look in the orders.php file in the /admin you will see where it manages the download:

// reset single download to on

6 Nov 2008, 4:22 AM
#3
lissae avatar

lissae

Totally Zenned

Join Date:
Oct 2007
Location:
Australia
Posts:
814
Plugin Contributions:
0

Re: Resetting Download Links

I found that section....I have no idea what to change though to change it specifically to another 7 days LOL if it can be changed to that?

      // reset single download to on
        if ($_GET['download_reset_on'] > 0) {
          // adjust download_maxdays based on current date
          $check_status = $db->Execute("select customers_name, customers_email_address, orders_status,
                                      date_purchased from " . TABLE_ORDERS . "
                                      where orders_id = '" . $_GET['oID'] . "'");
          $zc_max_days = date_diff($check_status->fields['date_purchased'], date('Y-m-d H:i:s', time())) + DOWNLOAD_MAX_DAYS;

          $update_downloads_query = "update " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " set download_maxdays='" . $zc_max_days . "', download_count='" . DOWNLOAD_MAX_COUNT . "' where orders_id='" . $_GET['oID'] . "' and orders_products_download_id='" . $_GET['download_reset_on'] . "'";
          $db->Execute($update_downloads_query);
          unset($_GET['download_reset_on']);

          $messageStack->add_session(SUCCESS_ORDER_UPDATED_DOWNLOAD_ON, 'success');
          zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL'));
        }
```Do I just change this bit:

```php
$zc_max_days = date_diff($check_status->fields['date_purchased'], date('Y-m-d H:i:s', time())) + DOWNLOAD_MAX_DAYS;
```to this:

```php
$zc_max_days = 7;

OR

$zc_max_days = DOWNLOAD_MAX_DAYS;
```Or will I be screwing it all up? LOLOL






6 Nov 2008, 5:52 AM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Resetting Download Links

The $zc_max_days is how many days to set the download_maxdays so that downloads can continue ...

The calculation is taking the date_purchased to the current date and resetting the number of days to what it would take to allow the new number of days to give, for example, 7 days if the DOWNLOAD_MAX_DAYS is set to 7 ...

This is set on the Configuration ... Attribute Settings ...

Download Expiration (Number of Days)
Set number of days before the download link expires. 0 means no limit.

This means if the order was placed on October 1st and the download was good for 7 days ... then you reset it on the 15th to give 7 days, the number of days would be changed to 22 days so that from the 15th there were 7 days left to download ...

6 Nov 2008, 6:19 AM
#5
lissae avatar

lissae

Totally Zenned

Join Date:
Oct 2007
Location:
Australia
Posts:
814
Plugin Contributions:
0

Re: Resetting Download Links

I understand that...or I think I do LOL

I tried changing it to $zc_max_days = DOWNLOAD_MAX_DAYS; and while that did actually work to reset it to another 7 days only....the yellow button failed to become green and any attempt to click on it after just told me the it had been reset, wouldn't disable it back again lol so I don't know where to go from here except to wait until my head and eyes might be fresher and try again LOL

6 Nov 2008, 3:37 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Resetting Download Links

The button is more like a toggle ...

Green for Available for Download
Yellow for disabled
Red for filename cannot be downloaded

If you click the Green button you cannot download and it will be marked Yellow ...

If you click the Yellow button you can download and it will be marked as Green ...

If you see the Red button, then you need to check the filename on the Attribute and make sure that it is on the server ...

Keep in mind, adding 7 days to an old order is not enough ...

The reason it is setup with the original calculation is to give the number of extra days needed from the Order Date to allow for a new "7" days or whatever setting there is ...

So if I make an Order today ... and get it to process ... then go into phpMyAdmin and change the Order Date to October 6th, the Download is unavailable and I will see Yellow on the Order ...

If I click the Yellow button it will change the settings on the Attribute to be Green and I will now see 38 days ... as October 6th to 7 days from now is 38 days ...

If you change the formula to just be 7 days, then it is still expired based on the Order date ...

I think the original code is correct and it is just the display of the number of days confusing you as you are not taking into account how many days are needed from Order Date to give the New 7 days for the Download ...

6 Nov 2008, 11:04 PM
#7
lissae avatar

lissae

Totally Zenned

Join Date:
Oct 2007
Location:
Australia
Posts:
814
Plugin Contributions:
0

Re: Resetting Download Links

ahhhh I understand now thanx LOL sometimes I need to have it banged into my head :bangin: LOL!

20 Apr 2009, 9:59 PM
#8
tjmuse avatar

tjmuse

New Zenner

Join Date:
Mar 2009
Posts:
11
Plugin Contributions:
0

Re: Resetting Download Links

is there an easy way to reset the downloads without having to toggle each and every one of them. Because our store is fully digital products an order could have 100 download files and it would take forever to reset everything?

20 Apr 2009, 10:08 PM
#9
lissae avatar

lissae

Totally Zenned

Join Date:
Oct 2007
Location:
Australia
Posts:
814
Plugin Contributions:
0

Re: Resetting Download Links

Yep there is, if you scroll down to the bottom underneath the download listing, there's a drop down box next to Status: change that to Updated and click the Update button...unless you remove the tick in the box next to notify customer, this will also notify your customer that the downloads have been reset and the order updated.

I also changed mine to say Reset instead of Updated in Admin - Localization - Orders Status since we also only do downloadable products :)