php - How to add Cash on Delivery fee to opencart? -
i'm trying add fee "cash on delivery" module (within payments). have added fields cost
, tax_class_id
in database , in form.
the cost appears in checkout form, how add cost total of cart?
i have controllers , found totals of checkout calculated piece of code:
$totals = array(); $taxes = $this->cart->gettaxes(); $total = 0; $total_data = array( 'totals' => &$totals, 'taxes' => &$taxes, 'total' => &$total );
by output result of $total_data
this:
array ( [totals] => array ( [0] => array ( [code] => sub_total [title] => sub-total [value] => 25 [sort_order] => 1 ) [1] => array ( [code] => shipping [title] => lift on store [value] => 0 [sort_order] => 3 ) [2] => array ( [code] => tax [title] => tax [value] => 5.75 [sort_order] => 5 ) [3] => array ( [code] => total [title] => total [value] => 30.75 [sort_order] => 9 ) ) [taxes] => array ( [88] => 5.75 ) [total] => 30.75 )
i manage add line totals
doing:
if($_post['payment_method'] == 'cod') { $method = $this->model_extension_payment_cod->getmethod($_session['address'], $total); $totals[] = array('code' => 'cod', 'title' => $method['title'], 'value' => $method['text'], 'sort_order' => 4); }
but need update checkout total. if try call again code calculates taxes after code, nothing happens.
$totals = array(); $taxes = $this->cart->gettaxes(); $total = 0; $total_data = array( 'totals' => &$totals, 'taxes' => &$taxes, 'total' => &$total );
Comments
Post a Comment