Jump to content

[SOLVED] There are no carriers that deliver to the address you selected


Recommended Posts

Hi,

 

i had search all the forum topic which is related to this problem for prestashop 1.5 but didnt saw any working solution for this. i believe some solution are working but no post out clearly how to solve step by step.

 

i had tried few days to create new carrier and delete for so many times and still no luck on it. So i decide to post some screen shot and hope anyone out there which know what exactly happen to my setting or it is a bug etc.

 

thanks for helping....

post-37808-0-60905700-1349285662_thumb.jpg

post-37808-0-69748200-1349285672_thumb.jpg

post-37808-0-26824600-1349285682_thumb.jpg

post-37808-0-68383100-1349285697_thumb.jpg

post-37808-0-24413100-1349285707_thumb.jpg

post-37808-0-60905700-1349285662_thumb.jpg

post-37808-0-69748200-1349285672_thumb.jpg

post-37808-0-26824600-1349285682_thumb.jpg

post-37808-0-68383100-1349285697_thumb.jpg

post-37808-0-24413100-1349285707_thumb.jpg

Link to comment
Share on other sites

problem of no carrier on the selected address is SOLVED ! because of all the country are set to disable in default. just enabled all the countries and it will working.

 

But after this have another issues, which is invalid address. if anyone have similar issue and is solved please help in this.

 

thanks

Link to comment
Share on other sites

  • 1 month later...

problem of no carrier on the selected address is SOLVED ! because of all the country are set to disable in default. just enabled all the countries and it will working.

 

But after this have another issues, which is invalid address. if anyone have similar issue and is solved please help in this.

 

thanks

 

I had adjust correctly prise ant weight ranges for every carrier as well to solve this issue

Link to comment
Share on other sites

  • 1 month later...

What if you don't what to enable all the countries, I only want to enable North America?

Will the system require that I enable all the countries?

 

Edit: After 2 hours, I found a setting that corrected the issue.

Here is a video I made for a client:

http://www.youtube.com/watch?v=cKF2KdoojCA

Edited by Goldmaverick (see edit history)
  • Like 4
Link to comment
Share on other sites

  • 5 weeks later...

What if you don't what to enable all the countries, I only want to enable North America?

Will the system require that I enable all the countries?

 

Edit: After 2 hours, I found a setting that corrected the issue.

Here is a video I made for a client:

http://www.youtube.com/watch?v=cKF2KdoojCA

 

 

Your two hours worth the time. I finally was able to solve this, thx to you.

 

THANK YOUUUUUUUUUUUUUUUU

Link to comment
Share on other sites

  • 1 month later...

hi there:

 

Problem is only exist when Enable Guest Checkout function. Otherwise it works fine.

 

I am using 1.5.3.1 , After click check out. I am set up as one page check out option from BO.,

If I choose the Instant Checkout. After I fill up all details and save.

 

The Carriers are not showing on the bottom and Says:

 

No carriers available for the address "My address".

 

Please see test in my website. www.fancychannel.com

 

 

Please help on how to fix the problem.

 

I have set up all the Price range and Weight Range.Carrier details, Turn Off Advanced Stock Mamagement,

 

The weight range is like 0-0.1kg, 0.1kg -0.2kg, 0kg-1kg,............

 

Price Range set all carrier from $0.00 to US $100,000.00.

 

Registration process type : Only Account Creation.

 

Please help! Thanks in advance.

Link to comment
Share on other sites

hi there:

 

Problem is only exist when Enable Guest Checkout function. Otherwise it works fine.

 

I am using 1.5.3.1 , After click check out. I am set up as one page check out option from BO.,

If I choose the Instant Checkout. After I fill up all details and save.

 

The Carriers are not showing on the bottom and Says:

 

No carriers available for the address "My address".

 

Please see test in my website. www.fancychannel.com

 

 

Please help on how to fix the problem.

 

I have set up all the Price range and Weight Range.Carrier details, Turn Off Advanced Stock Mamagement,

 

The weight range is like 0-0.1kg, 0.1kg -0.2kg, 0kg-1kg,............

 

Price Range set all carrier from $0.00 to US $100,000.00.

 

Registration process type : Only Account Creation.

 

Please help! Thanks in advance.

 

Hey man!

Everything works fine for me except when creating an account... "My address" is created but now "Shippind address".. then prestashop cant find any carrier because they dont have any Shipping address.. just "my adress".

Link to comment
Share on other sites

Hey man!

