phpopencartopencart2.xopencart-module

Make shipping free when purchases reached 2,000 pesos in Opencart


I already tried to search for this before but my opencart page gave me some bugs and errors that's why I reuploaded my website. The only problem is when the purchases reaches 2,000 the shipping fee will be 0 (zero) or free. With the codes given from other forums, it disappears/disabling the shipping fee that's why it gives some errors on the checkout page (for example, "continue" button can't be clicked because there's no shipping fee was selected). What I would like to do is to make the main value (120.00) to zero.

Here's the flat.php (the only shipping method I use) from Opencart:

<?php
class ModelShippingFlat extends Model {
function getQuote($address) {
    $this->load->language('shipping/flat');

    $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('flat_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");

    if (!$this->config->get('flat_geo_zone_id')) {
        $status = true;
    } elseif ($query->num_rows) {
        $status = true;
    } else {
        $status = false;
    }

    $method_data = array();

    if ($status) {
        $quote_data = array();

        $quote_data['flat'] = array(
            'code'         => 'flat.flat',
            'title'        => $this->language->get('text_description'),
            'cost'         => $this->config->get('flat_cost'),
            'tax_class_id' => $this->config->get('flat_tax_class_id'),
            'text'         => $this->currency->format($this->tax->calculate($this->config->get('flat_cost'), $this->config->get('flat_tax_class_id'), $this->config->get('config_tax')))
        );

        $method_data = array(
            'code'       => 'flat',
            'title'      => $this->language->get('text_title'),
            'quote'      => $quote_data,
            'sort_order' => $this->config->get('flat_sort_order'),
            'error'      => false
        );
    }

    return $method_data;
}
}

Solution

  • Follow the following instruction to get free shipping functionality of > 2,000 pesos

    In catalog\model\shipping\free.php

    make following code before $method_data = array();

    if ($this->cart->getSubTotal() < $this->config->get('free_total')){
    $status = false;
    }
    

    And In catalog\model\shipping\flat.php

    make following code before $method_data = array();

    if ($this->cart->getSubTotal() >= $this->config->get('free_total')) {
    $status = false;
    }