Post by FnF » Sat Feb 01, 2025 11:28 am

I cant get this one figured out. Tried searching for an answer to no avail.
I have client that we installed OC 3.0.3.8 Maintenance, for.
Default Theme
Extensions are:
  • Daniels Spambot
  • Different Downloads per options
  • VQ Mod
  • Same order email for admin as customer
PHP 8.1
Browsers tested with, Safari, Chrome, Firefox

This site is used for selling sound files. Sounds files used in Game callers etc.
On the customers side, account > downloads, the purchased files are listed 10 to a page.
Customers with multiple pages are complaining that their pages of downloads shuffle themselves upon navigation.
I tested it with three different browsers and had the same results. Navigate from page 1 to page 2, and some of the files from page 1 are listed again further down the list on page 2.
Go back to page 1 and the list of files has changed from the first time I was there.

Any ideas why this is happening or what is causing it?
It's making it very difficult for customers to go through and efficiently download their purchased files.
Last edited by FnF on Sat Feb 08, 2025 7:47 am, edited 1 time in total.

User avatar
FnF
Active Member

Posts

Joined
Sat Mar 19, 2011 9:59 pm

Post by OSWorX » Sat Feb 01, 2025 5:44 pm

Sounds very strange to me.
Have you checked how the sorting and database queries are made at each page call?
Do you use any cache mechanism(extension, server, etc.)?

If I would be you, I would check first how the sorting and database queries are made.
And, if you are using php 8.x, I would prefer to use OpenCart 3.0.4.0 https://www.opencart.com/index.php?rout ... load_id=74

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Administrator

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by ADD Creative » Sat Feb 01, 2025 8:44 pm

Check catalog/model/account/download.php and if any of your extensions modify. It looks like the downloads are sorted by order.date_added. Are the downloads all from the same order?

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by FnF » Sat Feb 01, 2025 10:13 pm

Thanks guys.
With the customer I'm testing and checking with...No the files are not from the same order. Two different orders placed on the same date though.
You triggered my memory with your mention of cache. I recall having incredible cache issues with the site after install, while editing and customers trying to get through the checkout process.
After hours of searching for answers, I ended up place the following code in my framework.php

Code: Select all

header('Expires: Thu, 19 Nov 1981 08:52:00 GMT', true);
header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0', true);
header('Pragma: no-cache', true);
...and that fixed the cache problem immediately.

No other files have been changed since install, that I could see or find.

I DID however remove that snippet to test this mysterious shuffling and and they were still shuffling upon navigation.
I can even shuffle them by refreshing the page.

User avatar
FnF
Active Member

Posts

Joined
Sat Mar 19, 2011 9:59 pm

Post by FnF » Sun Feb 02, 2025 2:03 am

I took the time this morning to migrate this install to OC 3.0.4.0, in attempt to curb this issue.
The end result was no change. Files are still shuffled upon navigation or refresh of the customers "downloads" page.

Edited to add;
To further test pagination of multiple pages or downloads obtained through multiple orders, I checked a client with only 10 files in their account > downloads since thats how many files are displayed per page also. (all files from the same order)
The results were again the same. I could shuffle the list by refreshing the page.

User avatar
FnF
Active Member

Posts

Joined
Sat Mar 19, 2011 9:59 pm

Post by ADD Creative » Mon Feb 03, 2025 7:32 pm

In catalog/model/account/download.php try changing.

Code: Select all

ORDER BY o.date_added DESC
To.

Code: Select all

ORDER BY o.date_added DESC, op.order_product_id DESC

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by FnF » Tue Feb 04, 2025 9:08 am

Thanks ADD Creative.
I was sure that was going to fix the problem. Unfortunately it didn't.
I did find some interesting stuff being done to that file by the "Downloads_Per_Options Mod, though.
I feel stupid for not looking there first. :-\
I guess I need to visit the vendor of that mod.

Code: Select all