Everything works fine for me except when creating an account... "My address" is created but now "Shippind address".. then prestashop cant find any carrier because they dont have any Shipping address.. just "my adress".

 

although

hi there:

 

Problem is only exist when Enable Guest Checkout function. Otherwise it works fine.

 

I am using 1.5.3.1 , After click check out. I am set up as one page check out option from BO.,

If I choose the Instant Checkout. After I fill up all details and save.

 

The Carriers are not showing on the bottom and Says:

 

No carriers available for the address "My address".

 

Please see test in my website. www.fancychannel.com

 

 

Please help on how to fix the problem.

 

I have set up all the Price range and Weight Range.Carrier details, Turn Off Advanced Stock Mamagement,

 

The weight range is like 0-0.1kg, 0.1kg -0.2kg, 0kg-1kg,............

 

Price Range set all carrier from $0.00 to US $100,000.00.

 

Registration process type : Only Account Creation.

 

Please help! Thanks in advance.

 

hmm but now it just works.. eeh..

Link to comment
Share on other sites

  • 4 weeks later...

I had this problem trying to setup USPS and UPS.

 

Here's what I did to fix it:

 

1. Reset the USPS and UPS modules.

 

2. Set them up again with my account info, api key, etc.

 

NOW: Here's the important part:

 

Do NOT setup Price Ranges or Weight Ranges at this point. The default ranges are universal.

 

Do NOT setup shipping for individual products or categories. The defaults are universal.

 

Verify that you can see the shipping options for your chosen carriers in the check out. The Shipping Estimator module is handy in this regard because it allows you to easily test shipping addresses and products in cart to see that it is working.

 

If you cannot see the various shipping options, make sure that you have shipping options selected that are compatible with the dimensions, weight, and packaging you have set for the carrier, shipping methods and the products.

 

NOW: Once you have successfully gotten the carriers and shipping methods working (displaying, calculating, etc.), you can setup Price Ranges, Weight Ranges, specific shipping types for individual products or categories, limit which countries can use which shipping method, etc.

 

