Loading

This manual is intended for people who have basic knowledge in HTML, Smarty, PHP. The plugin developer does not perform free optimization and profiling work.

Flexdiscount plugin uses hook frontend_products for changing product prices. This hook, due to it's features, is called very often in theme designs and plugins. For example, in product's collections, total price, total discount. Some of this callers can be optimized.

Here are some requests, which activates discount calculating:

Smarty:


PHP:


Any clearing of the session shop/cart also will cause to discount calculating to update information in requests above.

Below you will find a list of recommendations for optimizing Flexdiscount plugin, theme designs and external plugins. Make sure to take into the user's convenience.

Recommendations for optimization

1) Disable or delete plugin.

This option will significantly improve performance, because the plugin will no longer use server resources to create discount systems.

2) Disable setting "Change product prices to discount prices".

This setting uses hook frontend_products and it is the most resource-intensive.

If you stop here and decided to disable it, all recommendations below will not be relevant for you.

3) "Ignore price changing in plugins below".

This setting is located under the setting "Change product prices to discount prices". It disables requests from plugins through the hook frontend_products.

Disable (tick checkboxes) as many plugins as possible. Pay attention to the total amount of discounts for products and the order. If you will get incorrect calculating, this means, that you should not disable plugin.

Theme designs

4) Pay attention on requests in loops.

This is strictly forbidden!

If you find a similar construction in the template, change it immediately:


You'd better to take it outside the loop and use only variable $products inside the loop:


5) Reduce the number of calls of the order total, order discount, and product collections.

You can find this constructions really often in the templates:


Use variables instead of multiple calls:


6) Optimize product collections.

Some calls of {$wa->shop->products(...)} may be realized without getting actual information about discounts. By default each call calculates discounts for products. If you need only product features or product names, disable discount calculating.

Use option no_plugins_frontend_products. For example, this construction:


Can be replaced with the following:


Or:


Replace to:


Or:


Replace to:


This option should be specified as 4th argument.

PHP-files

7) Optimize product collections.

Similar to 6 paragraph.

Use the following construction:


8) Use plugin extra parameters.

"Flexdiscount plugin" has parameters, which help to disable discount calculating in the hook frontend_products, if it is not necessary.

Use the following parameter to disable discount calculating.


Parameter blocks the hook frontend_products.

Don't forget to enable hook back to work, otherwise it can break other plugins.

Let's take an example:


9) Use deny rule instead of "Not equal".

In discount rules instead of conditions with operator "not equal" (for conditions from the group Product) it's better to create deny rule.

This recommendation is relevant, if number of products with operator "equal" will be less, than with operator "not equal".


The plugin allows you to get a complete report of all calls. To do this, you must perform profiling. Based on profiling report, it will be clear which recommendation should be used and in which place.

Posted: April 29, 2020
0
Feedback form

Fill the form, and we will contact you.

Your name:
Email
Message: