Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

need help with order total!


Recommended Posts

Hi, I was wondering if there was some documentation, or if someone would describe to me the process of the shopping cart. I'm trying to do a pretty extensive modification and am getting bogged down at this point. I'm trying to learn PHP by immersion and the checkout part seems very, very obscure.


I'm mostly interested in the last stage of the checkout procedure where the order totals are created and put into the orders_total table. It seems like it seaches the modules directory for any file and executes each, e.g. ot_shipping, ot_total etc.


What I want to do is add another line to the orders_totals. I've modified the product listing so it displays a flag field, modified the cart so that it includes it, pushed it into orders_products. All that was *relatively* easy. Now I need to act on that flag and do some calculations based on all products in the order.


I really need this help pretty badly because I have stared at the code in this section for 3-4 days and still don't get it, it trails off into too many directions.

Link to comment
Share on other sites

OK, I looked at the quantity discount contribution and am starting to get it. I've created ot_xitem.php and installed it through the admin portion. The relevant pieces of code are:

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

     $od_amount = $this->calculate_discount($order);
     if ($od_amount > 0) {
       $this->deduction = $od_amount;
       $this->output[] = array('title' => $this->title . ':',
                             'text' => '<b>' . $currencies->format($od_amount, true, $order->info['currency'], $order->info['currency_value']) . '</b>',
                             'value' => $od_amount);
       $order->info['total'] -= $this->deduction;


The part that I don't know what I'm doing is how to get the $od_amount into the order_totals table. I'm not sure what "deduction" is -- I suspect it's part of the quantity discount mod and does not actually do what I need it to do.


What is happening with this code: the order displays correctly at confirmation time, with the discounted amount and the total computed correctly. However, the discount itself never gets inserted into the order_totals table, and upon returning to order history, the pre-discount price is displayed.


How do I get this line entered? I was hoping it would automatically be created by the rest of the code...


Link to comment
Share on other sites


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

  • Create New...