Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Admin packingslip help


Peper

Recommended Posts

Please need help to figure out out following.

 

In admin i print a packingslip.php and then all details is shown from total weight to everything that is needed to complete a waybill for couriers.

The only thing missing is a simple calculation to show the actual value of the order for courier insurance purposes if customer selected the option.

 

This means Subtotal - discount(discount coupon applied) * TAX

As easy as that.

 

No how to get simple function to calculate this?

 

Getting the Phoenix off the ground

Link to comment
Share on other sites

So far i came up with a short answer, but there is many functions required to make this properly works like proper tax value for shipping country.

Also if an order is edited in admin then the discount class changes to ie ot_custom_2 or ot_custom_2 so on and makes it even more difficult

 

If anyone wants to add/change below please help, file admin/packingslip.php

This hopefully will save some admin time to manually punch in values into calculator and ending up making mistake.


/// this part after $currencies = new currencies();

  $oID = tep_db_prepare_input($HTTP_GET_VARS['oID']);
  $orders_query = tep_db_query("select orders_id, payment_method, customers_id, date_purchased from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'");
$customer_id = tep_db_fetch_array($orders_query);
$orders=$customer_id['customers_id'];
$customer_id = $orders;
?>
/// this part

///// add next to page
<?php
 
function filter_text($text) {
$filter_array = array(",","\r","\n","\t");
return str_replace($filter_array,"",$text);
} // function for the filter
   
// --------------------    QUERIES 1  ------------------------------------//
//Orders_tax
$orders_tax = tep_db_query("select value from orders_total
where class = 'ot_tax' and orders_id = " . $oID);
while($row_orders_tax = tep_db_fetch_array($orders_tax)) {
 // end //
$Order_Tax = filter_text($row_orders_tax["value"]);
}
 
// --------------------    QUERIES 2  ------------------------------------//
//Orders_subtotal
$orders_subtotal = tep_db_query("select value from orders_total
where class = 'ot_subtotal' and orders_id = " . $oID);
while($row_orders_subtotal = tep_db_fetch_array($orders_subtotal)) {
 // end //
$Order_Subtotal = filter_text($row_orders_subtotal["value"]);
}
 
// --------------------    QUERIES 3  ------------------------------------//
//Orders_discount
$orders_discount = tep_db_query("select value from orders_total
where class = 'ot_discount' and orders_id = " . $oID);
while($row_orders_discount = tep_db_fetch_array($orders_discount)) {
 // end //
$Order_Discount = filter_text($row_orders_discount["value"]);
  }
// --------------------    QUERIES 4  ------------------------------------//
//Orders_insurance
$orders_ot_insurance = tep_db_query("select value from orders_total
where class = 'ot_insurance' and orders_id = " . $oID);
while($row_orders_ot_insurance = tep_db_fetch_array($orders_ot_insurance)) {
 // end //
$Order_insurance = filter_text($row_orders_ot_insurance["value"]);
  }
  
/// Begin calculations
/// If zero insurance - disable display of insurance value completely 
  if ($Order_insurance !=="0.0000") { 
 
/// Amounts above 1 then calculate
if (($Order_Discount < "1") || ($Order_Tax < "1"))  {
 echo "Insurance Value: <b> " . round(($Order_Subtotal + $Order_Discount) * 1.14) . '</b>';
///
 
/// Amounts above 1 then calculate
} elseif  (($Order_Discount > "0.1") || ($Order_Tax > "0.1"))  {
echo "Insurance Value: <b> " . round($Order_Subtotal * 1.14) . '</b>';
 
/// Manual calculate then
} else {
echo "Calculated Insurance Value: <b> _________________ " . '</b>';
}
 
 // if ($Order_Tax < "1") {
//echo "Insurance Value: <b>2 " . round($Order_Subtotal + $Order_Discount). '</b>';
//  }else{
//  echo "Insurance Value: <b>3 " . round(($Order_Subtotal + $Order_Discount) * 1.14) . '</b>';
 
// }
// print '<br>1 Order Subtotal: ' . $Order_Subtotal;
// print'<br>2 Order Discount: ' . $Order_Discount;
// print '<br>3 Order Tax: ' . $Order_Tax;
// print '<br>4 Order Insurance: ' . $Order_insurance;
  }
 
?>

Getting the Phoenix off the ground

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...