Jump to content

Digital Downloads in 'My Account'


Big Spender

Recommended Posts

I am attempting to see the output of the downloads section in the users account section.  I have created a test product, assigned a PDF to the product, ensured it is in stock.  I have gone through and ordered the product, I have done this via 'Print Order Form'.

 

Once done I then go into the admin area and change to 'Processing' and then 'Order Complete'.  In the downloads section of my account it then states 'This download is no longer available.'  If I look at the order details in the admin area it just states [Reset Download Link]... I never received an email but this maybe just an issue with my local setup.

 

So - what am I supposed to see in the 'Your Digital Downloads' section of the my account pages? and why am I seeing 'This download is no longer available.' ...?

 

Thanks in advance.

 

PS it's 5.2.12

Link to comment
Share on other sites

Please let us know what values you have in Store Settings, Stock tab, Digital Products section.

 

This may be a case where, because the POF gateway is being used, CubeCart is not recording the item in the CubeCart_downloads database table.

 

I don't think that's the source of the problem.

 

Please use a database utility such as phpMyAdmin to look at CubeCart_downloads directly.

 

"I look at the order details in the admin area it just states [Reset Download Link]"

 

Hopefully, there is also listed the name of the digital product and the prices?

Link to comment
Share on other sites

I've just given this a retry using a different gateway with the same result.

 

I thought it might have been something to do with the expiry settings in Stock Settings in the General Settings but no.

 

Do you know how it's supposed to work by default? Does anyone here use the downloads option?

Link to comment
Share on other sites

I have a suspicion this is related to the database class in that, when CubeCart inserts a record in the database, the insert class can return what's called the insert_id of the just inserted record. CubeCart also has a separate database function that will return the last insert_id if, for some reason, it could not be obtained immediately.

 

I have experienced less than consistent behavior using PHP's mysql group of functions of connecting to the database. Your hosting provider may be using PHP's mysqli group of functions. I have not really examined the mysqli code extensively.

 

In admin, PHP Info, scroll to the mysql section. Do you have mysql or mysqli?

Link to comment
Share on other sites

Ok, it appears you have both mysql and mysqli extensions enabled. That's not a problem. Based on the one section showing one active link, I assume CubeCart is using the mysqli extension.

 

As an experiment, in the PHP.INI file, comment out the mysqli extension and restart Apache (if using PHP as an apache module - otherwise restart the PHP daemon). This will force CubeCart to use the mysql group of functions. Then place another digital order. In the CubeCart_downloads table, verify the value of the 'order_inv_id' is not zero.

 

I will look at CubeCart's mysqli file and see if insert_id may be causing some issues.

Link to comment
Share on other sites

Tried this, same result, the downloads table now doesn't add a new row. I also have this error on every page including the admin area: -

 

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:xampphtdocsCubeCart-5.2.12classesdbmysql.class.php on line 24

Link to comment
Share on other sites

I assume you have now commented out the mysql extension and un-commented the mysqli extension in PHP.INI.

 

To trick the system...

 

Look in CubeCart_order_inventory and find all the records for that digital item (product_id 36). There should be at least a record for orders 140914-113038-9897 and 140918-185411-3822. Take note of each of those records' respective 'id' value.

 

Now look in CubeCart_downloads. Match the cart_order_id and edit the order_inv_id with the respective id noted earlier.

 

Test the downloads page in the customer account section.

Link to comment
Share on other sites

I've checked code differences between CC5212 and CC5213. Nothing suggests why the order_inv_id value would be zero.

 

I will now configure my system to use mysqli and perform the same tests.

 

The table CubeCart_order_inv is populated at the same time the customer is shown the gateway selection page. (That is, in the end, there is no difference in which gateway is chosen to make payment.)

Link to comment
Share on other sites

Okay - I can now see that section in 'My Account' (I can see the expired downloads) I can't seem to get this to display me a download that isn't expired however.

 

