PrestaShopCorp / chronopost

5 stars 13 forks source link

carrier id changed : can't create waybill #27

Open SebSept opened 9 years ago

SebSept commented 9 years ago

If we change the carrier details in admin, the carrier id changes. Module config values are updated, than fine ( chronopost.php#L514 ) but there is now problem while viewing a command to print the waybill (l'étiquette a imprimer et coller quoi! ;) ), we can no more print it in previous order because isChrono now return false.

SebSept commented 9 years ago

Maybe we can :

What's better ?

francoisfeugeas commented 8 years ago

Hi @SebSept

A new way of working with carrier is implemented in the upcoming 3.8 version, which I'll encourage you to check out : https://github.com/francoisfeugeas/chronopost

It's not production-ready yet but will give you an idea of how we're approaching this now. Your issue is not implemented in it, though we probably will change isChrono implementation to implement some sort of carrier history.

Klemart3D commented 8 years ago

@SebSept, I've same issue. That's is my provisory hack :

In "hookAdminOrder" function of chronopost.php file :

        // Add an array to get ID list of Chronopost carriers : 
        $carriers = array(
            "CHRONORELAIS_CARRIER_ID" => Configuration::get('CHRONORELAIS_CARRIER_ID'),
            "CHRONOPOST_CARRIER_ID" => Configuration::get('CHRONOPOST_CARRIER_ID'),
            "CHRONOEXPRESS_CARRIER_ID" => Configuration::get('CHRONOEXPRESS_CARRIER_ID'),
            "CHRONO10_CARRIER_ID" => Configuration::get('CHRONO10_CARRIER_ID'),
            "CHRONO18_CARRIER_ID" => Configuration::get('CHRONO18_CARRIER_ID'),
            "CHRONOCLASSIC_CARRIER_ID" => Configuration::get('CHRONOCLASSIC_CARRIER_ID')
        );

        // Display list
        var_dump($carriers);

        // Refresh order's page (and empty cache), I can compare Id's with Id's of AdminCarriers page
        // In my sample my CHRONOPOST_CARRIER_ID is 169 but it has been updated to 182 
        // Change ID of Chronopost Carrier :
        if ((int)(Configuration::get('CHRONOPOST_CARRIER_ID') == "169"))
            Configuration::updateValue('CHRONOPOST_CARRIER_ID', "182");

Refresh order's page to look if button to print waybills turn back. For me it works well pending official update…

SebSept commented 8 years ago

Well, that's a dirty hack :/ Not sur it will work for everyone. Thanks for sharing :)

For the moment, I advise my client not to configure the carriers. I had to fix the ids only two times, sometime I just hit the database to make the carrier free for a short period. That's not a normal that my clients needs a webmaster to configure it's carriers !

+

Klemart3D commented 8 years ago

You're right. I was inspired by @francoisfeugeas version and re-write a provisory isChrono function that checking if id carrier associated to the order is associated to chronopost module. Why ? Because each time a chronopost carrier is updated by Prestashop, id carrier changed and module can't found the new one. With checking if carrier is associated with "chronopost" module, each order with a chronopost carrier can display waybill button with no problems (older like newer orders, after or before an update, it does not matter). May be it can be improvable but this lightened code is tested and approved on my website ;)

    public static function isChrono($id_carrier)
    {
        $carrier = new Carrier($id_carrier);
        return $carrier->external_module_name == "chronopost";
    }

(In ps_carrier table it's easy to check all carriers having an _external_modulename to "chronopost")

SebSept commented 8 years ago

Looks good. Thanks :)

Le 25/02/2016 19:21, Klemart3D a écrit :

You're right. I was inspired by @francoisfeugeas https://github.com/francoisfeugeas version and re-write a provisory isChrono function that checking if id carrier associated to the order is associated to chronopost module. Why ? Because each time a chronopost carrier is updated by Prestashop, id carrier changed and module can't found the new one. With checking if carrier is associated with "chronopost" module, each order with a chronopost carrier can display waybill button with no problems (older like newer orders, after or before an update, it does not matter). May be it can be improvable but this lightened code is tested and approved on my website ;)

|public static function isChrono($id_carrier) { $carrier = new Carrier($id_carrier); return $carrier->external_module_name == "chronopost"; } |

(In _pscarrier table it's easy to check all carriers having an /external_module_name/ to "chronopost")

— Reply to this email directly or view it on GitHub https://github.com/PrestaShop/chronopost/issues/27#issuecomment-188917630.