Add a new field to new shipping method in simple checkout module for Open Cart

863 views Asked by At

I try to configure simple checkout module v3.8.3 for Open Cart and I want to create a new shipping method with saving delivery date to new field (like the existed field 'comment'). How can I extend my files to carry out this?

1

There are 1 answers

0
Igor Leonovich On

My purpose was is to add custom shipping date and time. I actually carried out this case by this way:

1.) In the 'admin/view/template/module/simple.tpl':

<option value="date" <?php echo $field['save_to'] == 'date' ? 'selected="selected"' : '' ?>>date</option>
<option value="time" <?php echo $field['save_to'] == 'time' ? 'selected="selected"' : '' ?>>time</option>

2.) In the 'catalog/controller/checkout/simplecheckout_customer.php':

private function get_date_value() {
$date = $this->simple->get_total_value(Simple::SET_CHECKOUT_CUSTOMER,'date');
        $simple_show_shipping_address = $this->cart->hasShipping() ? $this->config->get('simple_show_shipping_address') : 0;

        if ($simple_show_shipping_address && $this->request->server['REQUEST_METHOD'] == 'POST' && empty($this->request->post['shipping_address_same'])) {
            $date .= ' '.$this->simple->get_total_value(Simple::SET_CHECKOUT_ADDRESS,'date');
        }

        $this->simple->date = $date;
        $this->session->data['date'] = $date;
    }

    private function get_time_value() {
        $time = $this->simple->get_total_value(Simple::SET_CHECKOUT_CUSTOMER,'time');

        $simple_show_shipping_address = $this->cart->hasShipping() ? $this->config->get('simple_show_shipping_address') : 0;

        if ($simple_show_shipping_address && $this->request->server['REQUEST_METHOD'] == 'POST' && empty($this->request->post['shipping_address_same'])) {
            $time .= ' '.$this->simple->get_total_value(Simple::SET_CHECKOUT_ADDRESS,'time');
        }

        $this->simple->time = $time;
        $this->session->data['time'] = $time;
    }

3.) In the 'catalog/controller/checkout/simplecheckout.php':

$data['date'] = $this->simple->date;
$data['time'] = $this->simple->time;

4.) So after these actions I can get the values in the 'catalog/controller/checkout/success.php':

$this->session->data['date']
$this->session->data['time']