Jump to content

Where are set $errors_discount


jd440
 Share

Recommended Posts

Hi everyone.

 

On shopping-cart.tpl we got:

{if isset($errors_discount) && $errors_discount}
<ul class="alert alert-danger">
{foreach $errors_discount as $k=>$error}
<li>{$error|escape:'html':'UTF-8'}</li>
{/foreach}
</ul>
{/if}

Can anyone telle me wherre are set $errors_discount ?

I look almost everywhere and I don't find it?

only on :

order-payment.tpl and shopping-cart.tpl?

Share this post


Link to post
Share on other sites

If ran a quick scan through every file that comes with a prestashop installation and outside of order-payment.tpl and shopping-cart.tpl there is not a single mention or definition of this variable. (neither in .php controller code or .tpl template assignment)

 

You should report a bug for this.

 

(Note: If you want to search for plaintext in all your prestashop files quickly try and use this old programme: InfoRapid Search&Replace - it allows you to search through all files in a matter of seconds ;)

Share this post


Link to post
Share on other sites

Thanks.

That's what I did also.

And I was surprise.

find /var/www/html/prestashop/ -name "*" -exec grep -Hn "errors_discount" {} \;

and also search by sublimetext

 

Share this post


Link to post
Share on other sites

This variable is not defined in either 1.4,1.5 or 1.6 in any of the default modules or basic code. It can be however, that one of PrestaShop's add on modules is defining it, and that they added this code to do something with it IF defined. No need to report a bug...

 

As the code is excluded if the variable is not defined, this code won't be executed either. It takes a microsecond extra to decide if it should be included or not, so I don't expect much delay problems from it either.

 

Did you encounter any problem with it, or were you just curious??

 

 

My 2 cents,

pascal.

Share this post


Link to post
Share on other sites

I'm not sure whether agree with you - if its code that never is executed it means that it is obsolete and it should be removed from the main files. It's it is used by any default module (which it isn't, as I check the modules as well) it should never have landed in a default-template .tpl file :)

 

As for the microsecond, I agree, performance hit will be nihil, but ten of these obsolete code blocks can make the difference between a polished code base and an out-of-sync codebase with problems, I've seen it happen in 'the office'...

Edited by las3r (see edit history)

Share this post


Link to post
Share on other sites

Laser, you're right. This code 'should not be here'. If they have a module that needs this, they should add this at that moment. May very well be that it's forgotten code. At the very least, some comment where/when it is used would be great...

Share this post


Link to post
Share on other sites

Thanks for your explanation.

 

I was question myself, because for a specific developpment I was looking to get discount error on shopping-cart.tpl.

 

I don't like the way it's reporting error when customer entrer wrong code.

Instead of message in top of the cart, I d prefer to get the message on the top of voucher's input box, And styled the box with some red color.

So i was questionning myselfg about the variable.

 

To only way I find is:

{if $errors[0]|strstr:"voucher"}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More