문제

I want to add our custom amount in total cart amount during checkout or payment in prestashop in custom payment module. And so can i change cart amount during checkout or payment in our custom payment module in prestashop?

도움이 되었습니까?

해결책

There are three options I spontaneously know about:

  • Use an already available module for such purpose. In this case, there is in example the Additional Payment Fees module (which I use in production in a PrestaShop installation myself).

  • Write an additional module which can apply configurable fees on selectable payment options. This might be the favored option and bases on the same principles as the next.

  • Make your payment module use a specific cart rule.

I checked it again and cart rules do not appear to be a good idea for adding fees rather than discounts. In fact, the PrestaShop Back-Office does not allow to set up cart rules with negative "discounts".

These are the things to take care about:

  • Its best to add the fee distinct from the actually purchased products and eventual shipping costs to maintain transparency towards the customer. This might not be a technical detail, but valuable concerning user experience.

  • Display the additional fees for a payment type on the cart page. The hookdisplayShoppingCart or displayShoppingCartFooter is suitable for that. These hooks can also be used to initiate calculation of payment fees and storing them in association with the cart because calculation is necessary only when the customer is confronted with the choice of payment: in the cart.

  • Create an additional column in the cart table or alternatively a dedicated table which holds the fee information for each cart. This information must be stored permanently as it is necessary even after finished order.

  • Getting the cart's total value is easy: $this->context->cart->getOrderTotal(); - but keep in mind that this includes tax (provide false as first parameter). I am not sure about whether such fee must be applied to the net or gross value of the cart.

  • They must be visible on the invoice, too. In that case the displayPDFInvoice hook is suitable for inserting additional information into the invoice PDF.

I am sorry I did not find yet how to finally apply the fee to the cart for checkout but I hope it helps if I point into the direction of tax rules, which you could leverage programmatically for each order.

Sources

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top