I did notice when trying to amend the data you suggested that the cubecart_downloads table states: 

 

"Current selection does not contain a unique column. Grid edit, checkbox, Edit, Copy and Delete features are not available."

 

So I had to make the digital_id a primary key to open up the order_inv_id editing.

 

I attempted to change the expire number which was 1410730312 to 0 or 999999 but still shows expired.

Link to comment
Share on other sites

I attempted the reset link but they remained expired.

 

Please let us know the values you have for admin, Store Settings, Stock tab, Digital Products section.

 

I just verified that, when using the mysqli group of functions, CubeCart makes the database entry in the downloads table correctly.

Link to comment
Share on other sites

I see code that, when CubeCart sends the email to the customer with the download link, the respective download table record is updated so that the customer has at least 30 minutes to get the download.

 

I will report this as a bug, because if the admin setting is left blank, the expiration is presumed disabled -- meaning, to me, the download will not expire.

 

In /classes/order.class.php, near line 636 in the _digitalDelivery() function, make this edit:

Was:
$validity_time = ($GLOBALS['config']->get('config', 'download_expire') > 1800) ? $GLOBALS['config']->get('config', 'download_expire') : 1800;
$expire = time() + $validity_time;
 
Now:
if (!$GLOBALS['config']->isEmpty('config', 'download_expire')) {
  $validity_time = ($GLOBALS['config']->get('config', 'download_expire') > 1800) ? $GLOBALS['config']->get('config', 'download_expire') : 1800;
  $expire = time() + $validity_time;
} else {
  $expire = 0;
}

Then, a few statements down:

Was:
'expire'    => formatTime($expire, false, true),
 
Now:
'expire'    => ($expire > 0) ? formatTime($expire, false, true) : $GLOBALS['language']->common['never'] ,

However, this does not answer why records in your table show zero for the order_inv_id value. A zero for order_inv_id does explain why you didn't get an email with the download link.

Link to comment
Share on other sites

  • 2 weeks later...

Two more fixes:

1. should solve the '0' for the cart_order_id in the downloads table.

2. solves the situation where a download may be inactive for no apparent reason.

 

1. In the file /classes/order.class.php, private function _orderAddProduct():

Near Line 893, Was:
$GLOBALS['db']->insert('CubeCart_order_inventory', $record);
 
Now:
$insert_id = $GLOBALS['db']->insert('CubeCart_order_inventory', $record);

The problem is that, if this downloadable product has taxes, CubeCart inserts a record into the order_tax database table, which has the database holding a new, different insertID. Line 908 needs the previous insertID from the database. So:

Near line 908, Was:
$this->_createDownload($item['id'], (int)$GLOBALS['db']->insertid());
 
Now:
$this->_createDownload($item['id'], (int)$insert_id);

Also, in this same file, if the state_id in the basket's billing or delivery address is not a numeric value, there may be the wrong taxes summed.

Near line 896, near the end of the statement, find:
getStateFormat($this->_baskett[$tax_on]['state_id'], 'name', 'id');
 
Change to:
getStateFormat($this->_basket[$tax_on]['state_id'], 'name', 'id');

Even so, hopefully the provided name of the state for the billing and delivery address is a proper State name (not an abbreviation).

 

2. In addition to post #18 above, make this edit in the file /classes/cubecart.class.php, private function _download():

Near line 1745, Was:
$download['active'] = ($download['expire'] > 0 && $download['expire'] < time() || $download['downloads'] >= $GLOBALS['config']->get('config', 'download_count')) ? false : true;
 
Now:
$download['active'] = ($download['expire'] > 0 && $download['expire'] < time() || (int)$download['downloads'] >= $GLOBALS['config']->get('config', 'download_count') && $GLOBALS['config']->get('config', 'download_count') > 0) ? false : true;

The FileManager gets it right, which explains why clicking the link from the email works, but when looking at available downloads in the Customer's Account Downloads page, the link says 'Inactive".

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...