Jump to content

Get the cost for a specific carrier id


FluffyCat

Recommended Posts

Hi

 

I am trying to calculate the shipping cost for a specific carrier and I just can not get it to return anything else but 0.

 

I have created a new carrier that serves lets say Belgium.

 

Now I thought I would be able to use the Cart.php function

getCarrierCost($id_carrier, $useTax = true, Country $default_country = null, $delivery_option = null)

 

to properly calculate the cost using this carrier. I have tried several combinations, creating the country, trying to get the delivery_option array but all I get back is 0.

 

The carrier is enabled for the zone where Belgium is located and the id of the carrier I have just taken from the backoffice. I have printed the Country info and its also initated ok to Belgium.

 

Nevertheless, I just can´t get it to return the correct shipping cost. 

 

Can anyone please advice on how to use this function? I just want it to return the correct price for a hardcoded country and carrier_id.

 

Thanks in advance

 

Link to comment
Share on other sites

Hi

 

Thanks for the reply. 

 

As I mentioned, for my test country Belgium I only have one carrier available, when doing the full checkout, Prestashop correctly shows this carrier in the carrier list so it must be properly configured. 

 

The default Carrier in my shop has id 144, this carrier does not shop to the Zone where Belgium is, it only ships to a custom zone that includes Spain and Portugal.

 

The Carrier that ships to the rest of Europe has id 146.

 

When doing like this:

$belgium = new Country(3);
print_r( $this->getDeliveryOption($belgium));
 
I only get an array with carrier 144 inside but this is not correct. The carrier with id 144 is not available for Belgium, again, when listing the carriers in the checkout process, then it works and carrier 146 is the one shown.
 
So, the main issue here is that when calling getDeliveryOption I just get the default carrier, that is 144. I need a way to get the carrier for a specific country like in the example above.
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...