Closed igor-tv closed 4 years ago
Sorry, I was unable to replay this behavior. Perhaps the problem was in the wrong settings on my part. I changed the currency code.
But I found another bug. If you have an order with a failed payment, and for some reason you changed the currency code on the backend, then you will not be able to go to the details page of this unsuccessful order on the backend.
Error:
No query results for model [OFFLINE \ Mall \ Models \ Currency].
/Applications/MAMP/htdocs/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php line 414
This is fixed in df69e4e, thanks @igor-tv!
Hi guys,
I was able to reproduce the error... After loggin in in a users account, I get the following stack trace. Do you know what the issue might be?
We're sorry, but an unhandled error occurred. Please see the details below.
/var/www/vhosts/mydomain.com/httpdocs/plugins/offline/mall/components/orderslist/productlist.htm line 32
Twig Template
Cms\Classes\CmsException
A quick update - I managed to get rid of the error. The database table offline_mall_product_files
was empty, but the table offline_mall_product_file_grants
did have a lot of references. I'm guessing the offline_mall_product_file_grants
tried to look up files that don't exist. What do you think?
Is it the case that when a product file is deleted, the related file grant is deleted aswel? If not, I'm guessing that is the source of the error...
Hi, I'm doing some more testing and it does seem like even though a product has no associated files, the table offline_mall_product_file grants is being populated. The problem is that is then displays this strange message: "Download download 114". If you click on it, the file is not found, because it doesn't exist.
What can we do to tackle this?
In the logs it then states [OFFLINE.Mall] A virtual product without a file attachment has been purchased. You need to fix this!
.
But what about virtual products like event tickets? I think we should allow virtual products not to have a file attached to them.
Can you let us know how to proceed?
The log message above comes from here: https://github.com/OFFLINE-GmbH/oc-mall-plugin/blob/develop/classes/downloads/VirtualProductFileDownload.php#L65
This method is only triggered when you visit the download link. Where do you list the download link? If you don't have any file attached, why show a download link?
Do you generate a file on your own?
It's probably a good idea to check before this for
loop if the product actually has any files attached and if not, the grant should never be created:
Hi @tobias-kuendig
Thanks so much for your answer. You are correct - I don't want to show a download link if there is no file associated with the virtual product. But at the moment the download link is being displayed regardless:
The download link is displayed in the following partials:
/plugins/offline/mall/components/orderslist/productslist.htm
{% if product.product_file_grants.count > 0 %}
<br/>
{% for grant in product.product_file_grants %}
<br/>
<a href="{{ grant.download_link }}">
Download {{ grant.display_name }}
{{ loop.length > 1 ? ('#' ~ loop.index) }}
</a>
{% if grant.expires_at %}
<br>valid until {{ grant.expires_at.toDateString() }}
{% endif %}
{% if grant.max_download_count %}
<br>max. {{ grant.max_download_count }} downloads
{% endif %}
{% endfor %}
{% endif %}
And also in one of the fragments of one of the emails sent by the system mall.order.table
So basically - if you create a virtual product and do not link a file to it, the above code does still display a download link in the format Download Download ID
.
I assume that if there is no file connected to a virtual product, a file grant should not be created. Am I overlooking something?
Thanks for looking into it, I appreciate it.
P.S.: My client is absolutely thrilled with your e-commerce solution. It is so incredibly complete and practical right out of the box. And it's a joy to work with. We only need to remove a few small hiccups and we're golden!
I assume that if there is no file connected to a virtual product, a file grant should not be created. Am I overlooking something?
This is correct. Before this line, you can try something like this (untested):
// Do not create a download grant if the product has no files attached.
if (!$orderProduct->product->latest_file) {
return;
}
This should get rid of the empty download grants, and since no grants are created, the code in the partial you linked above should be skipped ({% if product.product_file_grants.count > 0 %}
)
If this fixes your issue a PR is as always welcome!
Hi @tobias-kuendig,
You're the master!
Just tested it out, both with and without a file attached to the product. Now it works perfectly. I've created a pull request here: https://github.com/OFFLINE-GmbH/oc-mall-plugin/pull/862
Please note one small thing, not important for me on the short term: I notice that the download link is available even if the order hasn't been paid yet. I can easily circumvent this by changing the Twig code, but I just wanted to let you know.
Thanks for all of your work and help.
This is causing serious issues with my virtual downloads.
My products do NOT have a file associated. A pdf is generated on the file, after the mall.product.file_grant.created
event is triggered.
But these changes (https://github.com/OFFLINE-GmbH/oc-mall-plugin/pull/862/commits/52f112c5d36b091b4a082472590cd407455c6121) are preventing this.
I've commented out for my purposes, but can we have a fix for this?
After failing to pay for an order using PayPal, I tried to go to the account's order page and received this error:
In this order there were only non-virtual goods.