Jump to content

[Solved] default carrier issue


Recommended Posts

Hi there

In PS 1.4.2.5 i use 3 weight intervals for paid carriers and 1 carrier pickup in store for free for all weight values

if i take one of the paid carriers as default, it properly showes the shippingcost in the cart if the weight is within the ranges of that default carrier

if the weight is within one of the paid default carriers which is not the default, it shows 0 eur shipping because then pick up in store is the cheapest

what i would like is to exclude pickup in store in the primary shippingcosts calculation, but stil keep it as option in the checkoutproces (i use OPC by the way)

anybody an idea?

thanks!

kind regards,
Pieter

Link to comment
Share on other sites

Yes! I solved it!!

I just added a second default carrier:

in classes/cart.php change in line 1023 from

if (empty($id_carrier) && $this->isCarrierInRange(Configuration::get('PS_CARRIER_DEFAULT'), $id_zone))
$id_carrier = (int)(Configuration::get('PS_CARRIER_DEFAULT'));


to

if (empty($id_carrier) && $this->isCarrierInRange(Configuration::get('PS_CARRIER_DEFAULT'), $id_zone))
$id_carrier = (int)(Configuration::get('PS_CARRIER_DEFAULT'));

if (empty($id_carrier) && $this->isCarrierInRange(Configuration::get('PS_CARRIER_DEFAULT_2'), $id_zone))
$id_carrier = (int)(Configuration::get('PS_CARRIER_DEFAULT_2'));


and add with phpMyAdmin in the database in table [prefix]_configuration
the line:
222 PS_CARRIER_DEFAULT_2 51 2011-06-25 22:55:55 2011-06-25 22:55:57

in which
222 is the automatically assigned incrementnumber
PS_CARRIER_DEFAULT_2 is the name of the value
51 is the id of the alternate default carrier, to be found in the BO
and the date/times are input and update

do change the BO that this can be done through there is a bit out of my league.

maybe this helps someone else too

regards,
Pieter
Link to comment
Share on other sites

  • 2 months later...

I am glad I found this thread, I have the same problem on 1.4.4.0 if you are not from zone of default carrier, cart show zero until the third checkout step.

 

Adding another default carrier would really save the day but I followed your tips with no results.

 

I add another default carrier in the database with the id of the other non-default carrier in backend but the cart.php code don't work for me.

 

If I add your code, cart still show zero from outside carrier_default_zone and correct inside carrier_default_zone

 

if (empty($id_carrier) && $this->isCarrierInRange(Configuration::get('PS_CARRIER_DEFAULT'), $id_zone))
$id_carrier = (int)(Configuration::get('PS_CARRIER_DEFAULT'));

if (empty($id_carrier) && $this->isCarrierInRange(Configuration::get('PS_CARRIER_DEFAULT_2'), $id_zone))
$id_carrier = (int)(Configuration::get('PS_CARRIER_DEFAULT_2'));

 

It seems the the second if statment is ignored, and if I try to invert, cart is correct inside carrier_default_zone_2 but show zero inside carrier_default_zone.

 

if (empty($id_carrier) && $this->isCarrierInRange(Configuration::get('PS_CARRIER_DEFAULT_2'), $id_zone))
$id_carrier = (int)(Configuration::get('PS_CARRIER_DEFAULT_2'));

if (empty($id_carrier) && $this->isCarrierInRange(Configuration::get('PS_CARRIER_DEFAULT'), $id_zone))
$id_carrier = (int)(Configuration::get('PS_CARRIER_DEFAULT'));

 

I found no way to make it work for both zones. Any help is really apprecieted.

Link to comment
Share on other sites

Hi,

 

Setting this up always is a big hassle, each time i change something it takes me hours to get it right...

 

I work with 4 default carriers in the meantime, and managed to get it working, check out www,muramura.nl if you want to see it working.

 

the order in which the if statements are placed should not matter, they are all executed

 

a few things i encountered:

did you set the out of range behaviour of each carrier to deactivate?

did you remember to change the carrier number in the database after changes made with the carriers?

your weight-intervals are not overlapping?

did you clear the cache after changes made?

 

i work with one page checkout, dont know if that is of influence.

 

hope this helps...

 

regards,

Pieter

Link to comment
Share on other sites

  • 2 months later...

Hi Pieter and all,

 

I don't like the idea to have 2 default carriers, it looks strange to me.

 

As I had the same problem, I modified the function getOrderShippingCost in Cart.php. It's an override class you you can put the file in /override/classes. Tested on PS 1.4.5.1 but should work on 1.4.X

 

The principle is simple : when PS search for a carrier when the range of default is passed, it looks in a array and stop when it founds one. Just put a condition "and the carrier is not free" and it will not select it. At the check out, the "pickup in store" appears and can be selected.

 

I tested with 3 non free carriers and a free "pickup in store".

 

Regards,

 

Vincent

Cart.php

  • Like 1
Link to comment
Share on other sites

  • 12 years later...

Hi, I have found a solution for Prestashop 1.7.8.9 version.

On /classes/Cart.php, line 2896 add the condition in bold:

                    $price_with_tax = $this->getPackageShippingCost((int) $id_carrier, true, $country, $package['product_list']);
                    $price_without_tax = $this->getPackageShippingCost((int) $id_carrier, false, $country, $package['product_list']);
                    if ((null === $best_price || $price_with_tax < $best_price)  && $price_with_tax !== null && $price_with_tax != 0) {
                        $best_price = $price_with_tax;
                        $best_price_carrier = $id_carrier;

In my back office, default carrier option is "best price".

I have 1 carrier set as free shipping for in store pick-up, others are non-free.

Behaviour before the change when adding a product to the cart: the function picks up the cheapest carrier (free shipping)

Behaviour after the change when adding a product to the cart:  the function picks up the cheapest non free carrier

Hope this helps!

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...