I have messed around with the module to get it working, turns out it isn't that bad.
Two things need changing:
1 - Change the switch line that calculates the weight into KG as the variable changed at some point:
function _uc_canadapost_make_request($products, $details) {
$cpcid = variable_get('uc_canadapost_cpcid', '');
$turnaround = variable_get('uc_canadapost_turnaround', false);
$from_postalcode = variable_get('uc_canadapost_postalcode', false);
$weight = 0;
$price = 0;
foreach ($products as $product){
$product->weight *= $product->qty;
// convert to kg
switch ($product->units){To:
switch ($product->weight_units){2 - Add the new workflow_ng function: (Copied the one from USPS and modified it)
/******************************************************************************
* Workflow-ng Hooks *
******************************************************************************/
function uc_canadapost_configuration(){
$enabled = variable_get('uc_quote_enabled', array('canadapost' => true));
$configurations = array(
'uc_canadapost_get_quote' => array(
'#label' => t('Shipping quote from Canada Post'),
'#event' => 'get_quote_from_canadapost',
'#module' => 'uc_canadapost',
'#active' => $enabled['canadapost'],
),
);
$action = workflow_ng_use_action('uc_quote_action_get_quote', array(
'#label' => t('Fetch a shipping quote'),
));
$configurations['uc_canadapost_get_quote'] = workflow_ng_configure($configurations['uc_canadapost_get_quote'], $action);
return $configurations;
}
Note: Work still needs to be done as some countries return nothing at all, and orders that exceed the 30KG limit don't display an error.
Let me know if you have any questions.
I am also attaching a copy of my modified module, replace your own module file
| Attachment | Size |
|---|---|
| uc_canadapost.module | 19.93 KB |