WHY: The Price Ranges, Weight Ranges, and shipping options for individual categories and products are used to LIMIT the shipping options to make them more accurate. (You can't ship a 40 lb television in a USPS Flat Rate Box!)

 

LESSON: If you choose incompatible options, your carrier and shipping methods will not display or calculate. So, get the SIMPLEST possible configuration for each carrier working and then set the options that limit the carriers and methods.

Edited by hostricity (see edit history)
Link to comment
Share on other sites

What if you don't what to enable all the countries, I only want to enable North America?

Will the system require that I enable all the countries?

 

Edit: After 2 hours, I found a setting that corrected the issue.

Here is a video I made for a client:

http://www.youtube.com/watch?v=cKF2KdoojCA

 

MAN I CREATED AN ACCOUNT JUST TO THANK YOU! YOU REALLY HELPED ME THERE MAN. GOD BLESS!

Link to comment
Share on other sites

  • 6 months later...

I've had a the same problem upon check out via Instant Checkout.

 

what you need to do is set the carrier group access to check the guest and visitor option.

 

Step by step solutions :

http://www.unblockwww.com/solved/prestashop-error-there-are-no-carriers-that-deliver-to-the-address-you-selected/

 

thanks

Edited by entrancey (see edit history)
Link to comment
Share on other sites

  • 2 months later...

I have tried all of your solutions above and I am still having issues with my shopping cart in the delivery methods area. I have UPS ground entered as free freight. However it does not show up in the delivery method area and and error at the bottom of the page says (Error: None of your chosen carriers deliver to the address you've selected.)

 

But the address is a valid address. Has anyone else ran into this problem and do I solve it?

 

I have the one page check out selected and enabled. I have the same issue if i switch to the 5 step check out.

 

Any help or solves on this issue is greatly appreciated.

Link to comment
Share on other sites

  • 1 year later...
  • 1 year later...

After spending sometime, finally I figured out the exact issue. The problem was with carries configuration. Go to shipping >carries then select the carrier and click on 'edit'.

 

Then select on tab 'shipping location and costs' , and then select the proper region of your country and save it.

 

Best regards,

Tanveer

Link to comment
Share on other sites

Strict standards: Declaration of Carrier::getAvailableCarrierList() should be compatible with CarrierCore::getAvailableCarrierList(Product $product, $id_warehouse, $id_address_delivery = NULL, $id_shop = NULL, $cart = NULL, &$error = Array) in /var/www/html/cy_prestashop/override/classes/Carrier.php on line 95

 

How to resolve this problem.

Link to comment
Share on other sites

Strict standards: Declaration of Carrier::getAvailableCarrierList() should be compatible with CarrierCore::getAvailableCarrierList(Product $product, $id_warehouse, $id_address_delivery = NULL, $id_shop = NULL, $cart = NULL, &$error = Array) in /var/www/html/cy_prestashop/override/classes/Carrier.php on line 95

 

How to resolve this problem.

 

You have some old override of Carrier.php class installed, which contains method getAvailableCarrierList with different signature (parameters) than the core one. You could edit file override/classes/Carrier.php, locate this method and modify the signature to match the signature of function in /classes/Carrier.php.

 

But first, you should find out why you have this override, what is its purpose. You may find out you don't need it anymore, then simple get rid of it.

Link to comment
Share on other sites

I am migrated prestashop version 1.5.6 to 1.6.1.15. 

 

In older version prestashop 1.5.6. I saw classes/carrier.php file inside getAvailableCarrierList() method then check module/ups/overrride_1.5/classes/carrier.php file inside i found same method such as getAvailableCarrierList().
 
Both getAvailableCarrierList() coding is same so any error message does not appear.
 
Ex:
 

prestashop/Classes/Carrier.php 

 

public static function getAvailableCarrierList(Product $product, $id_warehouse, $id_address_delivery = null, $id_shop = null, $cart = null)
{
if (is_null($id_shop))
$id_shop = Context::getContext()->shop->id;
if (is_null($cart))
$cart = Context::getContext()->cart;
 
$id_address = (int)((!is_null($id_address_delivery) && $id_address_delivery != 0) ? $id_address_delivery :  $cart->id_address_delivery);
if ($id_address)
{
$address = new Address($id_address);
$id_zone = Address::getZoneById($address->id);
 
// Check the country of the address is activated
if (!Address::isCountryActiveById($address->id))
return array();
}
else
{
$country = new Country(Configuration::get('PS_COUNTRY_DEFAULT'));
$id_zone = $country->id_zone;
}
 
// Does the product is linked with carriers?
$query = new DbQuery();
$query->select('id_carrier');
$query->from('product_carrier', 'pc');
$query->innerJoin('carrier', 'c', 'c.id_reference = pc.id_carrier_reference AND c.deleted = 0');
$query->where('pc.id_product = '.(int)$product->id);
$query->where('pc.id_shop = '.(int)$id_shop);
 
$cache_id = 'Carrier::getAvailableCarrierList_'.(int)$product->id.'-'.(int)$id_shop;
if (!Cache::isStored($cache_id))
{
$carriers_for_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
Cache::store($cache_id, $carriers_for_product);
}
$carriers_for_product = Cache::retrieve($cache_id);
 
$carrier_list = array();
if (!empty($carriers_for_product))
{
//the product is linked with carriers
foreach ($carriers_for_product as $carrier) //check if the linked carriers are available in current zone
if (Carrier::checkCarrierZone($carrier['id_carrier'], $id_zone))
$carrier_list[] = $carrier['id_carrier'];
if (empty($carrier_list))
return array();//no linked carrier are available for this zone
}
 
// The product is not dirrectly linked with a carrier
// Get all the carriers linked to a warehouse
if ($id_warehouse)
{
$warehouse = new Warehouse($id_warehouse);
$warehouse_carrier_list = $warehouse->getCarriers();
}
 
$available_carrier_list = array();
$customer = new Customer($cart->id_customer);
$carriers = Carrier::getCarriersForOrder($id_zone, $customer->getGroups(), $cart);
 
foreach ($carriers as $carrier)
$available_carrier_list[] = $carrier['id_carrier'];
 
if ($carrier_list)
$carrier_list = array_intersect($available_carrier_list, $carrier_list);
else
$carrier_list = $available_carrier_list;
 
if (isset($warehouse_carrier_list))
$carrier_list = array_intersect($carrier_list, $warehouse_carrier_list);
 
if ($product->width > 0 || $product->height > 0 || $product->depth > 0 || $product->weight > 0)
{
foreach ($carrier_list as $key => $id_carrier)
{
$carrier = new Carrier($id_carrier);
if (($carrier->max_width > 0 && $carrier->max_width < $product->width)
|| ($carrier->max_height > 0 && $carrier->max_height < $product->height)
|| ($carrier->max_depth > 0 && $carrier->max_depth < $product->depth)
|| ($carrier->max_weight > 0 && $carrier->max_weight < $product->weight))
unset($carrier_list[$key]);
}
}
return $carrier_list;
}

 

 

prestashop/modules/ups/override_1.5/classes/Carrier.php

 

public static function getAvailableCarrierList(Product $product, $id_warehouse, $id_address_delivery = null, $id_shop = null, $cart = null)
{
if (is_null($id_shop))
$id_shop = Context::getContext()->shop->id;
if (is_null($cart))
$cart = Context::getContext()->cart;
 
$id_address = (int)((!is_null($id_address_delivery) && $id_address_delivery != 0) ? $id_address_delivery :  $cart->id_address_delivery);
if ($id_address)
{
$address = new Address($id_address);
$id_zone = Address::getZoneById($address->id);
 
// Check the country of the address is activated
if (!Address::isCountryActiveById($address->id))
return array();
}
else
{
// changed for Presto-Changeo carrier modules --->
$cookie = Context::getContext()->cookie;
$cookie_country = $cookie->id_country ? $cookie->id_country : $cookie->pc_dest_country;
$country = new Country((isset($cookie_country) && strlen($cookie_country) ? $cookie_country : Configuration::get('PS_COUNTRY_DEFAULT')));
// <--- changed for Presto-Changeo carrier modules
$id_zone = $country->id_zone;
}
 
// Does the product is linked with carriers?
$query = new DbQuery();
$query->select('id_carrier');
$query->from('product_carrier', 'pc');
$query->innerJoin('carrier', 'c', 'c.id_reference = pc.id_carrier_reference AND c.deleted = 0');
$query->where('pc.id_product = '.(int)$product->id);
$query->where('pc.id_shop = '.(int)$id_shop);
 
$cache_id = 'Carrier::getAvailableCarrierList_'.(int)$product->id.'-'.(int)$id_shop;
if (!Cache::isStored($cache_id))
{
$carriers_for_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
Cache::store($cache_id, $carriers_for_product);
}
$carriers_for_product = Cache::retrieve($cache_id);
$carrier_list = array();
if (!empty($carriers_for_product))
{
//the product is linked with carriers
foreach ($carriers_for_product as $carrier) //check if the linked carriers are available in current zone
if (Carrier::checkCarrierZone($carrier['id_carrier'], $id_zone))
$carrier_list[] = $carrier['id_carrier'];
if (empty($carrier_list))
return array();//no linked carrier are available for this zone
}
 
// The product is not dirrectly linked with a carrier
// Get all the carriers linked to a warehouse
if ($id_warehouse)
{
$warehouse = new Warehouse($id_warehouse);
$warehouse_carrier_list = $warehouse->getCarriers();
}
 
$available_carrier_list = array();
$customer = new Customer($cart->id_customer);
$carriers = Carrier::getCarriersForOrder($id_zone, $customer->getGroups(), $cart);
 
foreach ($carriers as $carrier)
$available_carrier_list[] = $carrier['id_carrier'];
 
if ($carrier_list)
$carrier_list = array_intersect($available_carrier_list, $carrier_list);
else
$carrier_list = $available_carrier_list;
 
if (isset($warehouse_carrier_list))
$carrier_list = array_intersect($carrier_list, $warehouse_carrier_list);
 
if ($product->width > 0 || $product->height > 0 || $product->depth > 0 || $product->weight > 0)
{
foreach ($carrier_list as $key => $id_carrier)
{
$carrier = new Carrier($id_carrier);
if (($carrier->max_width > 0 && $carrier->max_width < $product->width)
|| ($carrier->max_height > 0 && $carrier->max_height < $product->height)
|| ($carrier->max_depth > 0 && $carrier->max_depth < $product->depth)
|| ($carrier->max_weight > 0 && $carrier->max_weight < $product->weight))
unset($carrier_list[$key]);
}
}
return $carrier_list;
}
}
 
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
Now i am checking prestashop version 1.6.1.15 I saw classes/carrier.php file inside getAvailableCarrierList() method then check module/ups/overrride_1.6/classes/carrier.php file inside i found same method such as getAvailableCarrierList().
 
Both getAvailableCarrierList() coding are different. How to resolve it.
 
Ex:
 
Classes/Carrier.php:
 
public static function getAvailableCarrierList(Product $product, $id_warehouse, $id_address_delivery = null, $id_shop = null, $cart = null, &$error = array())
    {
        static $ps_country_default = null;
 
        if ($ps_country_default === null) {
            $ps_country_default = Configuration::get('PS_COUNTRY_DEFAULT');
        }
 
        if (is_null($id_shop)) {
            $id_shop = Context::getContext()->shop->id;
        }
        if (is_null($cart)) {
            $cart = Context::getContext()->cart;
        }
 
        if (is_null($error) || !is_array($error)) {
            $error = array();
        }
 
        $id_address = (int)((!is_null($id_address_delivery) && $id_address_delivery != 0) ? $id_address_delivery :  $cart->id_address_delivery);
        if ($id_address) {
            $id_zone = Address::getZoneById($id_address);
 
            // Check the country of the address is activated
            if (!Address::isCountryActiveById($id_address)) {
                return array();
            }
        } else {
            $country = new Country($ps_country_default);
            $id_zone = $country->id_zone;
        }
 
        // Does the product is linked with carriers?
        $cache_id = 'Carrier::getAvailableCarrierList_'.(int)$product->id.'-'.(int)$id_shop;
        if (!Cache::isStored($cache_id)) {
            $query = new DbQuery();
            $query->select('id_carrier');
            $query->from('product_carrier', 'pc');
            $query->innerJoin(
                'carrier',
                'c',
                'c.id_reference = pc.id_carrier_reference AND c.deleted = 0 AND c.active = 1'
            );
            $query->where('pc.id_product = '.(int)$product->id);
            $query->where('pc.id_shop = '.(int)$id_shop);
 
            $carriers_for_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
            Cache::store($cache_id, $carriers_for_product);
        } else {
            $carriers_for_product = Cache::retrieve($cache_id);
        }
 
        $carrier_list = array();
        if (!empty($carriers_for_product)) {
            //the product is linked with carriers
            foreach ($carriers_for_product as $carrier) { //check if the linked carriers are available in current zone
                if (Carrier::checkCarrierZone($carrier['id_carrier'], $id_zone)) {
                    $carrier_list[$carrier['id_carrier']] = $carrier['id_carrier'];
                }
            }
            if (empty($carrier_list)) {
                return array();
            }//no linked carrier are available for this zone
        }
 
        // The product is not dirrectly linked with a carrier
        // Get all the carriers linked to a warehouse
        if ($id_warehouse) {
            $warehouse = new Warehouse($id_warehouse);
            $warehouse_carrier_list = $warehouse->getCarriers();
        }
 
        $available_carrier_list = array();
        $cache_id = 'Carrier::getAvailableCarrierList_getCarriersForOrder_'.(int)$id_zone.'-'.(int)$cart->id;
        if (!Cache::isStored($cache_id)) {
            $customer = new Customer($cart->id_customer);
            $carrier_error = array();
            $carriers = Carrier::getCarriersForOrder($id_zone, $customer->getGroups(), $cart, $carrier_error);
            Cache::store($cache_id, array($carriers, $carrier_error));
        } else {
            list($carriers, $carrier_error) = Cache::retrieve($cache_id);
        }
 
        $error = array_merge($error, $carrier_error);
 
        foreach ($carriers as $carrier) {
            $available_carrier_list[$carrier['id_carrier']] = $carrier['id_carrier'];
        }
 
        if ($carrier_list) {
            $carrier_list = array_intersect($available_carrier_list, $carrier_list);
        } else {
            $carrier_list = $available_carrier_list;
        }
 
        if (isset($warehouse_carrier_list)) {
            $carrier_list = array_intersect($carrier_list, $warehouse_carrier_list);
        }
 
        $cart_quantity = 0;
        $cart_weight = 0;
 
        foreach ($cart->getProducts(false, false) as $cart_product) {
            if ($cart_product['id_product'] == $product->id) {
                $cart_quantity += $cart_product['cart_quantity'];
            }
            if (isset($cart_product['weight_attribute']) && $cart_product['weight_attribute'] > 0) {
                $cart_weight += ($cart_product['weight_attribute'] * $cart_product['cart_quantity']);
            } else {
                $cart_weight += ($cart_product['weight'] * $cart_product['cart_quantity']);
            }
        }
 
        if ($product->width > 0 || $product->height > 0 || $product->depth > 0 || $product->weight > 0 || $cart_weight > 0) {
            foreach ($carrier_list as $key => $id_carrier) {
                $carrier = new Carrier($id_carrier);
 
                // Get the sizes of the carrier and the product and sort them to check if the carrier can take the product.
                $carrier_sizes = array((int)$carrier->max_width, (int)$carrier->max_height, (int)$carrier->max_depth);
                $product_sizes = array((int)$product->width, (int)$product->height, (int)$product->depth);
                rsort($carrier_sizes, SORT_NUMERIC);
                rsort($product_sizes, SORT_NUMERIC);
 
                if (($carrier_sizes[0] > 0 && $carrier_sizes[0] < $product_sizes[0])
                    || ($carrier_sizes[1] > 0 && $carrier_sizes[1] < $product_sizes[1])
                    || ($carrier_sizes[2] > 0 && $carrier_sizes[2] < $product_sizes[2])) {
                    $error[$carrier->id] = Carrier::SHIPPING_SIZE_EXCEPTION;
                    unset($carrier_list[$key]);
                }
 
                if ($carrier->max_weight > 0 && ($carrier->max_weight < $product->weight * $cart_quantity || $carrier->max_weight < $cart_weight)) {
                    $error[$carrier->id] = Carrier::SHIPPING_WEIGHT_EXCEPTION;
                    unset($carrier_list[$key]);
                }
            }
        }
        return $carrier_list;
    }
 

modules/ups/override_1.6/classes/Carrier.php:

 

public static function getAvailableCarrierList(Product $product, $id_warehouse, $id_address_delivery = null, $id_shop = null, $cart = null)
    {
        if (is_null($id_shop))
            $id_shop = Context::getContext()->shop->id;
        if (is_null($cart))
            $cart = Context::getContext()->cart;
 
        $id_address = (int)((!is_null($id_address_delivery) && $id_address_delivery != 0) ? $id_address_delivery :  $cart->id_address_delivery);
        if ($id_address)
        {
            $address = new Address($id_address);
            $id_zone = Address::getZoneById($address->id);
 
            // Check the country of the address is activated
            if (!Address::isCountryActiveById($address->id))
                return array();
        }
        else
        {
            // changed for Presto-Changeo carrier modules --->
            $cookie = Context::getContext()->cookie;
            $cookie_country = $cookie->id_country ? $cookie->id_country : $cookie->pc_dest_country;
            $country = new Country((isset($cookie_country) && strlen($cookie_country) ? $cookie_country : Configuration::get('PS_COUNTRY_DEFAULT')));
            // <--- changed for Presto-Changeo carrier modules
            $id_zone = $country->id_zone;
        }
 
        // Does the product is linked with carriers?
        $query = new DbQuery();
        $query->select('id_carrier');
        $query->from('product_carrier', 'pc');
        $query->innerJoin('carrier', 'c', 'c.id_reference = pc.id_carrier_reference AND c.deleted = 0');
        $query->where('pc.id_product = '.(int)$product->id);
        $query->where('pc.id_shop = '.(int)$id_shop);
 
        $cache_id = 'Carrier::getAvailableCarrierList_'.(int)$product->id.'-'.(int)$id_shop;
        if (!Cache::isStored($cache_id))
        {
            $carriers_for_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
            Cache::store($cache_id, $carriers_for_product);
        }
        $carriers_for_product = Cache::retrieve($cache_id);
        $carrier_list = array();
        if (!empty($carriers_for_product))
        {
            //the product is linked with carriers
            foreach ($carriers_for_product as $carrier) //check if the linked carriers are available in current zone
                if (Carrier::checkCarrierZone($carrier['id_carrier'], $id_zone))
                    $carrier_list[] = $carrier['id_carrier'];
            if (empty($carrier_list))
                return array();//no linked carrier are available for this zone
        }
 
        // The product is not dirrectly linked with a carrier
        // Get all the carriers linked to a warehouse
        if ($id_warehouse)
        {
            $warehouse = new Warehouse($id_warehouse);
            $warehouse_carrier_list = $warehouse->getCarriers();
        }
 
        $available_carrier_list = array();
        $customer = new Customer($cart->id_customer);
        $carriers = Carrier::getCarriersForOrder($id_zone, $customer->getGroups(), $cart);
 
        foreach ($carriers as $carrier)
            $available_carrier_list[] = $carrier['id_carrier'];
 
        if ($carrier_list)
            $carrier_list = array_intersect($available_carrier_list, $carrier_list);
        else
            $carrier_list = $available_carrier_list;
 
        if (isset($warehouse_carrier_list))
            $carrier_list = array_intersect($carrier_list, $warehouse_carrier_list);
 
        if ($product->width > 0 || $product->height > 0 || $product->depth > 0 || $product->weight > 0)
        {
            foreach ($carrier_list as $key => $id_carrier)
            {
                $carrier = new Carrier($id_carrier);
                if (($carrier->max_width > 0 && $carrier->max_width < $product->width)
                    || ($carrier->max_height > 0 && $carrier->max_height < $product->height)
                    || ($carrier->max_depth > 0 && $carrier->max_depth < $product->depth)
                    || ($carrier->max_weight > 0 && $carrier->max_weight < $product->weight))
                    unset($carrier_list[$key]);
            }
        }
        return $carrier_list;
    }
Edited by kirubanidhi (see edit history)
Link to comment
Share on other sites

In older version prestashop 1.5.6. 

I saw classes/carrier.php file inside getAvailableCarrierList() method then check module/ups/overrride_1.5/classes/carrier.php file inside i found same method such as getAvailableCarrierList(). Both getAvailableCarrierList() method and their arguments are same.

 

Now i am checking prestashop version 1.6.1.15. 

I saw classes/carrier.php file inside getAvailableCarrierList() method then check module/ups/overrride_1.6/classes/carrier.php file inside i found same method such as getAvailableCarrierList(). Both getAvailableCarrierList() method and their arguments are different.

 

Please give me correct solution of this problem.

Edited by kirubanidhi (see edit history)
Link to comment
Share on other sites

In older version prestashop 1.5.6. 

 

I saw classes/carrier.php file inside getAvailableCarrierList() method then check module/ups/overrride_1.5/classes/carrier.php file inside i found same method such as getAvailableCarrierList().

 

Both getAvailableCarrierList() coding is same so any error message does not appear.

 

 

Well, we have 4 versions of the method here.

 

First, let's compare 1.5 core version with 1.5 override version:

 

diff-version-1-5.png

 

There are three new lines here. These lines are the reason why this override exists.

 

Now, let's compare overrides between 1.5 and 1.6 versions. Surprisingly, the content is same. Even though code in 1.6 version has changed.

 

I suggest this - copy code from 1.6 version to override, and manually insert those few lines in the right place. The result will look like this (I haven't tested it, though)

// core 1.6
public static function getAvailableCarrierList(Product $product, $id_warehouse, $id_address_delivery = null, $id_shop = null, $cart = null, &$error = array())
{
	static $ps_country_default = null;

	if ($ps_country_default === null) {
		$ps_country_default = Configuration::get('PS_COUNTRY_DEFAULT');
	}

	if (is_null($id_shop)) {
		$id_shop = Context::getContext()->shop->id;
	}
	if (is_null($cart)) {
		$cart = Context::getContext()->cart;
	}

	if (is_null($error) || !is_array($error)) {
		$error = array();
	}

	$id_address = (int)((!is_null($id_address_delivery) && $id_address_delivery != 0) ? $id_address_delivery :  $cart->id_address_delivery);
	if ($id_address) {
		$id_zone = Address::getZoneById($id_address);

		// Check the country of the address is activated
		if (!Address::isCountryActiveById($id_address)) {
			return array();
		}
	} else {
		// ******************************* changed for Presto-Changeo carrier modules --->
		$cookie = Context::getContext()->cookie;
		$cookie_country = $cookie->id_country ? $cookie->id_country : $cookie->pc_dest_country;
		$country = new Country((isset($cookie_country) && strlen($cookie_country) ? $cookie_country : $ps_country_default));
		// ******************************* <--- changed for Presto-Changeo carrier modules
		$id_zone = $country->id_zone;
	}

	// Does the product is linked with carriers?
	$cache_id = 'Carrier::getAvailableCarrierList_'.(int)$product->id.'-'.(int)$id_shop;
	if (!Cache::isStored($cache_id)) {
		$query = new DbQuery();
		$query->select('id_carrier');
		$query->from('product_carrier', 'pc');
		$query->innerJoin(
			'carrier',
			'c',
			'c.id_reference = pc.id_carrier_reference AND c.deleted = 0 AND c.active = 1'
		);
		$query->where('pc.id_product = '.(int)$product->id);
		$query->where('pc.id_shop = '.(int)$id_shop);

		$carriers_for_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
		Cache::store($cache_id, $carriers_for_product);
	} else {
		$carriers_for_product = Cache::retrieve($cache_id);
	}

	$carrier_list = array();
	if (!empty($carriers_for_product)) {
		//the product is linked with carriers
		foreach ($carriers_for_product as $carrier) { //check if the linked carriers are available in current zone
			if (Carrier::checkCarrierZone($carrier['id_carrier'], $id_zone)) {
				$carrier_list[$carrier['id_carrier']] = $carrier['id_carrier'];
			}
		}
		if (empty($carrier_list)) {
			return array();
		}//no linked carrier are available for this zone
	}

	// The product is not dirrectly linked with a carrier
	// Get all the carriers linked to a warehouse
	if ($id_warehouse) {
		$warehouse = new Warehouse($id_warehouse);
		$warehouse_carrier_list = $warehouse->getCarriers();
	}

	$available_carrier_list = array();
	$cache_id = 'Carrier::getAvailableCarrierList_getCarriersForOrder_'.(int)$id_zone.'-'.(int)$cart->id;
	if (!Cache::isStored($cache_id)) {
		$customer = new Customer($cart->id_customer);
		$carrier_error = array();
		$carriers = Carrier::getCarriersForOrder($id_zone, $customer->getGroups(), $cart, $carrier_error);
		Cache::store($cache_id, array($carriers, $carrier_error));
	} else {
		list($carriers, $carrier_error) = Cache::retrieve($cache_id);
	}

	$error = array_merge($error, $carrier_error);

	foreach ($carriers as $carrier) {
		$available_carrier_list[$carrier['id_carrier']] = $carrier['id_carrier'];
	}

	if ($carrier_list) {
		$carrier_list = array_intersect($available_carrier_list, $carrier_list);
	} else {
		$carrier_list = $available_carrier_list;
	}

	if (isset($warehouse_carrier_list)) {
		$carrier_list = array_intersect($carrier_list, $warehouse_carrier_list);
	}

	$cart_quantity = 0;
	$cart_weight = 0;

	foreach ($cart->getProducts(false, false) as $cart_product) {
		if ($cart_product['id_product'] == $product->id) {
			$cart_quantity += $cart_product['cart_quantity'];
		}
		if (isset($cart_product['weight_attribute']) && $cart_product['weight_attribute'] > 0) {
			$cart_weight += ($cart_product['weight_attribute'] * $cart_product['cart_quantity']);
		} else {
			$cart_weight += ($cart_product['weight'] * $cart_product['cart_quantity']);
		}
	}

	if ($product->width > 0 || $product->height > 0 || $product->depth > 0 || $product->weight > 0 || $cart_weight > 0) {
		foreach ($carrier_list as $key => $id_carrier) {
			$carrier = new Carrier($id_carrier);

			// Get the sizes of the carrier and the product and sort them to check if the carrier can take the product.
			$carrier_sizes = array((int)$carrier->max_width, (int)$carrier->max_height, (int)$carrier->max_depth);
			$product_sizes = array((int)$product->width, (int)$product->height, (int)$product->depth);
			rsort($carrier_sizes, SORT_NUMERIC);
			rsort($product_sizes, SORT_NUMERIC);

			if (($carrier_sizes[0] > 0 && $carrier_sizes[0] < $product_sizes[0])
				|| ($carrier_sizes[1] > 0 && $carrier_sizes[1] < $product_sizes[1])
				|| ($carrier_sizes[2] > 0 && $carrier_sizes[2] < $product_sizes[2])) {
				$error[$carrier->id] = Carrier::SHIPPING_SIZE_EXCEPTION;
				unset($carrier_list[$key]);
			}

			if ($carrier->max_weight > 0 && ($carrier->max_weight < $product->weight * $cart_quantity || $carrier->max_weight < $cart_weight)) {
				$error[$carrier->id] = Carrier::SHIPPING_WEIGHT_EXCEPTION;
				unset($carrier_list[$key]);
			}
		}
	}
	return $carrier_list;
}
 

 This should have been fixed by module creator, btw.

 

Good luck

Edited by DataKick (see edit history)
Link to comment
Share on other sites

 

 
Okay thanks you,
 
Are you saying, copy getAvailableCarrierList() method code from classes/Carrier.php file and pasted it to override1.6/Classes/Carrier.php file inside.

 

 

yes, and then extend the copied method by adding those few lines

Link to comment
Share on other sites

Okay, 

 

I do it. Shall i add below code in override/classes/Carrier.php file,

 

 $cookie = Context::getContext()->cookie;
 $cookie_country = $cookie->id_country ? $cookie->id_country : $cookie->pc_dest_country;
 $country = new Country((isset($cookie_country) && strlen($cookie_country) ? $cookie_country : Configuration::get('PS_COUNTRY_DEFAULT')));
Link to comment
Share on other sites

×
×
  • Create New...