I am currently doing a job for someone and he wants to set a percentage discount for orders with "Pickup From Store" shipping method selected.
How can I make such a module to enable this?
I could not find anything on Google that could help me with this. There are some modules related to payment method fees but this is completely different + I don't need any options in this module except to set the discount percentage and that's it.
I've been trying something and thought that this code might work but it actually doesn't.
Please help me, I need to get this done today :/
Code: Select all
class ModelTotalPickupDiscount extends Model {
public function getTotal(&$total_data, &$total, &$taxes) {
$this->load->language('total/pickup_discount');
if((isset($this->session->data['shipping_method']) && ($this->session->data['shipping_method']['code'] == 'pickup')) || (isset($this->request->post['shipping']) && ($this->request->post['shipping']=='pickup'))) {
$subTotal = $total;
$perc = (float)10/100; // 10 is the percentage
$remove = $subTotal-($subTotal*(1-$perc));
$total_data[] = array(
'code' => 'pickup_discount',
'title' => $this->language->get('text_pickup_discount'),
'text' => $this->currency->format(-$remove),
'value' => -$remove,
'sort_order' => 5
);
$total -= $remove;
}
}
}