<file path="catalog/model/account/download.php">
<operation>
<search>
<![CDATA[ public function getDownload($download_id) { ]]>
</search>
<add position="replace">
<![CDATA[ public function getDownload_ORIGINAL($download_id) { ]]>
</add>
</operation>
<operation>
<search>
<![CDATA[ public function getDownloads($start = 0, $limit = 20) { ]]>
</search>
<add position="replace">
<![CDATA[ public function getDownloads_ORIGINAL($start = 0, $limit = 20) { ]]>
</add>
</operation>
<operation>
<search>
<![CDATA[ public function getTotalDownloads() { ]]>
</search>
<add position="replace">
<![CDATA[ public function getTotalDownloads_ORIGINAL() { ]]>
</add>
</operation>
<operation>
<search>
<![CDATA[ class ModelAccountDownload extends Model { ]]>
</search>
<add position="after">
<![CDATA[ public function getDownload($download_id) { $implode = array(); $order_statuses = $this->config->get('config_complete_status'); foreach ($order_statuses as $order_status_id) { $implode[] = "o.order_status_id = '" . (int)$order_status_id . "'"; } if ($implode) { $query = $this->db->query("SELECT d.filename, d.mask FROM `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "order_product op ON (o.order_id = op.order_id) LEFT JOIN " . DB_PREFIX . "order_option oo ON (op.order_product_id = oo.order_product_id) LEFT JOIN " . DB_PREFIX . "order_option_to_download oo2d ON (oo.product_option_id = oo2d.product_option_id AND oo.order_id = oo2d.order_id) LEFT JOIN " . DB_PREFIX . "product_to_download p2d ON (op.product_id = p2d.product_id) LEFT JOIN " . DB_PREFIX . "download d ON (oo2d.download_id = d.download_id OR p2d.download_id = d.download_id) LEFT JOIN " . DB_PREFIX . "download_description dd ON (d.download_id = dd.download_id) WHERE o.customer_id = '" . (int)$this->customer->getId() . "' AND (" . implode(" OR ", $implode) . ") AND d.download_id = '" . (int)$download_id . "'"); return $query->row; } else { return; } } public function getDownloads($start = 0, $limit = 20) { if ($start < 0) { $start = 0; } if ($limit < 1) { $limit = 20; } $implode = array(); $order_statuses = $this->config->get('config_complete_status'); foreach ($order_statuses as $order_status_id) { $implode[] = "o.order_status_id = '" . (int)$order_status_id . "'"; } if ($implode) { $query = $this->db->query("SELECT DISTINCT d.download_id, o.order_id, o.date_added, dd.name, d.filename FROM `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "order_product op ON (o.order_id = op.order_id) LEFT JOIN " . DB_PREFIX . "order_option oo ON (op.order_product_id = oo.order_product_id) LEFT JOIN " . DB_PREFIX . "order_option_to_download oo2d ON (oo.product_option_id = oo2d.product_option_id AND oo.order_id = oo2d.order_id) LEFT JOIN " . DB_PREFIX . "product_to_download p2d ON (op.product_id = p2d.product_id) LEFT JOIN " . DB_PREFIX . "download d ON (oo2d.download_id = d.download_id OR p2d.download_id = d.download_id) LEFT JOIN " . DB_PREFIX . "download_description dd ON (d.download_id = dd.download_id) WHERE o.customer_id = '" . (int)$this->customer->getId() . "' AND dd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND (" . implode(" OR ", $implode) . ") ORDER BY o.date_added DESC LIMIT " . (int)$start . "," . (int)$limit); return $query->rows; } else { return array(); } } public function getTotalDownloads() { $implode = array(); $order_statuses = $this->config->get('config_complete_status'); foreach ($order_statuses as $order_status_id) { $implode[] = "o.order_status_id = '" . (int)$order_status_id . "'"; } if ($implode) { $query = $this->db->query("SELECT COUNT(DISTINCT d.download_id, o.order_id, o.date_added, dd.name, d.filename) AS total FROM `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "order_product op ON (o.order_id = op.order_id) LEFT JOIN " . DB_PREFIX . "order_option oo ON (op.order_product_id = oo.order_product_id) LEFT JOIN " . DB_PREFIX . "order_option_to_download oo2d ON (oo.product_option_id = oo2d.product_option_id AND oo.order_id = oo2d.order_id) LEFT JOIN " . DB_PREFIX . "product_to_download p2d ON (op.product_id = p2d.product_id) LEFT JOIN " . DB_PREFIX . "download d ON (oo2d.download_id = d.download_id OR p2d.download_id = d.download_id) LEFT JOIN " . DB_PREFIX . "download_description dd ON (d.download_id = dd.download_id) WHERE o.customer_id = '" . (int)$this->customer->getId() . "' AND dd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND (" . implode(" OR ", $implode) . ")"); return $query->row['total']; } else { return 0; } } ]]>
</add>

User avatar
FnF
Active Member

Posts

Joined
Sat Mar 19, 2011 9:59 pm

Post by ADD Creative » Wed Feb 05, 2025 5:33 pm

You could modify the code in storage/modification to test if the query is the issue.

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by FnF » Thu Feb 06, 2025 8:11 am

ADD Creative wrote:
Wed Feb 05, 2025 5:33 pm
You could modify the code in storage/modification to test if the query is the issue.
Thanks ADD Creative
I reached out to the creator. They quickly replied and I sent some login info yesterday.
I'll report back when I hear something

User avatar
FnF
Active Member

Posts

Joined
Sat Mar 19, 2011 9:59 pm

Post by FnF » Sat Feb 08, 2025 7:46 am

This has been resolved.
Let me first thank again, OSWorX and ADD Creative for the attempts. I very much appreciate you two for reaching out.
The dev changed up the mod and it now no longer sorts downloads by "order date" and "download ID".

User avatar
FnF
Active Member

Posts

Joined
Sat Mar 19, 2011 9:59 pm
Who is online

Users browsing this forum: No registered users and 16 guests