first commit
This commit is contained in:
51
extension/opencart/catalog/model/shipping/flat.php
Normal file
51
extension/opencart/catalog/model/shipping/flat.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
namespace Opencart\Catalog\Model\Extension\Opencart\Shipping;
|
||||
/**
|
||||
* Class Flat
|
||||
*
|
||||
* @package
|
||||
*/
|
||||
class Flat extends \Opencart\System\Engine\Model {
|
||||
/**
|
||||
* @param array $address
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getQuote(array $address): array {
|
||||
$this->load->language('extension/opencart/shipping/flat');
|
||||
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone_to_geo_zone` WHERE `geo_zone_id` = '" . (int)$this->config->get('shipping_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('shipping_flat_geo_zone_id')) {
|
||||
$status = true;
|
||||
} elseif ($query->num_rows) {
|
||||
$status = true;
|
||||
} else {
|
||||
$status = false;
|
||||
}
|
||||
|
||||
$method_data = [];
|
||||
|
||||
if ($status) {
|
||||
$quote_data = [];
|
||||
|
||||
$quote_data['flat'] = [
|
||||
'code' => 'flat.flat',
|
||||
'name' => $this->language->get('text_description'),
|
||||
'cost' => $this->config->get('shipping_flat_cost'),
|
||||
'tax_class_id' => $this->config->get('shipping_flat_tax_class_id'),
|
||||
'text' => $this->currency->format($this->tax->calculate($this->config->get('shipping_flat_cost'), $this->config->get('shipping_flat_tax_class_id'), $this->config->get('config_tax')), $this->session->data['currency'])
|
||||
];
|
||||
|
||||
$method_data = [
|
||||
'code' => 'flat',
|
||||
'name' => $this->language->get('heading_title'),
|
||||
'quote' => $quote_data,
|
||||
'sort_order' => $this->config->get('shipping_flat_sort_order'),
|
||||
'error' => false
|
||||
];
|
||||
}
|
||||
|
||||
return $method_data;
|
||||
}
|
||||
}
|
55
extension/opencart/catalog/model/shipping/free.php
Normal file
55
extension/opencart/catalog/model/shipping/free.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
namespace Opencart\Catalog\Model\Extension\Opencart\Shipping;
|
||||
/**
|
||||
* Class Free
|
||||
*
|
||||
* @package
|
||||
*/
|
||||
class Free extends \Opencart\System\Engine\Model {
|
||||
/**
|
||||
* @param array $address
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getQuote(array $address): array {
|
||||
$this->load->language('extension/opencart/shipping/free');
|
||||
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone_to_geo_zone` WHERE `geo_zone_id` = '" . (int)$this->config->get('shipping_free_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('shipping_free_geo_zone_id')) {
|
||||
$status = true;
|
||||
} elseif ($query->num_rows) {
|
||||
$status = true;
|
||||
} else {
|
||||
$status = false;
|
||||
}
|
||||
|
||||
if ($this->cart->getSubTotal() < $this->config->get('shipping_free_total')) {
|
||||
$status = false;
|
||||
}
|
||||
|
||||
$method_data = [];
|
||||
|
||||
if ($status) {
|
||||
$quote_data = [];
|
||||
|
||||
$quote_data['free'] = [
|
||||
'code' => 'free.free',
|
||||
'name' => $this->language->get('text_description'),
|
||||
'cost' => 0.00,
|
||||
'tax_class_id' => 0,
|
||||
'text' => $this->currency->format(0.00, $this->session->data['currency'])
|
||||
];
|
||||
|
||||
$method_data = [
|
||||
'code' => 'free',
|
||||
'name' => $this->language->get('heading_title'),
|
||||
'quote' => $quote_data,
|
||||
'sort_order' => $this->config->get('shipping_free_sort_order'),
|
||||
'error' => false
|
||||
];
|
||||
}
|
||||
|
||||
return $method_data;
|
||||
}
|
||||
}
|
62
extension/opencart/catalog/model/shipping/item.php
Normal file
62
extension/opencart/catalog/model/shipping/item.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
namespace Opencart\Catalog\Model\Extension\Opencart\Shipping;
|
||||
/**
|
||||
* Class Item
|
||||
*
|
||||
* @package
|
||||
*/
|
||||
class Item extends \Opencart\System\Engine\Model {
|
||||
/**
|
||||
* @param array $address
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getQuote(array $address): array {
|
||||
$this->load->language('extension/opencart/shipping/item');
|
||||
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone_to_geo_zone` WHERE `geo_zone_id` = '" . (int)$this->config->get('shipping_item_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('shipping_item_geo_zone_id')) {
|
||||
$status = true;
|
||||
} elseif ($query->num_rows) {
|
||||
$status = true;
|
||||
} else {
|
||||
$status = false;
|
||||
}
|
||||
|
||||
$method_data = [];
|
||||
|
||||
if ($status) {
|
||||
$items = 0;
|
||||
|
||||
foreach ($this->cart->getProducts() as $product) {
|
||||
if ($product['shipping']) {
|
||||
$items += $product['quantity'];
|
||||
}
|
||||
}
|
||||
|
||||
$cost = (float)$this->config->get('shipping_item_cost');
|
||||
$tax_class_id = (int)$this->config->get('shipping_item_tax_class_id');
|
||||
|
||||
$quote_data = [];
|
||||
|
||||
$quote_data['item'] = [
|
||||
'code' => 'item.item',
|
||||
'name' => $this->language->get('text_description'),
|
||||
'cost' => $cost * $items,
|
||||
'tax_class_id' => $tax_class_id,
|
||||
'text' => $this->currency->format($this->tax->calculate($cost * $items, $tax_class_id, $this->config->get('config_tax')), $this->session->data['currency'])
|
||||
];
|
||||
|
||||
$method_data = [
|
||||
'code' => 'item',
|
||||
'name' => $this->language->get('heading_title'),
|
||||
'quote' => $quote_data,
|
||||
'sort_order' => $this->config->get('shipping_item_sort_order'),
|
||||
'error' => false
|
||||
];
|
||||
}
|
||||
|
||||
return $method_data;
|
||||
}
|
||||
}
|
51
extension/opencart/catalog/model/shipping/pickup.php
Normal file
51
extension/opencart/catalog/model/shipping/pickup.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
namespace Opencart\Catalog\Model\Extension\Opencart\Shipping;
|
||||
/**
|
||||
* Class Pickup
|
||||
*
|
||||
* @package
|
||||
*/
|
||||
class Pickup extends \Opencart\System\Engine\Model {
|
||||
/**
|
||||
* @param array $address
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getQuote(array $address): array {
|
||||
$this->load->language('extension/opencart/shipping/pickup');
|
||||
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone_to_geo_zone` WHERE `geo_zone_id` = '" . (int)$this->config->get('shipping_pickup_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('shipping_pickup_geo_zone_id')) {
|
||||
$status = true;
|
||||
} elseif ($query->num_rows) {
|
||||
$status = true;
|
||||
} else {
|
||||
$status = false;
|
||||
}
|
||||
|
||||
$method_data = [];
|
||||
|
||||
if ($status) {
|
||||
$quote_data = [];
|
||||
|
||||
$quote_data['pickup'] = [
|
||||
'code' => 'pickup.pickup',
|
||||
'name' => $this->language->get('text_description'),
|
||||
'cost' => 0.00,
|
||||
'tax_class_id' => 0,
|
||||
'text' => $this->currency->format(0.00, $this->session->data['currency'])
|
||||
];
|
||||
|
||||
$method_data = [
|
||||
'code' => 'pickup',
|
||||
'name' => $this->language->get('heading_title'),
|
||||
'quote' => $quote_data,
|
||||
'sort_order' => $this->config->get('shipping_pickup_sort_order'),
|
||||
'error' => false
|
||||
];
|
||||
}
|
||||
|
||||
return $method_data;
|
||||
}
|
||||
}
|
79
extension/opencart/catalog/model/shipping/weight.php
Normal file
79
extension/opencart/catalog/model/shipping/weight.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
namespace Opencart\Catalog\Model\Extension\Opencart\Shipping;
|
||||
/**
|
||||
* Class Weight
|
||||
*
|
||||
* @package
|
||||
*/
|
||||
class Weight extends \Opencart\System\Engine\Model {
|
||||
/**
|
||||
* @param array $address
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getQuote(array $address): array {
|
||||
$this->load->language('extension/opencart/shipping/weight');
|
||||
|
||||
$quote_data = [];
|
||||
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "geo_zone` ORDER BY `name`");
|
||||
|
||||
$weight = $this->cart->getWeight();
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
if ($this->config->get('shipping_weight_' . $result['geo_zone_id'] . '_status')) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone_to_geo_zone` WHERE `geo_zone_id` = '" . (int)$result['geo_zone_id'] . "' AND `country_id` = '" . (int)$address['country_id'] . "' AND (`zone_id` = '" . (int)$address['zone_id'] . "' OR `zone_id` = '0')");
|
||||
|
||||
if ($query->num_rows) {
|
||||
$status = true;
|
||||
} else {
|
||||
$status = false;
|
||||
}
|
||||
} else {
|
||||
$status = false;
|
||||
}
|
||||
|
||||
if ($status) {
|
||||
$cost = '';
|
||||
|
||||
$rates = explode(',', $this->config->get('shipping_weight_' . $result['geo_zone_id'] . '_rate'));
|
||||
|
||||
foreach ($rates as $rate) {
|
||||
$data = explode(':', $rate);
|
||||
|
||||
if ($data[0] >= $weight) {
|
||||
if (isset($data[1])) {
|
||||
$cost = $data[1];
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((string)$cost != '') {
|
||||
$quote_data['weight_' . $result['geo_zone_id']] = [
|
||||
'code' => 'weight.weight_' . $result['geo_zone_id'],
|
||||
'name' => $result['name'] . ' (' . $this->language->get('text_weight') . ' ' . $this->weight->format($weight, $this->config->get('config_weight_class_id')) . ')',
|
||||
'cost' => $cost,
|
||||
'tax_class_id' => $this->config->get('shipping_weight_tax_class_id'),
|
||||
'text' => $this->currency->format($this->tax->calculate($cost, $this->config->get('shipping_weight_tax_class_id'), $this->config->get('config_tax')), $this->session->data['currency'])
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$method_data = [];
|
||||
|
||||
if ($quote_data) {
|
||||
$method_data = [
|
||||
'code' => 'weight',
|
||||
'name' => $this->language->get('heading_title'),
|
||||
'quote' => $quote_data,
|
||||
'sort_order' => $this->config->get('shipping_weight_sort_order'),
|
||||
'error' => false
|
||||
];
|
||||
}
|
||||
|
||||
return $method_data;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user