QB customer id is assigned to orders at the same time as the module checks if customers exist in QB. If multiple orders from the same customer is being exported, only the first one will get the customer assigned to it.

To fix, in uc_qb.module, function uc_qb_qbwc_request, find the following (around line 600):

// Check that all the customers exist in QB and if not create them
if (!array_key_exists($copy->uid ? $copy->uid : $copy->primary_email, $checked_users)) {
if (isset($copy->user_data['QBListID'])) {
$copy->qb_user_id = $copy->user_data['QBListID'];
}
else if (isset($copy->order_data['QBListID'])) {
$copy->qb_user_id = $copy->order_data['QBListID'];
}
else if (!$copy->primary_email) {
watchdog('uc_qb', t('Order #%order could not be exported to QB because anonymous user did not provide an email address.', array('%order' => $copy->order_id)), WATCHDOG_ERROR);
}
else {
$check[] = array(
'name' => 'CustomerAddRq',
'request' => array('CustomerAdd' => array(
'Name' => $copy->uid ? $copy->name : $copy->primary_email,
'IsActive' => 'true',
'Email' => $copy->primary_email,
'Notes' => $copy->uid ? url('user/'. $copy->uid, null, null, true) : ' '
)),
'data' => $copy
);
$copy->qb_user_id_pending = true;
}

$checked_users[$copy->uid ? $copy->uid : $copy->primary_email] = true;
}

at the end of this block, add the following:

else if (isset($copy->user_data['QBListID'])) {
$copy->qb_user_id = $copy->user_data['QBListID'];
}

CommentFileSizeAuthor
#1 uc_qb.module.patch434 bytesmillenniumtree

Comments

millenniumtree’s picture

Priority: Normal » Critical
Status: Active » Needs review
StatusFileSize
new434 bytes

This seems to me like a critical issue.

I've put the change in a patch.