- Posts: 69
- Thank you received: 5
Discount not calculated
- politikchronist
-
Topic Author
- Offline
-- HikaShop version -- : 4.4.4
-- Joomla version -- : 3.10.3
-- PHP version -- : 7.4.20
-- Browser(s) name and version -- : Firefox 93.0
-- Error-message(debug-mod must be tuned on) -- : Warning: trim() expects parameter 1 to be string, array given in /var/www/html/joomla/administrator/components/com_hikashop/classes/discount.php on line 157
When trying to order with discount, the discount is not calculated. The following error message is shown.
Warning: trim() expects parameter 1 to be string, array given in /var/www/html/joomla/administrator/components/com_hikashop/classes/discount.php on line 157
Thanks for help
Please Log in or Create an account to join the conversation.
- politikchronist
-
Topic Author
- Offline
- Posts: 69
- Thank you received: 5
Please Log in or Create an account to join the conversation.
I don't see why it would do that. I'm not able to reproduce the problem on my end.
Where do you get that warning ?
Could you temporarily add the line of code below:
That should display a callstack of the situation until where the error happens so that we can better understand why it's displaying that error.
Also, could you provide the screenshot of a discount which doesn't work so that we can better understand the situation ?
Finally, maybe you're talking about coupons not discounts ?
We actually fixed today an issue with coupons not working when only one of the min/max of the quantity or amount restrictions were applied:
www.hikashop.com/support/forum/discount-...-working.html#337142
So if that's your issue, then just downloading again the install package on our website and installing it on yours will fix the problem.
Please Log in or Create an account to join the conversation.
- politikchronist
-
Topic Author
- Offline
- Posts: 69
- Thank you received: 5
Sorry, I am only the administrator, not programmer, and I need more information into what file at what position to enter the code line you mention. Sorry again.
The error happens in both areas. It first occurred in coupons. Then I changed and entered a discount for some customer. But got the same result.
The error message appears on top of the summary of the shopping cart.
(We are a non-profit organization and sell books. Bookstores can order with discount. But we cannot proceed the orders right now.)
The discount function worked well for weeks.
Thanks in advance.
Please Log in or Create an account to join the conversation.
- politikchronist
-
Topic Author
- Offline
- Posts: 69
- Thank you received: 5
If you prefer to take a look into the admin side, I could install a super-user right for you.
Please Log in or Create an account to join the conversation.
Well, I told you to add the code just before the line number 157 in the file /administrator/components/com_hikashop/classes/discount.php
So I don't know what more information I can give you regarding the "what file at what position", since that's precisely what I gave you.
But before all that, as I said before, we've added a fix regarding the discount system. So I would first recommend you reinstall your HikaShop to get the fix. That might be enough.
Unfortunately, a backend access won't allow me to add the debug in the file as it needs to be done with the FTP access provided by your hosting.
Please Log in or Create an account to join the conversation.
- politikchronist
-
Topic Author
- Offline
- Posts: 69
- Thank you received: 5
Please Log in or Create an account to join the conversation.
- politikchronist
-
Topic Author
- Offline
- Posts: 69
- Thank you received: 5
And the result was:
Warning: trim() expects parameter 1 to be string, array given in /var/www/html/joomla/administrator/components/com_hikashop/classes/discount.php on line 157
Is this helpful?
Please Log in or Create an account to join the conversation.
- politikchronist
-
Topic Author
- Offline
- Posts: 69
- Thank you received: 5
Please Log in or Create an account to join the conversation.
- politikchronist
-
Topic Author
- Offline
- Posts: 69
- Thank you received: 5
Thanks for your attention.
Please Log in or Create an account to join the conversation.
Thanks for the details. Maybe you have something like opcache on your hosting server ( wp-rocket.me/blog/what-is-opcache/ ). This will make PHP automatically cache the compiled versions of the PHP files for a while so that it saves resources.
But in that case, it's possible that after an update the cached version of the files are not taken into account immediately.
It's possible to manually flush the opcache cache : ma.ttias.be/how-to-clear-php-opcache/
I looked at the code but besides the fix I was talking in my previous message, I don't see any reason for these to happen.
So if it's now working properly, it just mean that the update fixed the problem.
The red error message upon registration indicates that you've activated the privacy consent plugin in the Joomla plugins manager but that for some reason you didn't agree to the privacy consent when asked on the registration form.
It could be that you missed it, or it could be that it wasn't added to the registration form.
This last case could happen if you have an override of the sub_block_login_registration.php view file via the menu Display>Views based on an old version of HikaShop which didn't support the privacy settings.
Please Log in or Create an account to join the conversation.
- politikchronist
-
Topic Author
- Offline
- Posts: 69
- Thank you received: 5
Am I right to expect that if this was the case, it should not happen with the last version updated?nicolas wrote: Hi,
This last case could happen if you have an override of the sub_block_login_registration.php view file via the menu Display>Views based on an old version of HikaShop which didn't support the privacy settings.
Thanks again for your efforts to answer to my questions.
Please Log in or Create an account to join the conversation.
No, this could happen even after the update since view overrides are not deleted during updates (it's the whole point of creating overrides that you keep them during updates).
So I would recommend you to check if you can find an override for that view file in the Display>Views menu. If you do, you can backup the code and delete the override so that it uses the default view file and if it fixes the problem, then it means it indeed came from that view override and you can create a new view override and port the modifications from the backup to the new version of the view file.
Please Log in or Create an account to join the conversation.
- politikchronist
-
Topic Author
- Offline
- Posts: 69
- Thank you received: 5
The nice guys, who helped a lot from Vietnam, announced just a few weeks after I was proud having realized the site, that they are only giving support for some more month. So may be soon I need to switch to a new template. May be we will be in a mess without a Joomla specialist. But as a non-profit organization, we might need to collect money to finance it.
I liked the easy way of defining the pages very well. But now may be I have to switch soon to another template. If you have any proposal what template might make the less issues when changing from JSN_Bookstore, I would appreciate your mentioning it.
My own small overrides were only on the language file.
Please Log in or Create an account to join the conversation.
So you confirm that you don't see the privacy consent area on the registration form of the checkout and that the red error message says that you need to validate the privacy consent option ?
If so, then yes, yt's probably linked to an override in your template.
Search for the file templates/YOUR_TEMPLATE/html/com_hikashop/checkout/sub_block_login_registration.php via FTP.
If you find it, rename it in order to deactivate it and check your checkout registration form. You should now see the privacy consent area. Hopefully, the registration form still looks the same without the customized override and so you can keep the view file override renamed.
Please Log in or Create an account to join the conversation.
- politikchronist
-
Topic Author
- Offline
- Posts: 69
- Thank you received: 5
Thanks again!
Please Log in or Create an account to join the conversation.