Jump to content

Shipping / Carrier Module


Recommended Posts

Hello.

 

I am developing a carrier module, used for calculating shipping costs for orders. The module creates a carrier, and gets the shipping costs depending on zipcode, weight and cost of the order. The external API returns a value for the cost, or false if there is no shipping available for that combination.

 

I would like to handle this by disabling or removing the carrier on the front end, so customers would not see that carrier in those specific options.

 

There is always a default option for picking up the order at the store, but I would like the other carrier to only be shown if the shipping is actually available. Is this possible, either by tapping into the cart object and setting some options, without messing with the Prestashop core code? Or would I have to edit the checkout templates and code? Can anyone point me to the correct way of doing this?

 

Thank you in advance.

 

<?php
if (!defined('_PS_VERSION_')) exit;

class ShippingCalculator extends CarrierModule {
public function getOrderShippingCost($params, $shipping_cost) {

$apiValue = getValueFromExternalAPI();
// returns shipping cost for zipcode, weight and price, or false if shipping is no available

return $apiValue;
}
}

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...