Active
Project:
Ubercart Percent Rate with Minimum Rate
Version:
6.x-1.1
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
28 Aug 2010 at 02:43 UTC
Updated:
28 Aug 2010 at 02:43 UTC
When using this module to create a flat shipping fee based on the subtotal, the shipping fee is create based on the calculated shipping cost of each individual product. Ideally the would be an over-ride built into the admin area, so thats what I did for each min percent. The changes are listed below. Sorry not better put together for addition but I am on the run.
uc_minpercentrate.admin.inc
after to line 80
$form['sub_total'] = array('#type' => 'checkbox',
'#title' => t('Apply to Subtotal'),
'#default_value' => $form_state['values']['sub_total'],
'#description' => t('Should this rate be applied to the orders sub-total.'),
);new 119 & 120
db_query("UPDATE {uc_minpercentrate_methods} SET title = '%s', label = '%s', base_rate = %f, percent_rate = %f, free_rate = %f, sub_total = %f WHERE mid = %d",
$form_state['values']['title'], $form_state['values']['label'], $form_state['values']['base_rate'], $form_state['values']['percent_rate'], $form_state['values']['free_rate'], $form_state['values']['sub_total'], $form_state['values']['mid']);
and the new 125
$form_state['values']['title'], $form_state['values']['label'], $form_state['values']['base_rate'], $form_state['values']['percent_rate'], $form_state['values']['free_rate'], $form_state['values']['sub_total']);uc_minpercentrate.admin.inc
add after line 81 (Didn't create update, inserted field manually)
'sub_total' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
'description' => t('Should this rate be applied to the orders sub-total.'),
),uc_minpercentrate.module
after line 208
$apply_sub = db_fetch_object(db_query("SELECT * FROM {uc_minpercentrate_methods} WHERE sub_total = %d", $mid));
if($method = db_fetch_object(db_query("SELECT * FROM {uc_minpercentrate_methods} WHERE mid = %d", $mid))) {
foreach ($products as $product) {
if($product->minpercentrate[$mid]) {
$percent_rate = $product->minpercentrate[$mid];
}
else {
$percent_rate = $method->percent_rate;
}
$product_total = $product->price * $product->qty;
// keep track of the total cost of the products in this order, so that we can make
// the total shipping cost free if it's higher than $method->free_rate
$sub_total += $product_total;
if ($apply_sub == 0) {
$product_ship_price = ($percent_rate / 100) * $product_total;
if ($product_ship_price < $method->base_rate ) {
$product_ship_price = $method->base_rate;
}
$total_ship_price += $product_ship_price;
}
}
if ($apply_sub == 1) {
$sub_total_ship_price = ($percent_rate / 100) * $sub_total;
if ($sub_total_ship_price < $method->base_rate ) {
$sub_total_ship_price = $method->base_rate;
}
$total_ship_price += $sub_total_ship_price;
}Sorry about the hast in production, any other fixes will not be done so hastily.