shoppingflux / shoppingfluxexport

7 stars 7 forks source link

PRID info missing in SoLiberte (socolissimo_delivery_info) #414

Open ghost opened 6 years ago

ghost commented 6 years ago

Expected behaviour

When soliberte is active, we should be able to set the prid (relay ID) so the relay info will be linked to the order.

Actual behaviour

The relay ID is not added to soliberte (in the table socolissimo_delivery_info)

Steps to reproduce the behaviour

Receiving an order having a carrier set up for colissimo relay and the module SoLiberte enabled

ghost commented 6 years ago

We can adapt the existing code, such as:

$module = Module::getInstanceByName('soliberte');
if ($module && $module->active) {
    SfLogger::getInstance()->log(SF_LOG_ORDERS, 'soliberte active', $doEchoLog);
    $addrSoColissimo = new Address((int)$id_address_shipping);
    $countrySoColissimo = new Country($addrSoColissimo->id_country);
    $socotable_name = 'socolissimo_delivery_info';
    $socovalues = array(
        'id_cart' => (int) $cart->id,
        'id_customer' => (int) $id_customer,
        'prfirstname' => pSQL($addrSoColissimo->firstname),
        'cename' => pSQL($addrSoColissimo->lastname),
        'cefirstname' => pSQL($addrSoColissimo->firstname),
        'cecountry' => pSQL($countrySoColissimo->iso_code),
        'ceemail' => pSQL($email),
    );

    if (!empty($order->Other)) {
        $socovalues['prid'] = (int)(pSQL($order->Other));
        SfLogger::getInstance()->log(SF_LOG_ORDERS, 'soliberte prid: '.$socovalues['prid'], $doEchoLog);
    } 
    $res = Db::getInstance()->insert($socotable_name, $socovalues);
} else {
    SfLogger::getInstance()->log(SF_LOG_ORDERS, 'soliberte not active', $doEchoLog);
}