shoppingflux / shoppingfluxexport

7 stars 7 forks source link

Mondial Relay ID management (And "Rue Du Commerce" specific case) #392

Closed ghost closed 5 years ago

ghost commented 6 years ago

Expected behaviour

It should be possible to automatically set the relay ID when using Mondial Relay in the ShippingMethod.

As well specific cases, such as Rue Du Commerce should be managed. Rue Du Commerce is not storing the relay ID in the field Other, but is instead concatenating the Relay ID in the ShippingMethod, such as : Livraison en point de proximité avec Mondial Relay (2-3 jours) XYZ where XYZ is the Relay ID.

Actual behaviour

The relay ID is not correctly saved by setMondialRelayData() function. As well specific case for Rue Du Commerce is not managed.

Steps to reproduce the behaviour

Create an order with Mondial Relay in the ShippingMethod

ghost commented 6 years ago

I started some adjustments in a branch in my repo with some preliminary work: https://github.com/shoppingflux/shoppingfluxexport/compare/dev...infiniweb:mondialrelay Being tested.

ghost commented 6 years ago

Depending of the marketplace, the length of the relay ID is not the same. (5 digits, 6 digits). However MondialRelay required 6 digits.

To be added in the next commit:

                $lengthRelayId = strlen($idRelay);
                while ($lengthRelayId !== 6) {
                    $idRelay = "0".$idRelay;
                    $lengthRelayId = strlen($idRelay);
                }
                $idRelayFormatted = $idRelay;
ghost commented 5 years ago

It seems that there is an issue with the Order object that is cached and not returning correct information when used in setMondialRelayData function to retrieve the related carrier.

Therefore the following piece of code should be used to clear the Order cache before calling the setMondialRelayData function and after calling the _updatePrices function.

    $orderClear = new Order();
    if (method_exists($orderClear, 'clearCache')) {
        $orderClear->clearCache(true);
    }