Nils-H Posted August 3, 2011 Share Posted August 3, 2011 Hi! I'm trying to develop a custom shipping module, and I have some questions. I have hooked the module into "extraCarrier", and I am able to display the shipping options and prices, which are dynamic based on postcode. - The carrier I'm creating the module for has several shipping products. Do I need to create a carrier for each shipping product? - Do the carrier physically need to exist (in the database), or can I just get the shipping cost from the external service and update the order/cart with the shipping cost value? - ... which leads to, how do I update the order/cart with the new shipping cost? Link to comment Share on other sites More sharing options...
Ehinarr Posted August 3, 2011 Share Posted August 3, 2011 You must craete the carrier in order to prestashop manage somethings like free shipping... Once created the carrier you can manage all services that apply to the customer address inside the module trough functions. Your module must have a function called getOrderShippingCost or getOrderShippingCostExternal, in order to update cart, this way is very recommended to store shipping values got from external services in a database table. See, In Cart.php class,the function getOrderShippingCost(), near line 1159 (//get external shipping cost from module). Link to comment Share on other sites More sharing options...
Nils-H Posted August 4, 2011 Author Share Posted August 4, 2011 Yes, I figured that out eventually by reading through the source code of the other shipping modules that comes with prestashop. So now I have it _almost_ working. The only issue now is that if I have no other carriers than those created with my module, an error is displayed: "There are no carriers available that deliver to this address." However, the carriers I have created are enabled for all zones... Link to comment Share on other sites More sharing options...
Ehinarr Posted August 4, 2011 Share Posted August 4, 2011 Check the order-carrier.tpl file of your theme if there is a line like this in it: {if $HOOK_EXTRACARRIER || ($carriers && count($carriers))} Link to comment Share on other sites More sharing options...
Nils-H Posted August 4, 2011 Author Share Posted August 4, 2011 No, doesn't look like it has that line. It's a prestashop 1.4.4.0 test installation with the default prestashop theme. Link to comment Share on other sites More sharing options...
Ehinarr Posted August 4, 2011 Share Posted August 4, 2011 I think if you add "$HOOK_EXTRACARRIER' on "if' statement maybe works. Link to comment Share on other sites More sharing options...
Nils-H Posted August 5, 2011 Author Share Posted August 5, 2011 Hm... I guess I could try that. But that kind of defeats the purpose of creating a standalone installable module, if a file has to be manually patched. Link to comment Share on other sites More sharing options...
[email protected] Posted June 3, 2013 Share Posted June 3, 2013 How did you get the customer's zip code from within Cart.php? I only see a zone_id. 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