Zen Cart How to Set a Low Order Fee by Manufacturer?

If you have a zen cart business that offers products or custom products from several different manufacturers, and these manufacturers have different low order fees and thresholds, you will need a way to program this into your zen cart to avoid headaches in order fulfillment. By default, zen cart does not offer this functionality. This tutorial will show you how to program your zen cart to set a low order fee by manufacturer.

In your favorite plain text editor, open the includes/modules/order_total/ot_loworderfee.php file. Be sure to create a back up of this file before you make any modifications, and make a note that this file has been modified in your records as it is a zen cart core file, and you will need to know about this modification for future upgrades.

Replace the whole function process with this new code:


function process() {
global $order, $currencies;

$chk_manufacturers_1_id = 3; // manufacturers_id 3
$chk_manufacturers_1_total = 0;
$chk_manufacturers_1_min = 30.00;
$chk_manufacturers_1_extra = 3.00;

$chk_manufacturers_2_id = 4; // manufacturers_id 4
$chk_manufacturers_2_total = 0;
$chk_manufacturers_2_min = 40.00;
$chk_manufacturers_2_extra = 4.00;

$products = $_SESSION['cart']->get_products();
//echo '<pre>'; echo print_r($products); echo '</pre>';
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
$product_id = $products[$i]['id'];
$ppe = $products[$i]['final_price'];
$ppt = $ppe * $products[$i]['quantity'];
$productsPriceTotal = $ppt + $products[$i]['onetime_charges'];
//echo 'product_id: ' . $product_id . ' $ppt: ' . $ppt . ' qty: ' . $products[$i]['quantity'] . ' $productsPriceTotal: ' . $productsPriceTotal . '
';
if (zen_products_lookup($product_id, 'manufacturers_id') == $chk_manufacturers_1_id && (int)$product_id == (int)$products[$i]['id']) {
$chk_manufacturers_1_total += $productsPriceTotal;
//echo '$chk_manufacturers_1_id: ' . $chk_manufacturers_1_id . ' $product_id: ' . $product_id . ' $chk_manufacturers_1_total: ' . $productsPriceTotal . '
';
}
if (zen_products_lookup($product_id, 'manufacturers_id') == $chk_manufacturers_2_id && (int)$product_id == (int)$products[$i]['id']) {
$chk_manufacturers_2_total += $productsPriceTotal;
//echo '$chk_manufacturers_2_id: ' . $chk_manufacturers_2_id . ' $product_id: ' . $product_id . ' $chk_manufacturers_2_total: ' . $productsPriceTotal . '
';
}
} // end FOR loop
$extra_fee = ($chk_manufacturers_1_total > 0 && $chk_manufacturers_1_total < $chk_manufacturers_1_min ? $chk_manufacturers_1_extra : 0) + ($chk_manufacturers_2_total > 0 && $chk_manufacturers_2_total < $chk_manufacturers_2_min ? $chk_manufacturers_2_extra : 0) if ($extra_fee > 0) {
$tax_address = zen_get_tax_locations();
$tax = zen_get_tax_rate(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $tax_address['country_id'], $tax_address['zone_id']);
$tax_description = zen_get_tax_description(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $tax_address['country_id'], $tax_address['zone_id']);

// calculate from flat fee or percentage
$low_order_fee = $extra_fee;

$order->info['tax'] += zen_calculate_tax($low_order_fee, $tax);
$order->info['tax_groups']["$tax_description"] += zen_calculate_tax($low_order_fee, $tax);
$order->info['total'] += $low_order_fee + zen_calculate_tax($low_order_fee, $tax);
if (DISPLAY_PRICE_WITH_TAX == 'true') {
$low_order_fee += zen_calculate_tax($low_order_fee, $tax);
}

$this->output[] = array('title' => $this->title . ':',
'text' => $currencies->format($low_order_fee, true, $order->info['currency'], $order->info['currency_value']),
'value' => $low_order_fee);
}
}

Then set the variables to match your manufacturers_id, minimum, and extra fee for each set. For example:
$chk_manufacturers_1_id = 3; // manufacturers_id 3
$chk_manufacturers_1_total = 0;
$chk_manufacturers_1_min = 30.00;
$chk_manufacturers_1_extra = 3.00;

This would give you manufacturers_id 3, minimum of $30.00 and an extra fee of $3.00.

If you need help with your zen cart project, or need a quote for a customization that is beyond your skill level, contact us for a quote.

zen cart customization

Leave a Reply