jmauclair Posted November 21, 2022 Share Posted November 21, 2022 Hi guys, I'm coming to you because I'm actually developping a module to allow the possibility to set free shipping depending of the total amount of the cart, even if the carrier is set on a range weight model. I've tried many solutions, first of them is doing a carrier Module : - Even if I used the functions set for CarrierModule to calculate shipping cost, it seems that the carrier not made through this module were not using the function to calculate the shippping through the module. So I tried another way, modify shipping cost through the hook ActionCartSave: - It seems that is not possible to modify the shipping price of the cart directly from his module. My actual plan is now to create a delivery option (table miib_delivery), it seems that this is use to calculate shipping cost, based on the range of price or weight set, I've been able to generate my range price and my delivery option, but for an obscur reason, my delivery option is not used when calculating the shipping. So here are the solutions that I already though about but are impossible in my case : - Create a new carrier that will be free over € -> It won't be linked to the initial carrier Module, which is really important for setting the relay, and printing the shipping label - Modify the shipping price dinamically in the DB -> Surely the worst idea I had Here are the worst solutions : - Override Cart or Carrier class -> Override is risky, moreover I'm using custom class made in my module to generate object of my free shipping carrier, so it might create conflicts between all (carrier module , ect). I'm quiet lost on the best way to do this, the most efficient and the most scalable between PS versions, olders and newers. If somebody has already faced the same issue, please help me, I know there is many way to do it, but I don't just wan't to do it, I wan't to do it properly. Link to comment Share on other sites More sharing options...
Open Presta Posted November 21, 2022 Share Posted November 21, 2022 hello, if you need i can build it in a module fee shipping rule , no override and no change in db. like this our module , but one condition work from Prestashop 1.7.8 https://addons.prestashop.com/en/order-management/88003-order-extra-fees-charges.html Link to comment Share on other sites More sharing options...
jmauclair Posted November 22, 2022 Author Share Posted November 22, 2022 13 hours ago, Open Presta said: hello, if you need i can build it in a module fee shipping rule , no override and no change in db. like this our module , but one condition work from Prestashop 1.7.8 https://addons.prestashop.com/en/order-management/88003-order-extra-fees-charges.html Thanks but I think we are on the Prestashop Forum for developers, not the Prestahsop marketplace or addons Forum ( https://www.prestashop.com/forums/forum/325-prestashop-addons/ ), so I’m not searching for a module, I’m searching for the best way to do it Link to comment Share on other sites More sharing options...
lordignus Posted December 6, 2022 Share Posted December 6, 2022 Might not be much help, but I use a module that achieves this with an override of Cart->getPackageShippingCost() Good luck Link to comment Share on other sites More sharing options...
Tom Girou Posted December 7, 2022 Share Posted December 7, 2022 I'm personnaly doing your "worst case" scenario. Link to comment Share on other sites More sharing options...
jmauclair Posted December 27, 2022 Author Share Posted December 27, 2022 On 12/7/2022 at 1:43 PM, Tom Girou said: I'm personnaly doing your "worst case" scenario. On 12/6/2022 at 3:38 PM, lordignus said: Might not be much help, but I use a module that achieves this with an override of Cart->getPackageShippingCost() Good luck I'm going for the worst case so 😿 I've tried to add a custom hook in cart class, but finally that's the same as creating an override Thanks for your help guys, I expect Prestashop will add maybe a hook at shipping calculation on the next versions. Link to comment Share on other sites More sharing options...
jmauclair Posted January 25, 2023 Author Share Posted January 25, 2023 Hi guys, I'm reopening this case 😭 I've finally made it by using an override of the cart class and the function getPackageShippingCost() But when the order is created, the user as paid the good price for exemple : - Product : 80€ - Shipping : 5€ Free over 75€ so the customer pay 80€. The payment value is good, but the payment lines on the order detail isn't, and the invoice price too. What did I've missed ? Link to comment Share on other sites More sharing options...
Tom Girou Posted February 2, 2023 Share Posted February 2, 2023 Here are all the functions I did override, maybe it will help you : getDeliveryPriceByWeight() checkDeliveryPriceByWeight() getMaxDeliveryPriceByWeight() getDeliveryPriceByPrice() checkDeliveryPriceByPrice() getMaxDeliveryPriceByPrice() Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now