Prestashop: [BOOM-5223] Carriers list to enter a tracking number shows only those enabled for visitors

Created on 22 Aug 2018  ·  13Comments  ·  Source: PrestaShop/PrestaShop

This issue has been migrated from the Forge. Read the original ticket here.

  • _Reporter:_ Paolo
  • _Created at:_ Fri, 30 Mar 2018 19:54:31 +0200

When modifying an order from backoffice to enter tracking information, the list of carriers shows only those enabled for visitors. Function getCarrierList() in AdminOrdersController should consider not only the country of the customer but its group too.

Configuration parameter PS_UNIDENTIFIED_GROUP can change this behavior, but what if we want to leave access to carriers only to guests and registered users?

  • How to reproduce the issue ?

Create a carrier with group access => Visitor


Create a carrier with group access => Guest / Customer


Go to FO => add products to the cart as a visitor => to complete the order => create a new customer => process checkout


Go to BO => edit the order created => edit the shipping details => the list of carriers show only carriers configured for visitor and not for Guest / Customer

1.7.3.0 1.7.4.2 Bug Carriers Fixed Minor Order

All 13 comments

This comment has been migrated from the Forge. Read the original comment here.

  • _Author:_ khouloud.belguith
  • _Created at:_ Mon, 2 Apr 2018 11:56:22 +0200

Hi Paolo,

I did not manage to reproduce the issue with PS version 1.7.3.0.
I attached screenshots, thanks to check and feedback.

Best regards,
Khouloud

This comment has been migrated from the Forge. Read the original comment here.

  • _Author:_ paolo
  • _Created at:_ Wed, 4 Apr 2018 10:09:22 +0200

Hi Khouloud.

Here's my situation. Picture one shows the list of carriers we defined.

As we don't want visitors to have inaccurate information about shipping cost, we have a fake courier, "No shipping cost for visitors", enabled to visitors only, with free shipping (it will show "depending on destination" as shipping cost when filling the order).

Then we have "couriers" defining shipping costs for zones. These are enabled for guests and customers only.

With this situation, picture 2 shows the result: when we edit tracking information, the drop down list shows only the fake courier for visitor, while it should show a list of couriers for guests or customers (this test order was created with a registered user).

This comes from the use of function Carrier::getCarriersForOrder, that is called with group parameter null in function getCarrierList, module AdminOrdersController.php. As group parameter is null, getCarriersForOrder will use only PS_UNIDENTIFIED_GROUP as group, therefore visitor. I think it should use the group of the customer who placed the order, instead of being called with a null parameter.

We solved this by adding a real courier definition (DHL, for example, at the bottom of picture 1) to be used just to provide tracking information upon shipment. We also defined a new group ("couriers"), enabled for this new courier definition only.

Modifying getCarrierList function line from

return Carrier::getCarriersForOrder(Address::getZoneById((int) $address->id), null, $cart);

to

return Carrier::getCarriersForOrder(Address::getZoneById((int) $address->id), array(4), $cart);

(where '4' is the id of the new couriers group) it does what we need, as in picture 3.

Best regards,

 

Paolo

 

This comment has been migrated from the Forge. Read the original comment here.

  • _Author:_ khouloud.belguith
  • _Created at:_ Wed, 4 Apr 2018 13:43:48 +0200

Hi Paolo,

How could you create an order with a customer in a visitor group?

Best regards, Khouloud

This comment has been migrated from the Forge. Read the original comment here.

  • _Author:_ paolo
  • _Created at:_ Wed, 4 Apr 2018 14:41:48 +0200

Hi!

We can add products to the cart as visitors, but we need to checkout as guest or registered customer. No shipping cost is shown to visitors until they provide address information.

Paolo

This comment has been migrated from the Forge. Read the original comment here.

  • _Author:_ khouloud.belguith
  • _Created at:_ Wed, 4 Apr 2018 15:31:44 +0200

Hi Paolo,

I manage to reproduce the issue following this steps :
Create a free carrier with group access => Visitor
Create a carrier (not free) with group access => Guest / Customer
Go to FO => add products to the cart as a visitor => to complete the order => create a new customer => process checkout
Go to BO => edit the order created => edit the shipping details => the list of carriers is empty

PS: tested when Tracking URL for all the carriers empty or not.
We will see how to fix it.

Best regards, Khouloud

This comment has been migrated from the Forge. Read the original comment here.

  • _Author:_ paolo
  • _Created at:_ Wed, 4 Apr 2018 16:35:25 +0200

Thank you for your time in checking on this, Khouloud.

As I wrote above, the function getCarrierList may just consider in which group was the customer when he entered the order, and pass it to getCarriersForOrder instead of null (didn't test this myself...)

Have a great day,

Paolo

This comment has been migrated from the Forge. Read the original comment here.

  • _Author:_ marion_francois
  • _Created at:_ Thu, 5 Apr 2018 11:18:33 +0200

Salut Khouloud BELGUITH

Je n'arrive pas à reproduire le problème avec le scénario que tu décris
La liste des transporteurs est bien remplie
Peux-tu me dire si je n'ai pas loupé quelque chose: 

https://drive.google.com/open?id=12rudDc2OHD5VPgdSVini7ggGx9eIJMTA

Merci

This comment has been migrated from the Forge. Read the original comment here.

  • _Author:_ khouloud.belguith
  • _Created at:_ Thu, 5 Apr 2018 12:14:53 +0200

Salut Marion F,

Je n'ai pas utilisé les transporteurs par défaut de PrestaShop.
J'ai créé deux nouveaux transporteurs avec les caratéristiques spécifiés.
Apr 5 2018 11_09 AM.webm

Merci

This comment has been migrated from the Forge. Read the original comment here.

  • _Author:_ marion_francois
  • _Created at:_ Thu, 5 Apr 2018 13:51:06 +0200

I can reproduce the issue described by Paolo this way:

Create a carrier with group access => Visitor
Create a carrier with group access => Guest / Customer
Go to FO => add products to the cart as a visitor => to complete the order => create a new customer => process checkout
Go to BO => edit the order created => edit the shipping details => the list of carriers show only carriers configured for visitor and not for Guest / Customer

Hi, I'm experiencing the same exact issue.

Alright, this is the fix:

AdminOrderController.php line 3019

Method should retrieve customer's groups and passing them to the getCarriersForOrder static function:

    /**
     * Get available carrier list for an order
     * @param Object $order
     * @return array $delivery_option_list_formated
     */
    protected function getCarrierList($order)
    {
        $cart = $this->context->cart;
        $id_customer = $cart->id_customer;
        $groups = Customer::getGroupsStatic($id_customer);
        $address = new Address((int) $cart->id_address_delivery);
        return Carrier::getCarriersForOrder(Address::getZoneById((int) $address->id), $groups, $cart);
    }

I'm going to open a merge request on that.

Hi @manfield,

Thanks for your fix.

Hi @khouloudbelguith, this merge request:
https://github.com/PrestaShop/PrestaShop/pull/11256

is not yet assigned. Just to make you know ;)

Was this page helpful?
0 / 5 - 0 ratings