function uc_taxes_update_6 in Ubercart 5
File
- uc_taxes/
uc_taxes.install, line 135
Code
function uc_taxes_update_6() {
$ret = array();
if (module_exists('workflow_ng_ui')) {
$configurations = array();
$taxes = uc_taxes_get_rates();
foreach ($taxes as $tax) {
$configurations['uc_taxes_' . $tax->id] = array(
'#name' => 'uc_taxes_' . $tax->id,
'#label' => $tax->name,
'#event' => 'calculate_tax_' . $tax->id,
'#module' => 'uc_taxes',
'#active' => true,
);
$action = workflow_ng_use_action('uc_taxes_action_apply_tax', array(
'#label' => t('Apply @tax', array(
'@tax' => $tax->name,
)),
));
switch ($tax->type) {
case 'code':
$area_condition = workflow_ng_use_condition('uc_order_condition_delivery_postal_code', array(
'#label' => t('Is in postal code area @code', array(
'@code' => $tax->area,
)),
'#settings' => array(
'pattern' => $tax->area,
),
));
break;
case 'zone':
$zone = uc_get_zone_code($tax->area);
$area_condition = workflow_ng_use_condition('uc_order_condition_delivery_zone', array(
'#label' => t('Is in @zone', array(
'@zone' => $zone,
)),
'#settings' => array(
'zones' => array(
$tax->area,
),
),
));
break;
case 'country':
$country = uc_get_country_data(array(
'country_id' => $tax->area,
));
$country_name = $country[0]['country_name'];
$area_condition = workflow_ng_use_condition('uc_order_condition_delivery_country', array(
'#label' => t('Is in @country', array(
'@country' => $country_name,
)),
'#settings' => array(
'countries' => array(
$tax->area,
),
),
));
break;
}
$configurations['uc_taxes_' . $tax->id] = workflow_ng_configure($configurations['uc_taxes_' . $tax->id], $action, $area_condition);
workflow_ng_ui_save_configuration($configurations['uc_taxes_' . $tax->id]);
}
$ret[] = update_sql("ALTER TABLE {uc_taxes} DROP area");
$ret[] = update_sql("ALTER TABLE {uc_taxes} DROP type");
$ret[] = update_sql("ALTER TABLE {uc_taxes} DROP conditions");
}
return $ret;
}