mageprince / magento2-paymentfee

Magento 2 Payment Fee by MagePrince helps admin to set payment fees to charge customers for selecting a specific payment method to complete their order from all available payment methods.
25 stars 19 forks source link

Problem that causes a lot of extra loading time #24

Closed lesleydesmet closed 2 years ago

lesleydesmet commented 2 years ago

Hi there! We have been using your extension for a long time now and are really thankful for this solution. Although, we've ran into the problem that at least five calls are being done on our checkout page to gather the fee information, even when there's no extra fee rule active for the current store.

image On this image you can see the amount of calls and the seconds it takes to do this.

Is there a possibility you could look into this problem? I'm wondering if any call is necessary when there's no extra fee rule active for the current store? Also, why are there so many calls to the same endpoint with the same result?
Thank you in advance!

Best regards, Lesley

mageprince commented 2 years ago

Hi @lesleydesmet, Thank you for your report.

With an extra fee pro extension, we support lots of checkout page rules like shipping addresses, shipping method, billing address, payment method, etc. To check each rule we need to check fees on updating any fields of shipping addresses. So fee-information endpoint called at the time of updating shipping address, change the shipping method, change payment method, etc. By default, this endpoint is called only one time on the checkout page load. When you do any action as mentioned above we must call this endpoint to validate the latest current quote and check fee availability.

We have already added filters with store and customer groups. You will get an empty array if the current store or current customer group doesn't meet any rule. Please check this class for more understanding: \Mageprince\ExtrafeePro\Model\Calculation\CalculationService::collectQuote

We follow the same implementation as Magento validate quote on each action. For example, Magento calls endpoint estimate-shipping-methods to check if the shipping methods are applicable for the current quote. Check the below screenshot:

image