shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

cod.php (1105B)


      1 <?php
      2 class ModelExtensionPaymentCOD extends Model {
      3 	public function getMethod($address, $total) {
      4 		$this->load->language('extension/payment/cod');
      5 
      6 		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('payment_cod_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");
      7 
      8 		if ($this->config->get('payment_cod_total') > 0 && $this->config->get('payment_cod_total') > $total) {
      9 			$status = false;
     10 		} elseif (!$this->cart->hasShipping()) {
     11 			$status = false;
     12 		} elseif (!$this->config->get('payment_cod_geo_zone_id')) {
     13 			$status = true;
     14 		} elseif ($query->num_rows) {
     15 			$status = true;
     16 		} else {
     17 			$status = false;
     18 		}
     19 
     20 		$method_data = array();
     21 
     22 		if ($status) {
     23 			$method_data = array(
     24 				'code'       => 'cod',
     25 				'title'      => $this->language->get('text_title'),
     26 				'terms'      => '',
     27 				'sort_order' => $this->config->get('payment_cod_sort_order')
     28 			);
     29 		}
     30 
     31 		return $method_data;
     32 	}
     33 }