first commit

This commit is contained in:
sujan
2024-08-06 18:06:00 +05:45
commit a2fa49071a
2745 changed files with 391199 additions and 0 deletions

View File

@ -0,0 +1,70 @@
<?php
namespace Opencart\Catalog\Controller\Extension\Opencart\Captcha;
/**
* Class Basic
*
* @package
*/
class Basic extends \Opencart\System\Engine\Controller {
/**
* @return string
*/
public function index(): string {
$this->load->language('extension/opencart/captcha/basic');
$data['route'] = (string)$this->request->get['route'];
$this->session->data['captcha'] = substr(oc_token(100), rand(0, 94), 6);
return $this->load->view('extension/opencart/captcha/basic', $data);
}
/**
* @return string
*/
public function validate(): string {
$this->load->language('extension/opencart/captcha/basic');
if (!isset($this->session->data['captcha']) || !isset($this->request->post['captcha']) || ($this->session->data['captcha'] != $this->request->post['captcha'])) {
return $this->language->get('error_captcha');
} else {
return '';
}
}
/**
* @return void
*/
public function captcha(): void {
$image = imagecreatetruecolor(150, 35);
$width = imagesx($image);
$height = imagesy($image);
$black = imagecolorallocate($image, 0, 0, 0);
$white = imagecolorallocate($image, 255, 255, 255);
$red = imagecolorallocatealpha($image, 255, 0, 0, 75);
$green = imagecolorallocatealpha($image, 0, 255, 0, 75);
$blue = imagecolorallocatealpha($image, 0, 0, 255, 75);
imagefilledrectangle($image, 0, 0, $width, $height, $white);
imagefilledellipse($image, ceil(rand(5, 145)), ceil(rand(0, 35)), 30, 30, $red);
imagefilledellipse($image, ceil(rand(5, 145)), ceil(rand(0, 35)), 30, 30, $green);
imagefilledellipse($image, ceil(rand(5, 145)), ceil(rand(0, 35)), 30, 30, $blue);
imagefilledrectangle($image, 0, 0, $width, 0, $black);
imagefilledrectangle($image, $width - 1, 0, $width - 1, $height - 1, $black);
imagefilledrectangle($image, 0, 0, 0, $height - 1, $black);
imagefilledrectangle($image, 0, $height - 1, $width, $height - 1, $black);
imagestring($image, 10, intval(($width - (strlen($this->session->data['captcha']) * 9)) / 2), intval(($height - 15) / 2), $this->session->data['captcha'], $black);
header('Content-type: image/jpeg');
header('Cache-Control: no-cache');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
imagejpeg($image);
imagedestroy($image);
exit();
}
}

View File

@ -0,0 +1,67 @@
<?php
namespace Opencart\Catalog\Controller\Extension\Opencart\Currency;
/**
* Class ECB
*
* @package
*/
class ECB extends \Opencart\System\Engine\Controller {
/**
* @param string $default
*
* @return void
*/
public function currency(string $default = ''): void {
if ($this->config->get('currency_ecb_status')) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
$response = curl_exec($curl);
curl_close($curl);
if ($response) {
$dom = new \DOMDocument('1.0', 'UTF-8');
$dom->loadXml($response);
$cube = $dom->getElementsByTagName('Cube')->item(0);
$currencies = [];
$currencies['EUR'] = 1.0000;
foreach ($cube->getElementsByTagName('Cube') as $currency) {
if ($currency->getAttribute('currency')) {
$currencies[$currency->getAttribute('currency')] = $currency->getAttribute('rate');
}
}
if ($currencies) {
$this->load->model('localisation/currency');
$results = $this->model_localisation_currency->getCurrencies();
foreach ($results as $result) {
if (isset($currencies[$result['code']])) {
$from = $currencies['EUR'];
$to = $currencies[$result['code']];
$this->model_localisation_currency->editValueByCode($result['code'], 1 / ($currencies[$default] * ($from / $to)));
}
}
}
$this->model_localisation_currency->editValueByCode($default, '1.00000');
$this->cache->delete('currency');
}
}
}
}

View File

@ -0,0 +1,61 @@
<?php
namespace Opencart\Catalog\Controller\Extension\Opencart\Currency;
/**
* Class Fixer
*
* @package
*/
class Fixer extends \Opencart\System\Engine\Controller {
/**
* @param string $default
*
* @return void
*/
public function currency(string $default = ''): void {
if ($this->config->get('currency_fixer_status')) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://data.fixer.io/api/latest?access_key=' . $this->config->get('currency_fixer_api'));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
$response = curl_exec($curl);
curl_close($curl);
$response_info = json_decode($response, true);
if (is_array($response_info) && isset($response_info['rates'])) {
// Compile all the rates into an array
$currencies = [];
$currencies['EUR'] = 1.0000;
foreach ($response_info['rates'] as $key => $value) {
$currencies[$key] = $value;
}
$this->load->model('localisation/currency');
$results = $this->model_localisation_currency->getCurrencies();
foreach ($results as $result) {
if (isset($currencies[$result['code']])) {
$from = $currencies['EUR'];
$to = $currencies[$result['code']];
$this->model_localisation_currency->editValueByCode($result['code'], 1 / ($currencies[$default] * ($from / $to)));
}
}
$this->model_localisation_currency->editValueByCode($default, 1);
$this->cache->delete('currency');
}
}
}
}

View File

@ -0,0 +1,35 @@
<?php
namespace Opencart\Catalog\Controller\Extension\Opencart\Module;
/**
* Class Account
*
* @package
*/
class Account extends \Opencart\System\Engine\Controller {
/**
* @return string
*/
public function index(): string {
$this->load->language('extension/opencart/module/account');
$data['logged'] = $this->customer->isLogged();
$data['register'] = $this->url->link('account/register', 'language=' . $this->config->get('config_language'));
$data['login'] = $this->url->link('account/login', 'language=' . $this->config->get('config_language'));
$data['logout'] = $this->url->link('account/logout', 'language=' . $this->config->get('config_language'));
$data['forgotten'] = $this->url->link('account/forgotten', 'language=' . $this->config->get('config_language'));
$data['account'] = $this->url->link('account/account', 'language=' . $this->config->get('config_language') . (isset($this->session->data['customer_token']) ? '&customer_token=' . $this->session->data['customer_token'] : ''));
$data['edit'] = $this->url->link('account/edit', 'language=' . $this->config->get('config_language') . (isset($this->session->data['customer_token']) ? '&customer_token=' . $this->session->data['customer_token'] : ''));
$data['password'] = $this->url->link('account/password', 'language=' . $this->config->get('config_language') . (isset($this->session->data['customer_token']) ? '&customer_token=' . $this->session->data['customer_token'] : ''));
$data['address'] = $this->url->link('account/address', 'language=' . $this->config->get('config_language') . (isset($this->session->data['customer_token']) ? '&customer_token=' . $this->session->data['customer_token'] : ''));
$data['wishlist'] = $this->url->link('account/wishlist', 'language=' . $this->config->get('config_language') . (isset($this->session->data['customer_token']) ? '&customer_token=' . $this->session->data['customer_token'] : ''));
$data['order'] = $this->url->link('account/order', 'language=' . $this->config->get('config_language') . (isset($this->session->data['customer_token']) ? '&customer_token=' . $this->session->data['customer_token'] : ''));
$data['download'] = $this->url->link('account/download', 'language=' . $this->config->get('config_language') . (isset($this->session->data['customer_token']) ? '&customer_token=' . $this->session->data['customer_token'] : ''));
$data['reward'] = $this->url->link('account/reward', 'language=' . $this->config->get('config_language') . (isset($this->session->data['customer_token']) ? '&customer_token=' . $this->session->data['customer_token'] : ''));
$data['return'] = $this->url->link('account/returns', 'language=' . $this->config->get('config_language') . (isset($this->session->data['customer_token']) ? '&customer_token=' . $this->session->data['customer_token'] : ''));
$data['transaction'] = $this->url->link('account/transaction', 'language=' . $this->config->get('config_language') . (isset($this->session->data['customer_token']) ? '&customer_token=' . $this->session->data['customer_token'] : ''));
$data['newsletter'] = $this->url->link('account/newsletter', 'language=' . $this->config->get('config_language') . (isset($this->session->data['customer_token']) ? '&customer_token=' . $this->session->data['customer_token'] : ''));
$data['subscription'] = $this->url->link('account/subscription', 'language=' . $this->config->get('config_language') . (isset($this->session->data['customer_token']) ? '&customer_token=' . $this->session->data['customer_token'] : ''));
return $this->load->view('extension/opencart/module/account', $data);
}
}

View File

@ -0,0 +1,50 @@
<?php
namespace Opencart\Catalog\Controller\Extension\Opencart\Module;
/**
* Class Banner
*
* @package
*/
class Banner extends \Opencart\System\Engine\Controller {
/**
* @param array $setting
*
* @return string
*/
public function index(array $setting): string {
static $module = 0;
$this->load->model('design/banner');
$this->load->model('tool/image');
$data['banners'] = [];
$results = $this->model_design_banner->getBanner($setting['banner_id']);
foreach ($results as $result) {
if (is_file(DIR_IMAGE . html_entity_decode($result['image'], ENT_QUOTES, 'UTF-8'))) {
$data['banners'][] = [
'title' => $result['title'],
'link' => $result['link'],
'image' => $this->model_tool_image->resize(html_entity_decode($result['image'], ENT_QUOTES, 'UTF-8'), $setting['width'], $setting['height'])
];
}
}
if ($data['banners']) {
$data['module'] = $module++;
$data['effect'] = $setting['effect'];
$data['controls'] = $setting['controls'];
$data['indicators'] = $setting['indicators'];
$data['items'] = $setting['items'];
$data['interval'] = $setting['interval'];
$data['width'] = $setting['width'];
$data['height'] = $setting['height'];
return $this->load->view('extension/opencart/module/banner', $data);
} else {
return '';
}
}
}

View File

@ -0,0 +1,73 @@
<?php
namespace Opencart\Catalog\Controller\Extension\Opencart\Module;
/**
* Class BestSeller
*
* @package
*/
class BestSeller extends \Opencart\System\Engine\Controller {
/**
* @param array $setting
*
* @return string
*/
public function index(array $setting): string {
$this->load->language('extension/opencart/module/bestseller');
$data['axis'] = $setting['axis'];
$data['products'] = [];
$this->load->model('extension/opencart/module/bestseller');
$this->load->model('tool/image');
$results = $this->model_extension_opencart_module_bestseller->getBestSellers($setting['limit']);
if ($results) {
foreach ($results as $result) {
if ($result['image']) {
$image = $this->model_tool_image->resize(html_entity_decode($result['image'], ENT_QUOTES, 'UTF-8'), $setting['width'], $setting['height']);
} else {
$image = $this->model_tool_image->resize('placeholder.png', $setting['width'], $setting['height']);
}
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$price = false;
}
if ((float)$result['special']) {
$special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$special = false;
}
if ($this->config->get('config_tax')) {
$tax = $this->currency->format((float)$result['special'] ? $result['special'] : $result['price'], $this->session->data['currency']);
} else {
$tax = false;
}
$product_data = [
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => oc_substr(trim(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('config_product_description_length')) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1,
'rating' => $result['rating'],
'href' => $this->url->link('product/product', 'language=' . $this->config->get('config_language') . '&product_id=' . $result['product_id'])
];
$data['products'][] = $this->load->controller('product/thumb', $product_data);
}
return $this->load->view('extension/opencart/module/bestseller', $data);
} else {
return '';
}
}
}

View File

@ -0,0 +1,76 @@
<?php
namespace Opencart\Catalog\Controller\Extension\Opencart\Module;
/**
* Class Category
*
* @package
*/
class Category extends \Opencart\System\Engine\Controller {
/**
* @return string
*/
public function index(): string {
$this->load->language('extension/opencart/module/category');
if (isset($this->request->get['path'])) {
$parts = explode('_', (string)$this->request->get['path']);
} else {
$parts = [];
}
if (isset($parts[0])) {
$data['category_id'] = $parts[0];
} else {
$data['category_id'] = 0;
}
if (isset($parts[1])) {
$data['child_id'] = $parts[1];
} else {
$data['child_id'] = 0;
}
$this->load->model('catalog/category');
$this->load->model('catalog/product');
$data['categories'] = [];
$categories = $this->model_catalog_category->getCategories(0);
foreach ($categories as $category) {
$children_data = [];
if ($category['category_id'] == $data['category_id']) {
$children = $this->model_catalog_category->getCategories($category['category_id']);
foreach ($children as $child) {
$filter_data = [
'filter_category_id' => $child['category_id'],
'filter_sub_category' => true
];
$children_data[] = [
'category_id' => $child['category_id'],
'name' => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
'href' => $this->url->link('product/category', 'language=' . $this->config->get('config_language') . '&path=' . $category['category_id'] . '_' . $child['category_id'])
];
}
}
$filter_data = [
'filter_category_id' => $category['category_id'],
'filter_sub_category' => true
];
$data['categories'][] = [
'category_id' => $category['category_id'],
'name' => $category['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
'children' => $children_data,
'href' => $this->url->link('product/category', 'language=' . $this->config->get('config_language') . '&path=' . $category['category_id'])
];
}
return $this->load->view('extension/opencart/module/category', $data);
}
}

View File

@ -0,0 +1,83 @@
<?php
namespace Opencart\Catalog\Controller\Extension\Opencart\Module;
/**
* Class Featured
*
* @package
*/
class Featured extends \Opencart\System\Engine\Controller {
/**
* @param array $setting
*
* @return string
*/
public function index(array $setting): string {
$this->load->language('extension/opencart/module/featured');
$data['axis'] = $setting['axis'];
$data['products'] = [];
$this->load->model('catalog/product');
$this->load->model('tool/image');
if (!empty($setting['product'])) {
$products = [];
foreach ($setting['product'] as $product_id) {
$product_info = $this->model_catalog_product->getProduct($product_id);
if ($product_info) {
$products[] = $product_info;
}
}
foreach ($products as $product) {
if ($product['image']) {
$image = $this->model_tool_image->resize(html_entity_decode($product['image'], ENT_QUOTES, 'UTF-8'), $setting['width'], $setting['height']);
} else {
$image = $this->model_tool_image->resize('placeholder.png', $setting['width'], $setting['height']);
}
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
$price = $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$price = false;
}
if ((float)$product['special']) {
$special = $this->currency->format($this->tax->calculate($product['special'], $product['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$special = false;
}
if ($this->config->get('config_tax')) {
$tax = $this->currency->format((float)$product['special'] ? $product['special'] : $product['price'], $this->session->data['currency']);
} else {
$tax = false;
}
$product_data = [
'product_id' => $product['product_id'],
'thumb' => $image,
'name' => $product['name'],
'description' => oc_substr(trim(strip_tags(html_entity_decode($product['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('config_product_description_length')) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'minimum' => $product['minimum'] > 0 ? $product['minimum'] : 1,
'rating' => (int)$product['rating'],
'href' => $this->url->link('product/product', 'language=' . $this->config->get('config_language') . '&product_id=' . $product['product_id'])
];
$data['products'][] = $this->load->controller('product/thumb', $product_data);
}
}
if ($data['products']) {
return $this->load->view('extension/opencart/module/featured', $data);
} else {
return '';
}
}
}

View File

@ -0,0 +1,85 @@
<?php
namespace Opencart\Catalog\Controller\Extension\Opencart\Module;
/**
* Class Filter
*
* @package
*/
class Filter extends \Opencart\System\Engine\Controller {
/**
* @return string
*/
public function index(): string {
if (isset($this->request->get['path'])) {
$parts = explode('_', (string)$this->request->get['path']);
} else {
$parts = [];
}
$category_id = end($parts);
$this->load->model('catalog/category');
$category_info = $this->model_catalog_category->getCategory($category_id);
if ($category_info) {
$this->load->language('extension/opencart/module/filter');
$url = '';
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['limit'])) {
$url .= '&limit=' . $this->request->get['limit'];
}
$data['action'] = str_replace('&amp;', '&', $this->url->link('product/category', 'language=' . $this->config->get('config_language') . '&path=' . $this->request->get['path'] . $url));
if (isset($this->request->get['filter'])) {
$data['filter_category'] = explode(',', $this->request->get['filter']);
} else {
$data['filter_category'] = [];
}
$this->load->model('catalog/product');
$data['filter_groups'] = [];
$filter_groups = $this->model_catalog_category->getFilters($category_id);
if ($filter_groups) {
foreach ($filter_groups as $filter_group) {
$children_data = [];
foreach ($filter_group['filter'] as $filter) {
$filter_data = [
'filter_category_id' => $category_id,
'filter_filter' => $filter['filter_id']
];
$children_data[] = [
'filter_id' => $filter['filter_id'],
'name' => $filter['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : '')
];
}
$data['filter_groups'][] = [
'filter_group_id' => $filter_group['filter_group_id'],
'name' => $filter_group['name'],
'filter' => $children_data
];
}
return $this->load->view('extension/opencart/module/filter', $data);
}
}
return '';
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace Opencart\Catalog\Controller\Extension\Opencart\Module;
/**
* Class HTML
*
* @package
*/
class HTML extends \Opencart\System\Engine\Controller {
/**
* @param array $setting
*
* @return string
*/
public function index(array $setting): string {
if (isset($setting['module_description'][$this->config->get('config_language_id')])) {
$data['heading_title'] = html_entity_decode($setting['module_description'][$this->config->get('config_language_id')]['title'], ENT_QUOTES, 'UTF-8');
$data['html'] = html_entity_decode($setting['module_description'][$this->config->get('config_language_id')]['description'], ENT_QUOTES, 'UTF-8');
return $this->load->view('extension/opencart/module/html', $data);
} else {
return '';
}
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace Opencart\Catalog\Controller\Extension\Opencart\Module;
/**
* Class Information
*
* @package
*/
class Information extends \Opencart\System\Engine\Controller {
/**
* @return string
*/
public function index(): string {
$this->load->language('extension/opencart/module/information');
$this->load->model('catalog/information');
$data['informations'] = [];
foreach ($this->model_catalog_information->getInformations() as $result) {
$data['informations'][] = [
'title' => $result['title'],
'href' => $this->url->link('information/information', 'language=' . $this->config->get('config_language') . '&information_id=' . $result['information_id'])
];
}
$data['contact'] = $this->url->link('information/contact', 'language=' . $this->config->get('config_language'));
$data['sitemap'] = $this->url->link('information/sitemap', 'language=' . $this->config->get('config_language'));
return $this->load->view('extension/opencart/module/information', $data);
}
}

View File

@ -0,0 +1,73 @@
<?php
namespace Opencart\Catalog\Controller\Extension\Opencart\Module;
/**
* Class Latest
*
* @package
*/
class Latest extends \Opencart\System\Engine\Controller {
/**
* @param array $setting
*
* @return string
*/
public function index(array $setting): string {
$this->load->language('extension/opencart/module/latest');
$data['axis'] = $setting['axis'];
$data['products'] = [];
$this->load->model('extension/opencart/module/latest');
$this->load->model('tool/image');
$results = $this->model_extension_opencart_module_latest->getLatest($setting['limit']);
if ($results) {
foreach ($results as $result) {
if ($result['image']) {
$image = $this->model_tool_image->resize(html_entity_decode($result['image'], ENT_QUOTES, 'UTF-8'), $setting['width'], $setting['height']);
} else {
$image = $this->model_tool_image->resize('placeholder.png', $setting['width'], $setting['height']);
}
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$price = false;
}
if ((float)$result['special']) {
$special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$special = false;
}
if ($this->config->get('config_tax')) {
$tax = $this->currency->format((float)$result['special'] ? $result['special'] : $result['price'], $this->session->data['currency']);
} else {
$tax = false;
}
$product_data = [
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => oc_substr(trim(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('config_product_description_length')) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1,
'rating' => $result['rating'],
'href' => $this->url->link('product/product', 'language=' . $this->config->get('config_language') . '&product_id=' . $result['product_id'])
];
$data['products'][] = $this->load->controller('product/thumb', $product_data);
}
return $this->load->view('extension/opencart/module/latest', $data);
} else {
return '';
}
}
}

View File

@ -0,0 +1,80 @@
<?php
namespace Opencart\Catalog\Controller\Extension\Opencart\Module;
/**
* Class Special
*
* @package
*/
class Special extends \Opencart\System\Engine\Controller {
/**
* @param array $setting
*
* @return string
*/
public function index(array $setting): string {
$this->load->language('extension/opencart/module/special');
$data['axis'] = $setting['axis'];
$data['products'] = [];
$filter_data = [
'sort' => 'pd.name',
'order' => 'ASC',
'start' => 0,
'limit' => $setting['limit']
];
$this->load->model('catalog/product');
$this->load->model('tool/image');
$results = $this->model_catalog_product->getSpecials($filter_data);
if ($results) {
foreach ($results as $result) {
if ($result['image']) {
$image = $this->model_tool_image->resize(html_entity_decode($result['image'], ENT_QUOTES, 'UTF-8'), $setting['width'], $setting['height']);
} else {
$image = $this->model_tool_image->resize('placeholder.png', $setting['width'], $setting['height']);
}
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$price = false;
}
if ((float)$result['special']) {
$special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$special = false;
}
if ($this->config->get('config_tax')) {
$tax = $this->currency->format((float)$result['special'] ? $result['special'] : $result['price'], $this->session->data['currency']);
} else {
$tax = false;
}
$product_data = [
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => oc_substr(trim(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('config_product_description_length')) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1,
'rating' => $result['rating'],
'href' => $this->url->link('product/product', 'language=' . $this->config->get('config_language') . '&product_id=' . $result['product_id'])
];
$data['products'][] = $this->load->controller('product/thumb', $product_data);
}
return $this->load->view('extension/opencart/module/special', $data);
} else {
return '';
}
}
}

View File

@ -0,0 +1,49 @@
<?php
namespace Opencart\Catalog\Controller\Extension\Opencart\Module;
/**
* Class Store
*
* @package
*/
class Store extends \Opencart\System\Engine\Controller {
/**
* @return string
*/
public function index(): string {
$status = true;
if ($this->config->get('module_store_admin')) {
$this->user = new \Opencart\System\Library\Cart\User($this->registry);
$status = $this->user->isLogged();
}
if ($status) {
$this->load->language('extension/opencart/module/store');
$data['store_id'] = $this->config->get('config_store_id');
$data['stores'] = [];
$data['stores'][] = [
'store_id' => 0,
'name' => $this->language->get('text_default'),
'url' => HTTP_SERVER . 'index.php?route=common/home&session_id=' . $this->session->getId()
];
$this->load->model('setting/store');
$results = $this->model_setting_store->getStores();
foreach ($results as $result) {
$data['stores'][] = [
'store_id' => $result['store_id'],
'name' => $result['name'],
'url' => $result['url'] . 'index.php?route=common/home&session_id=' . $this->session->getId()
];
}
return $this->load->view('extension/opencart/module/store', $data);
}
}
}

View File

@ -0,0 +1,53 @@
<?php
namespace Opencart\Catalog\Controller\Extension\Opencart\Payment;
/**
* Class BankTransfer
*
* @package
*/
class BankTransfer extends \Opencart\System\Engine\Controller {
/**
* @return string
*/
public function index(): string {
$this->load->language('extension/opencart/payment/bank_transfer');
$data['bank'] = nl2br($this->config->get('payment_bank_transfer_bank_' . $this->config->get('config_language_id')));
$data['language'] = $this->config->get('config_language');
return $this->load->view('extension/opencart/payment/bank_transfer', $data);
}
/**
* @return void
*/
public function confirm(): void {
$this->load->language('extension/opencart/payment/bank_transfer');
$json = [];
if (!isset($this->session->data['order_id'])) {
$json['error'] = $this->language->get('error_order');
}
if (!isset($this->session->data['payment_method']) || $this->session->data['payment_method']['code'] != 'bank_transfer.bank_transfer') {
$json['error'] = $this->language->get('error_payment_method');
}
if (!$json) {
$comment = $this->language->get('text_instruction') . "\n\n";
$comment .= $this->config->get('payment_bank_transfer_bank_' . $this->config->get('config_language_id')) . "\n\n";
$comment .= $this->language->get('text_payment');
$this->load->model('checkout/order');
$this->model_checkout_order->addHistory($this->session->data['order_id'], $this->config->get('payment_bank_transfer_order_status_id'), $comment, true);
$json['redirect'] = $this->url->link('checkout/success', 'language=' . $this->config->get('config_language'), true);
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}

View File

@ -0,0 +1,56 @@
<?php
namespace Opencart\Catalog\Controller\Extension\Opencart\Payment;
/**
* Class Cheque
*
* @package
*/
class Cheque extends \Opencart\System\Engine\Controller {
/**
* @return string
*/
public function index(): string {
$this->load->language('extension/opencart/payment/cheque');
$data['payable'] = $this->config->get('payment_cheque_payable');
$data['address'] = nl2br($this->config->get('config_address'));
$data['language'] = $this->config->get('config_language');
return $this->load->view('extension/opencart/payment/cheque', $data);
}
/**
* @return void
*/
public function confirm(): void {
$this->load->language('extension/opencart/payment/cheque');
$json = [];
if (!isset($this->session->data['order_id'])) {
$json['error'] = $this->language->get('error_order');
}
if (!isset($this->session->data['payment_method']) || $this->session->data['payment_method']['code'] != 'cheque.cheque') {
$json['error'] = $this->language->get('error_payment_method');
}
if (!$json) {
$comment = $this->language->get('text_payable') . "\n";
$comment .= $this->config->get('payment_cheque_payable') . "\n\n";
$comment .= $this->language->get('text_address') . "\n";
$comment .= $this->config->get('config_address') . "\n\n";
$comment .= $this->language->get('text_payment') . "\n";
$this->load->model('checkout/order');
$this->model_checkout_order->addHistory($this->session->data['order_id'], $this->config->get('payment_cheque_order_status_id'), $comment, true);
$json['redirect'] = $this->url->link('checkout/success', 'language=' . $this->config->get('config_language'), true);
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}

View File

@ -0,0 +1,47 @@
<?php
namespace Opencart\Catalog\Controller\Extension\Opencart\Payment;
/**
* Class Cod
*
* @package
*/
class Cod extends \Opencart\System\Engine\Controller {
/**
* @return string
*/
public function index(): string {
$this->load->language('extension/opencart/payment/cod');
$data['language'] = $this->config->get('config_language');
return $this->load->view('extension/opencart/payment/cod', $data);
}
/**
* @return void
*/
public function confirm(): void {
$this->load->language('extension/opencart/payment/cod');
$json = [];
if (!isset($this->session->data['order_id'])) {
$json['error'] = $this->language->get('error_order');
}
if (!isset($this->session->data['payment_method']) || $this->session->data['payment_method']['code'] != 'cod.cod') {
$json['error'] = $this->language->get('error_payment_method');
}
if (!$json) {
$this->load->model('checkout/order');
$this->model_checkout_order->addHistory($this->session->data['order_id'], $this->config->get('payment_cod_order_status_id'));
$json['redirect'] = $this->url->link('checkout/success', 'language=' . $this->config->get('config_language'), true);
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}

View File

@ -0,0 +1,47 @@
<?php
namespace Opencart\Catalog\Controller\Extension\Opencart\Payment;
/**
* Class FreeCheckout
*
* @package
*/
class FreeCheckout extends \Opencart\System\Engine\Controller {
/**
* @return string
*/
public function index(): string {
$this->load->language('extension/opencart/payment/free_checkout');
$data['language'] = $this->config->get('config_language');
return $this->load->view('extension/opencart/payment/free_checkout', $data);
}
/**
* @return void
*/
public function confirm(): void {
$this->load->language('extension/opencart/payment/free_checkout');
$json = [];
if (!isset($this->session->data['order_id'])) {
$json['error'] = $this->language->get('error_order');
}
if (!isset($this->session->data['payment_method']) || $this->session->data['payment_method']['code'] != 'free_checkout.free_checkout') {
$json['error'] = $this->language->get('error_payment_method');
}
if (!$json) {
$this->load->model('checkout/order');
$this->model_checkout_order->addHistory($this->session->data['order_id'], $this->config->get('payment_free_checkout_order_status_id'));
$json['redirect'] = $this->url->link('checkout/success', 'language=' . $this->config->get('config_language'), true);
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}

View File

@ -0,0 +1,79 @@
<?php
namespace Opencart\Catalog\Controller\Extension\Opencart\Total;
/**
* Class Coupon
*
* @package
*/
class Coupon extends \Opencart\System\Engine\Controller {
/**
* @return string
*/
public function index(): string {
if ($this->config->get('total_coupon_status')) {
$this->load->language('extension/opencart/total/coupon');
$data['save'] = $this->url->link('extension/opencart/total/coupon.save', 'language=' . $this->config->get('config_language'), true);
$data['list'] = $this->url->link('checkout/cart.list', 'language=' . $this->config->get('config_language'), true);
if (isset($this->session->data['coupon'])) {
$data['coupon'] = $this->session->data['coupon'];
} else {
$data['coupon'] = '';
}
return $this->load->view('extension/opencart/total/coupon', $data);
}
return '';
}
/**
* @return void
*/
public function save(): void {
$this->load->language('extension/opencart/total/coupon');
$json = [];
if (isset($this->request->post['coupon'])) {
$coupon = $this->request->post['coupon'];
} else {
$coupon = '';
}
if (!$this->config->get('total_coupon_status')) {
$json['error'] = $this->language->get('error_status');
}
if ($coupon) {
$this->load->model('marketing/coupon');
$coupon_info = $this->model_marketing_coupon->getCoupon($coupon);
if (!$coupon_info) {
$json['error'] = $this->language->get('error_coupon');
}
}
if (!$json) {
if ($coupon) {
$json['success'] = $this->language->get('text_success');
$this->session->data['coupon'] = $coupon;
} else {
$json['success'] = $this->language->get('text_remove');
unset($this->session->data['coupon']);
}
unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}

View File

@ -0,0 +1,103 @@
<?php
namespace Opencart\Catalog\Controller\Extension\Opencart\Total;
/**
* Class Reward
*
* @package
*/
class Reward extends \Opencart\System\Engine\Controller {
/**
* @return string
*/
public function index(): string {
if ($this->config->get('total_reward_status')) {
$available = $this->customer->getRewardPoints();
$points_total = 0;
foreach ($this->cart->getProducts() as $product) {
if ($product['points']) {
$points_total += $product['points'];
}
}
if ($available && $points_total) {
$this->load->language('extension/opencart/total/reward');
$data['heading_title'] = sprintf($this->language->get('heading_title'), $available);
$data['entry_reward'] = sprintf($this->language->get('entry_reward'), $points_total);
$data['save'] = $this->url->link('extension/opencart/total/reward.save', 'language=' . $this->config->get('config_language'), true);
$data['list'] = $this->url->link('checkout/cart.list', 'language=' . $this->config->get('config_language'), true);
if (isset($this->session->data['reward'])) {
$data['reward'] = $this->session->data['reward'];
} else {
$data['reward'] = '';
}
return $this->load->view('extension/opencart/total/reward', $data);
}
}
return '';
}
/**
* @return void
*/
public function save(): void {
$this->load->language('extension/opencart/total/reward');
$json = [];
if (isset($this->request->post['reward'])) {
$reward = abs((int)$this->request->post['reward']);
} else {
$reward = 0;
}
$available = $this->customer->getRewardPoints();
$points_total = 0;
foreach ($this->cart->getProducts() as $product) {
if ($product['points']) {
$points_total += $product['points'];
}
}
if (!$this->config->get('total_reward_status')) {
$json['error'] = $this->language->get('error_reward');
}
if ($reward > $available) {
$json['error'] = sprintf($this->language->get('error_points'), $reward);
}
if ($reward > $points_total) {
$json['error'] = sprintf($this->language->get('error_maximum'), $points_total);
}
if (!$json) {
if ($reward) {
$json['success'] = $this->language->get('text_success');
$this->session->data['reward'] = $reward;
} else {
$json['success'] = $this->language->get('text_remove');
unset($this->session->data['reward']);
}
unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}

View File

@ -0,0 +1,172 @@
<?php
namespace Opencart\Catalog\Controller\Extension\Opencart\Total;
/**
* Class Shipping
*
* @package
*/
class Shipping extends \Opencart\System\Engine\Controller {
/**
* @return string
*/
public function index(): string {
if ($this->config->get('total_shipping_status') && $this->config->get('total_shipping_estimator') && $this->cart->hasShipping()) {
$this->load->language('extension/opencart/total/shipping');
if (isset($this->session->data['shipping_address'])) {
$data['postcode'] = $this->session->data['shipping_address']['postcode'];
$data['country_id'] = $this->session->data['shipping_address']['country_id'];
$data['zone_id'] = $this->session->data['shipping_address']['zone_id'];
} else {
$data['postcode'] = '';
$data['country_id'] = (int)$this->config->get('config_country_id');
$data['zone_id'] = '';
}
if (isset($this->session->data['shipping_method'])) {
$data['code'] = $this->session->data['shipping_method']['code'];
} else {
$data['code'] = '';
}
$this->load->model('localisation/country');
$data['countries'] = $this->model_localisation_country->getCountries();
$data['language'] = $this->config->get('config_language');
return $this->load->view('extension/opencart/total/shipping', $data);
}
return '';
}
/**
* @return void
*/
public function quote(): void {
$this->load->language('extension/opencart/total/shipping');
$json = [];
$keys = [
'postcode',
'country_id',
'zone_id'
];
foreach ($keys as $key) {
if (!isset($this->request->post[$key])) {
$this->request->post[$key] = '';
}
}
if (!$this->cart->hasProducts()) {
$json['error']['warning'] = $this->language->get('error_product');
}
if (!$this->cart->hasShipping()) {
$json['error']['warning'] = sprintf($this->language->get('error_no_shipping'), $this->url->link('information/contact', 'language=' . $this->config->get('config_language')));
}
$this->load->model('localisation/country');
$country_info = $this->model_localisation_country->getCountry((int)$this->request->post['country_id']);
if ($country_info && $country_info['postcode_required'] && (oc_strlen($this->request->post['postcode']) < 2 || oc_strlen($this->request->post['postcode']) > 10)) {
$json['error']['postcode'] = $this->language->get('error_postcode');
}
if ($this->request->post['country_id'] == '') {
$json['error']['country'] = $this->language->get('error_country');
}
if ($this->request->post['zone_id'] == '') {
$json['error']['zone'] = $this->language->get('error_zone');
}
if (!$json) {
if ($country_info) {
$country = $country_info['name'];
$iso_code_2 = $country_info['iso_code_2'];
$iso_code_3 = $country_info['iso_code_3'];
$address_format = $country_info['address_format'];
} else {
$country = '';
$iso_code_2 = '';
$iso_code_3 = '';
$address_format = '';
}
$this->load->model('localisation/zone');
$zone_info = $this->model_localisation_zone->getZone($this->request->post['zone_id']);
if ($zone_info) {
$zone = $zone_info['name'];
$zone_code = $zone_info['code'];
} else {
$zone = '';
$zone_code = '';
}
$this->session->data['shipping_address'] = [
'postcode' => $this->request->post['postcode'],
'zone_id' => $this->request->post['zone_id'],
'zone' => $zone,
'zone_code' => $zone_code,
'country_id' => $this->request->post['country_id'],
'country' => $country,
'iso_code_2' => $iso_code_2,
'iso_code_3' => $iso_code_3
];
$this->tax->setShippingAddress($this->request->post['country_id'], $this->request->post['zone_id']);
// Shipping Methods
$this->load->model('checkout/shipping_method');
$shipping_methods = $this->model_checkout_shipping_method->getMethods($this->session->data['shipping_address']);
if ($shipping_methods) {
$json['shipping_methods'] = $this->session->data['shipping_methods'] = $shipping_methods;
} else {
$json['error']['warning'] = sprintf($this->language->get('error_no_shipping'), $this->url->link('information/contact', 'language=' . $this->config->get('config_language')));
}
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
/**
* @return void
*/
public function save(): void {
$this->load->language('extension/opencart/total/shipping');
$json = [];
if (!empty($this->request->post['shipping_method'])) {
$shipping = explode('.', $this->request->post['shipping_method']);
if (!isset($shipping[0]) || !isset($shipping[1]) || !isset($this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]])) {
$json['error'] = $this->language->get('error_shipping');
}
} else {
$json['error'] = $this->language->get('error_shipping');
}
if (!$json) {
$this->session->data['shipping_method'] = $this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]];
$json['success'] = $this->language->get('text_success');
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}

View File

@ -0,0 +1,79 @@
<?php
namespace Opencart\Catalog\Controller\Extension\Opencart\Total;
/**
* Class Voucher
*
* @package
*/
class Voucher extends \Opencart\System\Engine\Controller {
/**
* @return string
*/
public function index(): string {
if ($this->config->get('total_voucher_status')) {
$this->load->language('extension/opencart/total/voucher');
$data['save'] = $this->url->link('extension/opencart/total/voucher.save', 'language=' . $this->config->get('config_language'), true);
$data['list'] = $this->url->link('checkout/cart.list', 'language=' . $this->config->get('config_language'), true);
if (isset($this->session->data['voucher'])) {
$data['voucher'] = $this->session->data['voucher'];
} else {
$data['voucher'] = '';
}
return $this->load->view('extension/opencart/total/voucher', $data);
}
return '';
}
/**
* @return void
*/
public function save(): void {
$this->load->language('extension/opencart/total/voucher');
$json = [];
if (isset($this->request->post['voucher'])) {
$voucher = (string)$this->request->post['voucher'];
} else {
$voucher = '';
}
if (!$this->config->get('total_voucher_status')) {
$json['error'] = $this->language->get('error_status');
}
if ($voucher) {
$this->load->model('checkout/voucher');
$voucher_info = $this->model_checkout_voucher->getVoucher($voucher);
if (!$voucher_info) {
$json['error'] = $this->language->get('error_voucher');
}
}
if (!$json) {
if ($voucher) {
$json['success'] = $this->language->get('text_success');
$this->session->data['voucher'] = $voucher;
} else {
$json['success'] = $this->language->get('text_remove');
unset($this->session->data['voucher']);
}
unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}

View File

@ -0,0 +1,3 @@
<?php
// Heading
$_['heading_title'] = 'test 123';

View File

@ -0,0 +1,3 @@
<?php
// Heading
$_['heading_title'] = 'test 123';

View File

@ -0,0 +1,9 @@
<?php
// Text
$_['text_captcha'] = 'Captcha';
// Entry
$_['entry_captcha'] = 'Enter the code in the box below';
// Error
$_['error_captcha'] = 'Verification code does not match the image!';

View File

@ -0,0 +1,21 @@
<?php
// Heading
$_['heading_title'] = 'Account';
// Text
$_['text_register'] = 'Register';
$_['text_login'] = 'Login';
$_['text_logout'] = 'Logout';
$_['text_forgotten'] = 'Forgotten Password';
$_['text_account'] = 'My Account';
$_['text_edit'] = 'Edit Account';
$_['text_password'] = 'Password';
$_['text_address'] = 'Address Book';
$_['text_wishlist'] = 'Wish List';
$_['text_order'] = 'Order History';
$_['text_download'] = 'Downloads';
$_['text_reward'] = 'Reward Points';
$_['text_return'] = 'Returns';
$_['text_transaction'] = 'Transactions';
$_['text_newsletter'] = 'Newsletter';
$_['text_subscription'] = 'Subscriptions';

View File

@ -0,0 +1,3 @@
<?php
// Heading
$_['heading_title'] = 'Best Sellers';

View File

@ -0,0 +1,3 @@
<?php
// Heading
$_['heading_title'] = 'Categories';

View File

@ -0,0 +1,3 @@
<?php
// Heading
$_['heading_title'] = 'Featured';

View File

@ -0,0 +1,3 @@
<?php
// Heading
$_['heading_title'] = 'Refine Search';

View File

@ -0,0 +1,7 @@
<?php
// Heading
$_['heading_title'] = 'Information';
// Text
$_['text_contact'] = 'Contact Us';
$_['text_sitemap'] = 'Site Map';

View File

@ -0,0 +1,3 @@
<?php
// Heading
$_['heading_title'] = 'Latest';

View File

@ -0,0 +1,3 @@
<?php
// Heading
$_['heading_title'] = 'Specials';

View File

@ -0,0 +1,7 @@
<?php
// Heading
$_['heading_title'] = 'Choose a Store';
// Text
$_['text_default'] = 'Default';
$_['text_store'] = 'Please choose the store you wish to visit.';

View File

@ -0,0 +1,9 @@
<?php
// Heading
$_['heading_title'] = 'Bank Transfer';
// Text
$_['text_instruction'] = 'Bank Transfer Instructions';
$_['text_description'] = 'Please transfer the total amount to the following bank account.';
$_['text_payment'] = 'Your order will not ship until we receive payment.';

View File

@ -0,0 +1,9 @@
<?php
// Heading
$_['heading_title'] = 'Cheque / Money Order';
// Text
$_['text_instruction'] = 'Cheque / Money Order Instructions';
$_['text_payable'] = 'Make Payable To: ';
$_['text_address'] = 'Send To: ';
$_['text_payment'] = 'Your order will not ship until we receive payment.';

View File

@ -0,0 +1,7 @@
<?php
// Heading
$_['heading_title'] = 'Cash On Delivery';
// Error
$_['error_order_id'] = 'No order ID in the session!';
$_['error_payment_method'] = 'Payment method is incorrect!';

View File

@ -0,0 +1,3 @@
<?php
// Heading
$_['heading_title'] = 'Free Checkout';

View File

@ -0,0 +1,6 @@
<?php
// Heading
$_['heading_title'] = 'Flat Rate';
// Text
$_['text_description'] = 'Flat Shipping Rate';

View File

@ -0,0 +1,6 @@
<?php
// Heading
$_['heading_title'] = 'Free Shipping';
// Text
$_['text_description'] = 'Free Shipping';

View File

@ -0,0 +1,6 @@
<?php
// Heading
$_['heading_title'] = 'Per Item';
// Text
$_['text_description'] = 'Per Item Shipping Rate';

View File

@ -0,0 +1,6 @@
<?php
// Heading
$_['heading_title'] = 'Pickup';
// Text
$_['text_description'] = 'Pickup From Store';

View File

@ -0,0 +1,6 @@
<?php
// Heading
$_['heading_title'] = 'Weight Based Shipping';
// Text
$_['text_weight'] = 'Weight:';

View File

@ -0,0 +1,15 @@
<?php
// Heading
$_['heading_title'] = 'Use Coupon Code';
// Text
$_['text_coupon'] = 'Coupon (%s)';
$_['text_success'] = 'Success: Your coupon discount has been applied!';
$_['text_remove'] = 'Success: Your coupon discount has been removed!';
// Entry
$_['entry_coupon'] = 'Enter your coupon here';
// Error
$_['error_coupon'] = 'Warning: Coupon is either invalid, expired or reached its usage limit!';
$_['error_status'] = 'Warning: Coupons are not enabled on this store!';

View File

@ -0,0 +1,4 @@
<?php
// Text
$_['text_credit'] = 'Store Credit';
$_['text_order_id'] = 'Order ID: #%s';

View File

@ -0,0 +1,3 @@
<?php
// Text
$_['text_handling'] = 'Handling Fee';

View File

@ -0,0 +1,3 @@
<?php
// Text
$_['text_low_order_fee'] = 'Low Order Fee';

View File

@ -0,0 +1,18 @@
<?php
// Heading
$_['heading_title'] = 'Use Reward Points (Available %s)';
// Text
$_['text_reward'] = 'Reward Points (%s)';
$_['text_order_id'] = 'Order ID: #%s';
$_['text_success'] = 'Success: Your reward points discount has been applied!';
$_['text_remove'] = 'Success: Your reward points discount has been removed!';
// Entry
$_['entry_reward'] = 'Points to use (Max %s)';
// Error
$_['error_reward'] = 'Warning: Please enter the amount of reward points to use!';
$_['error_points'] = 'Warning: You don\'t have %s reward points!';
$_['error_maximum'] = 'Warning: The maximum number of points that can be applied is %s!';
$_['error_status'] = 'Warning: Reward points are not enabled on this store!';

View File

@ -0,0 +1,21 @@
<?php
// Heading
$_['heading_title'] = 'Estimate Shipping &amp; Taxes';
// Text
$_['text_shipping_method'] = 'Shipping method options';
$_['text_destination'] = 'Enter your destination to get a shipping estimate.';
$_['text_estimate'] = 'Please select the preferred shipping method to use on this order.';
$_['text_success'] = 'Success: Your shipping estimate has been applied!';
// Entry
$_['entry_country'] = 'Country';
$_['entry_zone'] = 'Region / State';
$_['entry_postcode'] = 'Post Code';
// Error
$_['error_postcode'] = 'Postcode must be between 2 and 10 characters!';
$_['error_country'] = 'Please select a country!';
$_['error_zone'] = 'Please select a region / state!';
$_['error_shipping'] = 'Warning: Shipping method required!';
$_['error_no_shipping'] = 'Warning: No Shipping options are available. Please <a href="%s">contact us</a> for assistance!';

View File

@ -0,0 +1,3 @@
<?php
// Text
$_['text_sub_total'] = 'Sub-Total';

View File

@ -0,0 +1,3 @@
<?php
// Text
$_['text_total'] = 'Total';

View File

@ -0,0 +1,15 @@
<?php
// Heading
$_['heading_title'] = 'Use Gift Certificate';
// Text
$_['text_voucher'] = 'Gift Certificate (%s)';
$_['text_success'] = 'Success: Your gift certificate discount has been applied!';
$_['text_remove'] = 'Success: Your gift certificate discount has been removed!';
// Entry
$_['entry_voucher'] = 'Enter your gift certificate code here';
// Error
$_['error_voucher'] = 'Warning: Gift Certificate is either invalid or the balance has been used up!';
$_['error_status'] = 'Warning: Gift Certificate are not enabled on this store!';

View File

@ -0,0 +1,45 @@
<?php
namespace Opencart\Catalog\Model\Extension\Opencart\Fraud;
/**
* Class Ip
*
* @package
*/
class Ip extends \Opencart\System\Engine\Model {
/**
* @param array $order_info
*
* @return int
*/
public function check(array $order_info): int {
$status = false;
if ($order_info['customer_id']) {
$this->load->model('account/customer');
$results = $this->model_account_customer->getIps($order_info['customer_id']);
foreach ($results as $result) {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "fraud_ip` WHERE `ip` = '" . $this->db->escape($result['ip']) . "'");
if ($query->num_rows) {
$status = true;
break;
}
}
} else {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "fraud_ip` WHERE `ip` = '" . $this->db->escape($order_info['ip']) . "'");
if ($query->num_rows) {
$status = true;
}
}
if ($status) {
return (int)$this->config->get('fraud_ip_order_status_id');
} else {
return 0;
}
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace Opencart\Catalog\Model\Extension\Opencart\Module;
/**
* Class Bestseller
*
* @package
*/
class Bestseller extends \Opencart\Catalog\Model\Catalog\Product {
/**
* @param int $limit
*
* @return array
*/
public function getBestSellers(int $limit): array {
// Storing some sub queries so that we are not typing them out multiple times.
$sql = "SELECT *, `pd`.`name`, `p`.`image`, `pb`.`total`, " . $this->statement['discount'] . ", " . $this->statement['special'] . ", " . $this->statement['reward'] . ", " . $this->statement['review'] . " FROM `" . DB_PREFIX . "product_bestseller` `pb` LEFT JOIN `" . DB_PREFIX . "product_to_store` `p2s` ON (`p2s`.`product_id` = `pb`.`product_id` AND p2s.`store_id` = '" . (int)$this->config->get('config_store_id') . "') LEFT JOIN `" . DB_PREFIX . "product` `p` ON (`p`.`product_id` = `pb`.`product_id` AND `p`.`status` = '1' AND `p`.`date_available` <= NOW()) LEFT JOIN `" . DB_PREFIX . "product_description` `pd` ON (`pd`.`product_id` = `p`.`product_id`) WHERE `pd`.`language_id` = '" . (int)$this->config->get('config_language_id') . "' ORDER BY `pb`.`total` DESC LIMIT 0," . (int)$limit;
$product_data = (array)$this->cache->get('product.' . md5($sql));
if (!$product_data) {
$query = $this->db->query($sql);
$product_data = $query->rows;
$this->cache->set('product.' . md5($sql), $product_data);
}
return $product_data;
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace Opencart\Catalog\Model\Extension\Opencart\Module;
/**
* Class Latest
*
* @package
*/
class Latest extends \Opencart\Catalog\Model\Catalog\Product {
/**
* @param int $limit
*
* @return array
*/
public function getLatest(int $limit): array {
$sql = "SELECT DISTINCT *, `pd`.`name`, `p`.`image`, " . $this->statement['discount'] . ", " . $this->statement['special'] . ", " . $this->statement['reward'] . ", " . $this->statement['review'] . " FROM `" . DB_PREFIX . "product_to_store` `p2s` LEFT JOIN `" . DB_PREFIX . "product` `p` ON (`p`.`product_id` = `p2s`.`product_id` AND `p2s`.`store_id` = '" . (int)$this->config->get('config_store_id') . "' AND `p`.`status` = '1' AND `p`.`date_available` <= NOW()) LEFT JOIN `" . DB_PREFIX . "product_description` `pd` ON (`p`.`product_id` = `pd`.`product_id`) WHERE `pd`.`language_id` = '" . (int)$this->config->get('config_language_id') . "' ORDER BY `p`.`date_added` DESC LIMIT 0," . (int)$limit;
$product_data = $this->cache->get('product.' . md5($sql));
if (!$product_data) {
$query = $this->db->query($sql);
$product_data = $query->rows;
$this->cache->set('product.' . md5($sql), $product_data);
}
return (array)$product_data;
}
}

View File

@ -0,0 +1,51 @@
<?php
namespace Opencart\Catalog\Model\Extension\Opencart\Payment;
/**
* Class BankTransfer
*
* @package
*/
class BankTransfer extends \Opencart\System\Engine\Model {
/**
* @param array $address
*
* @return array
*/
public function getMethods(array $address = []): array {
$this->load->language('extension/opencart/payment/bank_transfer');
if ($this->cart->hasSubscription()) {
$status = false;
} elseif (!$this->config->get('config_checkout_payment_address')) {
$status = true;
} elseif (!$this->config->get('payment_bank_transfer_geo_zone_id')) {
$status = true;
} else {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone_to_geo_zone` WHERE `geo_zone_id` = '" . (int)$this->config->get('payment_bank_transfer_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;
}
}
$method_data = [];
if ($status) {
$option_data['bank_transfer'] = [
'code' => 'bank_transfer.bank_transfer',
'name' => $this->language->get('heading_title')
];
$method_data = [
'code' => 'bank_transfer',
'name' => $this->language->get('heading_title'),
'option' => $option_data,
'sort_order' => $this->config->get('payment_bank_transfer_sort_order')
];
}
return $method_data;
}
}

View File

@ -0,0 +1,51 @@
<?php
namespace Opencart\Catalog\Model\Extension\Opencart\Payment;
/**
* Class Cheque
*
* @package
*/
class Cheque extends \Opencart\System\Engine\Model {
/**
* @param array $address
*
* @return array
*/
public function getMethods(array $address = []): array {
$this->load->language('extension/opencart/payment/cheque');
if ($this->cart->hasSubscription()) {
$status = false;
} elseif (!$this->config->get('config_checkout_payment_address')) {
$status = true;
} elseif (!$this->config->get('payment_cheque_geo_zone_id')) {
$status = true;
} else {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone_to_geo_zone` WHERE `geo_zone_id` = '" . (int)$this->config->get('payment_cheque_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;
}
}
$method_data = [];
if ($status) {
$option_data['cheque'] = [
'code' => 'cheque.cheque',
'name' => $this->language->get('heading_title')
];
$method_data = [
'code' => 'cheque',
'name' => $this->language->get('heading_title'),
'option' => $option_data,
'sort_order' => $this->config->get('payment_cheque_sort_order')
];
}
return $method_data;
}
}

View File

@ -0,0 +1,53 @@
<?php
namespace Opencart\Catalog\Model\Extension\Opencart\Payment;
/**
* Class COD
*
* @package
*/
class COD extends \Opencart\System\Engine\Model {
/**
* @param array $address
*
* @return array
*/
public function getMethods(array $address = []): array {
$this->load->language('extension/opencart/payment/cod');
if ($this->cart->hasSubscription()) {
$status = false;
} elseif (!$this->cart->hasShipping()) {
$status = false;
} elseif (!$this->config->get('config_checkout_payment_address')) {
$status = true;
} elseif (!$this->config->get('payment_cod_geo_zone_id')) {
$status = true;
} else {
$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')");
if ($query->num_rows) {
$status = true;
} else {
$status = false;
}
}
$method_data = [];
if ($status) {
$option_data['cod'] = [
'code' => 'cod.cod',
'name' => $this->language->get('heading_title')
];
$method_data = [
'code' => 'cod',
'name' => $this->language->get('heading_title'),
'option' => $option_data,
'sort_order' => $this->config->get('payment_cod_sort_order')
];
}
return $method_data;
}
}

View File

@ -0,0 +1,53 @@
<?php
namespace Opencart\Catalog\Model\Extension\Opencart\Payment;
/**
* Class FreeCheckout
*
* @package
*/
class FreeCheckout extends \Opencart\System\Engine\Model {
/**
* @param array $address
*
* @return array
*/
public function getMethods(array $address = []): array {
$this->load->language('extension/opencart/payment/free_checkout');
$total = $this->cart->getTotal();
if (!empty($this->session->data['vouchers'])) {
$amounts = array_column($this->session->data['vouchers'], 'amount');
} else {
$amounts = [];
}
$total = $total + array_sum($amounts);
if ((float)$total <= 0.00) {
$status = true;
} elseif ($this->cart->hasSubscription()) {
$status = false;
} else {
$status = false;
}
$method_data = [];
if ($status) {
$option_data['free_checkout'] = [
'code' => 'free_checkout.free_checkout',
'name' => $this->language->get('heading_title')
];
$method_data = [
'code' => 'free_checkout',
'name' => $this->language->get('heading_title'),
'option' => $option_data,
'sort_order' => $this->config->get('payment_free_checkout_sort_order')
];
}
return $method_data;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View File

@ -0,0 +1,168 @@
<?php
namespace Opencart\Catalog\Model\Extension\Opencart\Total;
/**
* Class Coupon
*
* @package
*/
class Coupon extends \Opencart\System\Engine\Model {
/**
* @param array $totals
* @param array $taxes
* @param float $total
*
* @return void
*/
public function getTotal(array &$totals, array &$taxes, float &$total): void {
if (isset($this->session->data['coupon'])) {
$this->load->language('extension/opencart/total/coupon', 'coupon');
$this->load->model('marketing/coupon');
$coupon_info = $this->model_marketing_coupon->getCoupon($this->session->data['coupon']);
if ($coupon_info) {
$discount_total = 0;
$products = $this->cart->getProducts();
if (!$coupon_info['product']) {
$sub_total = $this->cart->getSubTotal();
} else {
$sub_total = 0;
foreach ($products as $product) {
if (in_array($product['product_id'], $coupon_info['product'])) {
$sub_total += $product['total'];
}
}
}
if ($coupon_info['type'] == 'F') {
$coupon_info['discount'] = min($coupon_info['discount'], $sub_total);
}
foreach ($products as $product) {
$discount = 0;
if (!$coupon_info['product']) {
$status = true;
} else {
$status = in_array($product['product_id'], $coupon_info['product']);
}
if ($status) {
if ($coupon_info['type'] == 'F') {
$discount = $coupon_info['discount'] * ($product['total'] / $sub_total);
} elseif ($coupon_info['type'] == 'P') {
$discount = $product['total'] / 100 * $coupon_info['discount'];
}
if ($product['tax_class_id']) {
$tax_rates = $this->tax->getRates($product['total'] - ($product['total'] - $discount), $product['tax_class_id']);
foreach ($tax_rates as $tax_rate) {
if ($tax_rate['type'] == 'P') {
$taxes[$tax_rate['tax_rate_id']] -= $tax_rate['amount'];
}
}
}
}
$discount_total += $discount;
}
if ($coupon_info['shipping'] && isset($this->session->data['shipping_method']['cost']) && isset($this->session->data['shipping_method']['tax_class_id'])) {
if (!empty($this->session->data['shipping_method']['tax_class_id'])) {
$tax_rates = $this->tax->getRates($this->session->data['shipping_method']['cost'], $this->session->data['shipping_method']['tax_class_id']);
foreach ($tax_rates as $tax_rate) {
if ($tax_rate['type'] == 'P') {
$taxes[$tax_rate['tax_rate_id']] -= $tax_rate['amount'];
}
}
}
$discount_total += $this->session->data['shipping_method']['cost'];
}
// If discount greater than total
if ($discount_total > $total) {
$discount_total = $total;
}
if ($discount_total > 0) {
$totals[] = [
'extension' => 'opencart',
'code' => 'coupon',
'title' => sprintf($this->language->get('coupon_text_coupon'), $this->session->data['coupon']),
'value' => -$discount_total,
'sort_order' => (int)$this->config->get('total_coupon_sort_order')
];
$total -= $discount_total;
}
}
}
}
/**
* @param array $order_info
* @param array $order_total
*
* @return int
*/
public function confirm(array $order_info, array $order_total): int {
$code = '';
$start = strpos($order_total['title'], '(') + 1;
$end = strrpos($order_total['title'], ')');
if ($start && $end) {
$code = substr($order_total['title'], $start, $end - $start);
}
if ($code) {
$status = true;
$coupon_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "coupon` WHERE `code` = '" . $this->db->escape($code) . "' AND `status` = '1'");
if ($coupon_query->num_rows) {
$this->load->model('marketing/coupon');
$coupon_total = $this->model_marketing_coupon->getTotalHistoriesByCoupon($code);
if ($coupon_query->row['uses_total'] > 0 && ($coupon_total >= $coupon_query->row['uses_total'])) {
$status = false;
}
if ($order_info['customer_id']) {
$customer_total = $this->model_marketing_coupon->getTotalHistoriesByCustomerId($code, $order_info['customer_id']);
if ($coupon_query->row['uses_customer'] > 0 && ($customer_total >= $coupon_query->row['uses_customer'])) {
$status = false;
}
}
} else {
$status = false;
}
if ($status) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "coupon_history` SET `coupon_id` = '" . (int)$coupon_query->row['coupon_id'] . "', `order_id` = '" . (int)$order_info['order_id'] . "', `customer_id` = '" . (int)$order_info['customer_id'] . "', `amount` = '" . (float)$order_total['value'] . "', `date_added` = NOW()");
} else {
return $this->config->get('config_fraud_status_id');
}
}
return 0;
}
/**
* @param int $order_id
*
* @return void
*/
public function unconfirm(int $order_id): void {
$this->db->query("DELETE FROM `" . DB_PREFIX . "coupon_history` WHERE `order_id` = '" . (int)$order_id . "'");
}
}

View File

@ -0,0 +1,60 @@
<?php
namespace Opencart\Catalog\Model\Extension\Opencart\Total;
/**
* Class Credit
*
* @package
*/
class Credit extends \Opencart\System\Engine\Model {
/**
* @param array $totals
* @param array $taxes
* @param float $total
*
* @return void
*/
public function getTotal(array &$totals, array &$taxes, float &$total): void {
$this->load->language('extension/opencart/total/credit');
$balance = $this->customer->getBalance();
if ((float)$balance) {
$credit = min($balance, $total);
if ((float)$credit > 0) {
$totals[] = [
'extension' => 'opencart',
'code' => 'credit',
'title' => $this->language->get('text_credit'),
'value' => -$credit,
'sort_order' => (int)$this->config->get('total_credit_sort_order')
];
$total -= $credit;
}
}
}
/**
* @param array $order_info
* @param array $order_total
*
* @return void
*/
public function confirm(array $order_info, array $order_total): void {
$this->load->language('extension/opencart/total/credit');
if ($order_info['customer_id']) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "customer_transaction` SET `customer_id` = '" . (int)$order_info['customer_id'] . "', `order_id` = '" . (int)$order_info['order_id'] . "', `description` = '" . $this->db->escape(sprintf($this->language->get('text_order_id'), (int)$order_info['order_id'])) . "', `amount` = '" . (float)$order_total['value'] . "', `date_added` = NOW()");
}
}
/**
* @param int $order_id
*
* @return void
*/
public function unconfirm(int $order_id): void {
$this->db->query("DELETE FROM `" . DB_PREFIX . "customer_transaction` WHERE `order_id` = '" . (int)$order_id . "'");
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace Opencart\Catalog\Model\Extension\Opencart\Total;
/**
* Class Handling
*
* @package
*/
class Handling extends \Opencart\System\Engine\Model {
/**
* @param array $totals
* @param array $taxes
* @param float $total
*
* @return void
*/
public function getTotal(array &$totals, array &$taxes, float &$total): void {
if (($this->cart->getSubTotal() > (float)$this->config->get('total_handling_total')) && ($this->cart->getSubTotal() > 0)) {
$this->load->language('extension/opencart/total/handling');
$totals[] = [
'extension' => 'opencart',
'code' => 'handling',
'title' => $this->language->get('text_handling'),
'value' => (float)$this->config->get('total_handling_fee'),
'sort_order' => (int)$this->config->get('total_handling_sort_order')
];
if ($this->config->get('total_handling_tax_class_id')) {
$tax_rates = $this->tax->getRates((float)$this->config->get('total_handling_fee'), (int)$this->config->get('total_handling_tax_class_id'));
foreach ($tax_rates as $tax_rate) {
if (!isset($taxes[$tax_rate['tax_rate_id']])) {
$taxes[$tax_rate['tax_rate_id']] = $tax_rate['amount'];
} else {
$taxes[$tax_rate['tax_rate_id']] += $tax_rate['amount'];
}
}
}
$total += (float)$this->config->get('total_handling_fee');
}
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace Opencart\Catalog\Model\Extension\Opencart\Total;
/**
* Class LowOrderFee
*
* @package
*/
class LowOrderFee extends \Opencart\System\Engine\Model {
/**
* @param array $totals
* @param array $taxes
* @param float $total
*
* @return void
*/
public function getTotal(array &$totals, array &$taxes, float &$total): void {
if ($this->cart->getSubTotal() && ($this->cart->getSubTotal() < (float)$this->config->get('total_low_order_fee_total'))) {
$this->load->language('extension/opencart/total/low_order_fee');
$totals[] = [
'extension' => 'opencart',
'code' => 'low_order_fee',
'title' => $this->language->get('text_low_order_fee'),
'value' => (float)$this->config->get('total_low_order_fee_fee'),
'sort_order' => (int)$this->config->get('total_low_order_fee_sort_order')
];
if ($this->config->get('total_low_order_fee_tax_class_id')) {
$tax_rates = $this->tax->getRates($this->config->get('total_low_order_fee_fee'), $this->config->get('total_low_order_fee_tax_class_id'));
foreach ($tax_rates as $tax_rate) {
if (!isset($taxes[$tax_rate['tax_rate_id']])) {
$taxes[$tax_rate['tax_rate_id']] = $tax_rate['amount'];
} else {
$taxes[$tax_rate['tax_rate_id']] += $tax_rate['amount'];
}
}
}
$total += $this->config->get('total_low_order_fee_fee');
}
}
}

View File

@ -0,0 +1,105 @@
<?php
namespace Opencart\Catalog\Model\Extension\Opencart\Total;
/**
* Class Reward
*
* @package
*/
class Reward extends \Opencart\System\Engine\Model {
/**
* @param array $totals
* @param array $taxes
* @param float $total
*
* @return void
*/
public function getTotal(array &$totals, array &$taxes, float &$total): void {
if (isset($this->session->data['reward'])) {
$this->load->language('extension/opencart/total/reward', 'reward');
$points = $this->customer->getRewardPoints();
if ($this->session->data['reward'] <= $points) {
$discount_total = 0;
$points_total = 0;
foreach ($this->cart->getProducts() as $product) {
if ($product['points']) {
$points_total += $product['points'];
}
}
$points = min($points, $points_total);
foreach ($this->cart->getProducts() as $product) {
$discount = 0;
if ($product['points']) {
$discount = $product['total'] * ($this->session->data['reward'] / $points_total);
if ($product['tax_class_id']) {
$tax_rates = $this->tax->getRates($product['total'] - ($product['total'] - $discount), $product['tax_class_id']);
foreach ($tax_rates as $tax_rate) {
if ($tax_rate['type'] == 'P') {
$taxes[$tax_rate['tax_rate_id']] -= $tax_rate['amount'];
}
}
}
}
$discount_total += $discount;
}
$totals[] = [
'extension' => 'opencart',
'code' => 'reward',
'title' => sprintf($this->language->get('reward_text_reward'), $this->session->data['reward']),
'value' => -$discount_total,
'sort_order' => (int)$this->config->get('total_reward_sort_order')
];
$total -= $discount_total;
}
}
}
/**
* @param array $order_info
* @param array $order_total
*
* @return int
*/
public function confirm(array $order_info, array $order_total): int {
$this->load->language('extension/opencart/total/reward');
$points = 0;
$start = strpos($order_total['title'], '(') + 1;
$end = strrpos($order_total['title'], ')');
if ($start && $end) {
$points = substr($order_total['title'], $start, $end - $start);
}
$this->load->model('account/customer');
if ($order_info['customer_id'] && $this->model_account_customer->getRewardTotal($order_info['customer_id']) >= $points) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "customer_reward` SET `customer_id` = '" . (int)$order_info['customer_id'] . "', `order_id` = '" . (int)$order_info['order_id'] . "', `description` = '" . $this->db->escape(sprintf($this->language->get('text_order_id'), (int)$order_info['order_id'])) . "', `points` = '" . (float) - $points . "', `date_added` = NOW()");
} else {
return $this->config->get('config_fraud_status_id');
}
return 0;
}
/**
* @param int $order_id
*
* @return void
*/
public function unconfirm(int $order_id): void {
$this->db->query("DELETE FROM `" . DB_PREFIX . "customer_reward` WHERE `order_id` = '" . (int)$order_id . "' AND `points` < '0'");
}
}

View File

@ -0,0 +1,41 @@
<?php
namespace Opencart\Catalog\Model\Extension\Opencart\Total;
/**
* Class Shipping
*
* @package
*/
class Shipping extends \Opencart\System\Engine\Model {
/**
* @param array $totals
* @param array $taxes
* @param float $total
*
* @return void
*/
public function getTotal(array &$totals, array &$taxes, float &$total): void {
if ($this->cart->hasShipping() && isset($this->session->data['shipping_method'])) {
$totals[] = [
'extension' => 'opencart',
'code' => 'shipping',
'title' => $this->session->data['shipping_method']['name'],
'value' => $this->session->data['shipping_method']['cost'],
'sort_order' => (int)$this->config->get('total_shipping_sort_order')
];
if (isset($this->session->data['shipping_method']['tax_class_id'])) {
$tax_rates = $this->tax->getRates($this->session->data['shipping_method']['cost'], $this->session->data['shipping_method']['tax_class_id']);
foreach ($tax_rates as $tax_rate) {
if (!isset($taxes[$tax_rate['tax_rate_id']])) {
$taxes[$tax_rate['tax_rate_id']] = $tax_rate['amount'];
} else {
$taxes[$tax_rate['tax_rate_id']] += $tax_rate['amount'];
}
}
}
$total += $this->session->data['shipping_method']['cost'];
}
}
}

View File

@ -0,0 +1,37 @@
<?php
namespace Opencart\Catalog\Model\Extension\Opencart\Total;
/**
* Class SubTotal
*
* @package
*/
class SubTotal extends \Opencart\System\Engine\Model {
/**
* @param array $totals
* @param array $taxes
* @param float $total
*
* @return void
*/
public function getTotal(array &$totals, array &$taxes, float &$total): void {
$this->load->language('extension/opencart/total/sub_total');
$sub_total = $this->cart->getSubTotal();
if (!empty($this->session->data['vouchers'])) {
foreach ($this->session->data['vouchers'] as $voucher) {
$sub_total += $voucher['amount'];
}
}
$totals[] = [
'extension' => 'opencart',
'code' => 'sub_total',
'title' => $this->language->get('text_sub_total'),
'value' => $sub_total,
'sort_order' => (int)$this->config->get('total_sub_total_sort_order')
];
$total += $sub_total;
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace Opencart\Catalog\Model\Extension\Opencart\Total;
/**
* Class Tax
*
* @package
*/
class Tax extends \Opencart\System\Engine\Model {
/**
* @param array $totals
* @param array $taxes
* @param float $total
*
* @return void
*/
public function getTotal(array &$totals, array &$taxes, float &$total): void {
foreach ($taxes as $key => $value) {
if ($value > 0) {
$totals[] = [
'extension' => 'opencart',
'code' => 'tax',
'title' => $this->tax->getRateName($key),
'value' => $value,
'sort_order' => (int)$this->config->get('total_tax_sort_order')
];
$total += $value;
}
}
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace Opencart\Catalog\Model\Extension\Opencart\Total;
/**
* Class Total
*
* @package
*/
class Total extends \Opencart\System\Engine\Model {
/**
* @param array $totals
* @param array $taxes
* @param float $total
*
* @return void
*/
public function getTotal(array &$totals, array &$taxes, float &$total): void {
$this->load->language('extension/opencart/total/total');
$totals[] = [
'extension' => 'opencart',
'code' => 'total',
'title' => $this->language->get('text_total'),
'value' => $total,
'sort_order' => (int)$this->config->get('total_total_sort_order')
];
}
}

View File

@ -0,0 +1,85 @@
<?php
namespace Opencart\Catalog\Model\Extension\Opencart\Total;
/**
* Class Voucher
*
* @package
*/
class Voucher extends \Opencart\System\Engine\Model {
/**
* @param array $totals
* @param array $taxes
* @param float $total
*
* @return void
*/
public function getTotal(array &$totals, array &$taxes, float &$total): void {
if (isset($this->session->data['voucher'])) {
$this->load->language('extension/opencart/total/voucher', 'voucher');
$this->load->model('checkout/voucher');
$voucher_info = $this->model_checkout_voucher->getVoucher($this->session->data['voucher']);
if ($voucher_info) {
$amount = min($voucher_info['amount'], $total);
if ($amount > 0) {
$totals[] = [
'extension' => 'opencart',
'code' => 'voucher',
'title' => sprintf($this->language->get('voucher_text_voucher'), $this->session->data['voucher']),
'value' => -$amount,
'sort_order' => (int)$this->config->get('total_voucher_sort_order')
];
$total -= $amount;
} else {
unset($this->session->data['voucher']);
}
} else {
unset($this->session->data['voucher']);
}
}
}
/**
* @param array $order_info
* @param array $order_total
*
* @return int
*/
public function confirm(array $order_info, array $order_total): int {
$code = '';
$start = strpos($order_total['title'], '(') + 1;
$end = strrpos($order_total['title'], ')');
if ($start && $end) {
$code = substr($order_total['title'], $start, $end - $start);
}
if ($code) {
$this->load->model('checkout/voucher');
$voucher_info = $this->model_checkout_voucher->getVoucher($code);
if ($voucher_info) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "voucher_history` SET `voucher_id` = '" . (int)$voucher_info['voucher_id'] . "', `order_id` = '" . (int)$order_info['order_id'] . "', `amount` = '" . (float)$order_total['value'] . "', `date_added` = NOW()");
} else {
return $this->config->get('config_fraud_status_id');
}
}
return 0;
}
/**
* @param int $order_id
*
* @return void
*/
public function unconfirm(int $order_id): void {
$this->db->query("DELETE FROM `" . DB_PREFIX . "voucher_history` WHERE `order_id` = '" . (int)$order_id . "'");
}
}

View File

@ -0,0 +1,10 @@
<fieldset>
<legend>{{ text_captcha }}</legend>
<div class="mb-3 required">
<label for="input-captcha" class="form-label">{{ entry_captcha }}</label> <input type="text" name="captcha" value="" id="input-captcha" class="form-control mb-1"/>
<div id="captcha">
<img src="index.php?route=extension/opencart/captcha/basic.captcha" alt=""/>
</div>
<div id="error-captcha" class="invalid-feedback"></div>
</div>
</fieldset>

View File

@ -0,0 +1,13 @@
<div class="list-group mb-3">
{% if not logged %}
<a href="{{ login }}" class="list-group-item">{{ text_login }}</a> <a href="{{ register }}" class="list-group-item">{{ text_register }}</a> <a href="{{ forgotten }}" class="list-group-item">{{ text_forgotten }}</a>
{% endif %}
<a href="{{ account }}" class="list-group-item">{{ text_account }}</a>
{% if logged %}
<a href="{{ edit }}" class="list-group-item">{{ text_edit }}</a> <a href="{{ password }}" class="list-group-item">{{ text_password }}</a>
{% endif %}
<a href="{{ address }}" class="list-group-item">{{ text_address }}</a> <a href="{{ wishlist }}" class="list-group-item">{{ text_wishlist }}</a> <a href="{{ order }}" class="list-group-item">{{ text_order }}</a> <a href="{{ download }}" class="list-group-item">{{ text_download }}</a><a href="{{ subscription }}" class="list-group-item">{{ text_subscription }}</a> <a href="{{ reward }}" class="list-group-item">{{ text_reward }}</a> <a href="{{ return }}" class="list-group-item">{{ text_return }}</a> <a href="{{ transaction }}" class="list-group-item">{{ text_transaction }}</a> <a href="{{ newsletter }}" class="list-group-item">{{ text_newsletter }}</a>
{% if logged %}
<a href="{{ logout }}" class="list-group-item">{{ text_logout }}</a>
{% endif %}
</div>

View File

@ -0,0 +1,43 @@
<div id="carousel-banner-{{ module }}" class="carousel slide{% if effect == 'fade' %} carousel-fade{% endif %}" data-bs-ride="carousel">
{% if indicators and banners|batch(items)|length > 1 %}
<div class="carousel-indicators">
{% set banner_row = 0 %}
{% for banner in banners|batch(items) %}
<button type="button" data-bs-target="#carousel-banner-{{ module }}" data-bs-slide-to="{{ banner_row }}"{% if banner_row == 0 %} class="active"{% endif %}></button>
{% set banner_row = banner_row + 1 %}
{% endfor %}
</div>
{% endif %}
<div class="carousel-inner">
{% set banner_row = 0 %}
{% for carousel in banners|batch(items) %}
<div class="carousel-item{% if banner_row == 0 %} active{% endif %}">
<div class="row justify-content-center">
{% for banner in carousel %}
<div class="col-{{ (12 / items)|round }} text-center">
{% if banner.link %}
<a href="{{ banner.link }}"><img src="{{ banner.image }}" alt="{{ banner.title }}" class="img-fluid"/></a>
{% else %}
<img src="{{ banner.image }}" alt="{{ banner.title }}" class="img-fluid"/>
{% endif %}
</div>
{% endfor %}
</div>
</div>
{% set banner_row = banner_row + 1 %}
{% endfor %}
</div>
{% if controls and banners|batch(items)|length > 1 %}
<button type="button" class="carousel-control-prev" data-bs-target="#carousel-banner-{{ module }}" data-bs-slide="prev"><span class="fa-solid fa-chevron-left"></span></button>
<button type="button" class="carousel-control-next" data-bs-target="#carousel-banner-{{ module }}" data-bs-slide="next"><span class="fa-solid fa-chevron-right"></span></button>
{% endif %}
</div>
<script type="text/javascript"><!--
$(document).ready(function () {
new bootstrap.Carousel(document.querySelector('#carousel-banner-{{ module }}'), {
ride: 'carousel',
interval: {{ interval|escape('js') }},
wrap: true
});
});
//--></script>

View File

@ -0,0 +1,6 @@
<h3>{{ heading_title }}</h3>
<div class="row{% if axis == 'horizontal' %} row-cols-1 row-cols-sm-2 row-cols-md-3 row-cols-xl-4{% endif %}">
{% for product in products %}
<div class="col mb-3">{{ product }}</div>
{% endfor %}
</div>

View File

@ -0,0 +1,17 @@
<div class="list-group mb-3">
{% for category in categories %}
{% if category.category_id == category_id %}
<a href="{{ category.href }}" class="list-group-item active">{{ category.name }}</a>
{% if category.children %}
{% for child in category.children %}
{% if child.category_id == child_id %}
<a href="{{ child.href }}" class="list-group-item active">&nbsp;&nbsp;&nbsp;- {{ child.name }}</a>
{% else %}
<a href="{{ child.href }}" class="list-group-item">&nbsp;&nbsp;&nbsp;- {{ child.name }}</a>
{% endif %}
{% endfor %}
{% endif %}
{% else %} <a href="{{ category.href }}" class="list-group-item">{{ category.name }}</a>
{% endif %}
{% endfor %}
</div>

View File

@ -0,0 +1,6 @@
<h3>{{ heading_title }}</h3>
<div class="row{% if axis == 'horizontal' %} row-cols-1 row-cols-sm-2 row-cols-md-3 row-cols-xl-4{% endif %}">
{% for product in products %}
<div class="col mb-3">{{ product }}</div>
{% endfor %}
</div>

View File

@ -0,0 +1,32 @@
<div class="card">
<div class="card-header"><i class="fa-solid fa-filter"></i> {{ heading_title }}</div>
<div class="list-group list-group-flush">
{% for filter_group in filter_groups %}
<a class="list-group-item">{{ filter_group.name }}</a>
<div class="list-group-item">
<div id="filter-group-{{ filter_group.filter_group_id }}">
{% for filter in filter_group.filter %}
<div class="form-check">
<input type="checkbox" name="filter[]" value="{{ filter.filter_id }}" id="input-filter-{{ filter.filter_id }}" class="form-check-input"{% if filter.filter_id in filter_category %} checked{% endif %}/>
<label for="input-filter-{{ filter.filter_id }}" class="form-check-label">{{ filter.name }}</label>
</div>
{% endfor %}
</div>
</div>
{% endfor %}
</div>
<div class="card-footer text-right">
<button type="button" id="button-filter" class="btn btn-primary"><i class="fa-solid fa-filter"></i> {{ button_filter }}</button>
</div>
</div>
<script type="text/javascript"><!--
$('#button-filter').on('click', function () {
filter = [];
$('input[name^=\'filter\']:checked').each(function (element) {
filter.push(this.value);
});
location = '{{ action }}&filter=' + filter.join(',');
});
//--></script>

View File

@ -0,0 +1,6 @@
<div>
{% if heading_title %}
<h2>{{ heading_title }}</h2>
{% endif %}
{{ html }}
</div>

View File

@ -0,0 +1,9 @@
<div class="sidebar">
<ul class="nav nav-tabs nav-stacked">
{% for information in informations %}
<li><a href="{{ information.href }}">{{ information.title }}</a></li>
{% endfor %}
<li><a href="{{ contact }}">{{ text_contact }}</a></li>
<li><a href="{{ sitemap }}">{{ text_sitemap }}</a></li>
</ul>
</div>

View File

@ -0,0 +1,6 @@
<h3>{{ heading_title }}</h3>
<div class="row{% if axis == 'horizontal' %} row-cols-1 row-cols-sm-2 row-cols-md-3 row-cols-xl-4{% endif %}">
{% for product in products %}
<div class="col mb-3">{{ product }}</div>
{% endfor %}
</div>

View File

@ -0,0 +1,6 @@
<h3>{{ heading_title }}</h3>
<div class="row{% if axis == 'horizontal' %} row-cols-1 row-cols-sm-2 row-cols-md-3 row-cols-xl-4{% endif %}">
{% for product in products %}
<div class="col mb-3">{{ product }}</div>
{% endfor %}
</div>

View File

@ -0,0 +1,12 @@
<div class="card">
<div class="card-header">{{ heading_title }}</div>
<p style="text-align: center;">{{ text_store }}</p>
{% for store in stores %}
{% if store.store_id == store_id %}<a href="{{ store.url }}"><b>{{ store.name }}</b></a>
<br/>
{% else %}<a href="{{ store.url }}">{{ store.name }}</a>
<br/>
{% endif %}
{% endfor %}
<br/>
</div>

View File

@ -0,0 +1,39 @@
<fieldset>
<legend>{{ text_instruction }}</legend>
<p><b>{{ text_description }}</b></p>
<div class="border rounded p-3 mb-2">
<p>{{ bank }}</p>
<p>{{ text_payment }}</p>
</div>
<div class="text-end">
<button type="button" id="button-confirm" class="btn btn-primary">{{ button_confirm }}</button>
</div>
</fieldset>
<script type="text/javascript"><!--
$('#button-confirm').on('click', function () {
var element = this;
$.ajax({
url: 'index.php?route=extension/opencart/payment/bank_transfer.confirm&language={{ language }}',
dataType: 'json',
beforeSend: function () {
$(element).button('loading');
},
complete: function () {
$(element).button('reset');
},
success: function (json) {
if (json['error']) {
$('#alert').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa-solid fa-circle-exclamation"></i> ' + json['error'] + ' <button type="button" class="btn-close" data-bs-dismiss="alert"></button></div>');
}
if (json['redirect']) {
location = json['redirect'];
}
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
//--></script>

View File

@ -0,0 +1,42 @@
<fieldset>
<legend>{{ text_instruction }}</legend>
<div class="border rounded p-3 mb-2">
<p><b>{{ text_payable }}</b></p>
<p>{{ payable }}</p>
<b>{{ text_address }}</b>
<br/>
<p>{{ address }}</p>
<p>{{ text_payment }}</p>
</div>
<div class="text-end">
<button type="button" id="button-confirm" class="btn btn-primary">{{ button_confirm }}</button>
</div>
</fieldset>
<script type="text/javascript"><!--
$('#button-confirm').on('click', function () {
var element = this;
$.ajax({
url: 'index.php?route=extension/opencart/payment/cheque.confirm&language={{ language }}',
dataType: 'json',
beforeSend: function () {
$(element).button('loading');
},
complete: function () {
$(element).button('reset');
},
success: function (json) {
if (json['error']) {
$('#alert').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa-solid fa-circle-exclamation"></i> ' + json['error'] + ' <button type="button" class="btn-close" data-bs-dismiss="alert"></button></div>');
}
if (json['redirect']) {
location = json['redirect'];
}
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
//--></script>

View File

@ -0,0 +1,31 @@
<div class="text-end">
<button type="button" id="button-confirm" class="btn btn-primary">{{ button_confirm }}</button>
</div>
<script type="text/javascript"><!--
$('#button-confirm').on('click', function () {
var element = this;
$.ajax({
url: 'index.php?route=extension/opencart/payment/cod.confirm&language={{ language }}',
dataType: 'json',
beforeSend: function () {
$(element).button('loading');
},
complete: function () {
$(element).button('reset');
},
success: function (json) {
if (json['error']) {
$('#alert').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa-solid fa-circle-exclamation"></i> ' + json['error'] + ' <button type="button" class="btn-close" data-bs-dismiss="alert"></button></div>');
}
if (json['redirect']) {
location = json['redirect'];
}
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
//--></script>

View File

@ -0,0 +1,31 @@
<div class="text-end">
<button type="button" id="button-confirm" class="btn btn-primary">{{ button_confirm }}</button>
</div>
<script type="text/javascript"><!--
$('#button-confirm').on('click', function() {
var element = this;
$.ajax({
url: 'index.php?route=extension/opencart/payment/free_checkout.confirm&language={{ language }}',
dataType: 'json',
beforeSend: function () {
$(element).button('loading');
},
complete: function () {
$(element).button('reset');
},
success: function (json) {
if (json['error']) {
$('#alert').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa-solid fa-circle-exclamation"></i> ' + json['error'] + ' <button type="button" class="btn-close" data-bs-dismiss="alert"></button></div>');
}
if (json['redirect']) {
location = json['redirect'];
}
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
//--></script>

View File

@ -0,0 +1,16 @@
<div class="accordion-item">
<h2 class="accordion-header"><button type="button" class="accordion-button collapsed" data-bs-toggle="collapse" data-bs-target="#collapse-coupon">{{ heading_title }}</button></h2>
<div id="collapse-coupon" class="accordion-collapse collapse" data-bs-parent="#accordion">
<div class="accordion-body">
<form id="form-coupon" action="{{ save }}" method="post" data-oc-toggle="ajax" data-oc-load="{{ list }}" data-oc-target="#shopping-cart">
<div class="row mb-3">
<label for="input-coupon" class="col-md-4 col-form-label">{{ entry_coupon }}</label>
<div class="col-md-8">
<input type="text" name="coupon" value="{{ coupon }}" placeholder="{{ entry_coupon }}" id="input-coupon" class="form-control"/>
</div>
</div>
<div class="text-end"><button type="submit" class="btn btn-primary">{{ button_coupon }}</button></div>
</form>
</div>
</div>
</div>

View File

@ -0,0 +1,16 @@
<div class="accordion-item">
<h2 class="accordion-header"><button type="button" class="accordion-button collapsed" data-bs-toggle="collapse" data-bs-target="#collapse-reward">{{ heading_title }}</button></h2>
<div id="collapse-reward" class="accordion-collapse collapse" data-bs-parent="#accordion">
<div class="accordion-body">
<form id="form-reward" action="{{ save }}" method="post" data-oc-toggle="ajax" data-oc-load="{{ list }}" data-oc-target="#shopping-cart">
<div class="row mb-3">
<label for="input-reward" class="col-md-4 col-form-label">{{ entry_reward }}</label>
<div class="col-md-8">
<input type="text" name="reward" value="{{ reward }}" placeholder="{{ entry_reward }}" id="input-reward" class="form-control"/>
</div>
</div>
<div class="text-end"><button type="submit" class="btn btn-primary">{{ button_reward }}</button></div>
</form>
</div>
</div>
</div>

View File

@ -0,0 +1,211 @@
<div class="accordion-item">
<h2 class="accordion-header"><button type="button" class="accordion-button collapsed" data-bs-toggle="collapse" data-bs-target="#collapse-shipping">{{ heading_title }}</button></h2>
<div id="collapse-shipping" class="accordion-collapse collapse" data-bs-parent="#accordion">
<div class="accordion-body">
<form id="form-quote">
<p>{{ text_destination }}</p>
<div class="row mb-3 required">
<label for="input-country" class="col-md-4 col-form-label">{{ entry_country }}</label>
<div class="col-md-8">
<select name="country_id" id="input-country" class="form-select">
<option value="">{{ text_select }}</option>
{% for country in countries %}
<option value="{{ country.country_id }}"{% if country.country_id == country_id %} selected{% endif %}>{{ country.name }}</option>
{% endfor %}
</select>
<div id="error-country" class="invalid-feedback"></div>
</div>
</div>
<div class="row mb-3 required">
<label for="input-zone" class="col-md-4 col-form-label">{{ entry_zone }}</label>
<div class="col-md-8">
<select name="zone_id" id="input-zone" class="form-select"></select>
<div id="error-zone" class="invalid-feedback"></div>
</div>
</div>
<div class="row mb-3 required">
<label for="input-postcode" class="col-md-4 col-form-label">{{ entry_postcode }}</label>
<div class="col-md-8">
<input type="text" name="postcode" value="{{ postcode }}" placeholder="{{ entry_postcode }}" id="input-postcode" class="form-control"/>
<div id="error-postcode" class="invalid-feedback"></div>
</div>
</div>
<div class="text-end">
<button type="submit" id="button-quote" class="btn btn-primary">{{ button_quote }}</button>
</div>
</form>
</div>
</div>
<script type="text/javascript"><!--
$('#form-quote').on('submit', function (e) {
e.preventDefault();
$.ajax({
url: 'index.php?route=extension/opencart/total/shipping.quote&language={{ language }}',
type: 'post',
data: $('#form-quote').serialize(),
dataType: 'json',
beforeSend: function () {
$('#button-quote').button('loading');
},
complete: function () {
$('#button-quote').button('reset');
},
success: function (json) {
$('.alert-dismissible').remove();
$('#form-shipping').find('.is-invalid').removeClass('is-invalid');
$('#form-shipping').find('.invalid-feedback').removeClass('d-block');
if (json['error']) {
if (json['error']['warning']) {
$('#alert').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa-solid fa-circle-exclamation"></i> ' + json['error']['warning'] + ' <button type="button" class="btn-close" data-bs-dismiss="alert"></button></div>');
}
for (key in json['error']) {
$('#input-' + key.replaceAll('_', '-')).addClass('is-invalid').find('.form-control, .form-select, .form-check-input, .form-check-label').addClass('is-invalid');
$('#error-' + key.replaceAll('_', '-')).html(json['error'][key]).addClass('d-block');
}
}
if (json['shipping_methods']) {
$('#modal-shipping').remove();
html = '<div id="modal-shipping" class="modal">';
html += ' <div class="modal-dialog">';
html += ' <div class="modal-content">';
html += ' <div class="modal-header">';
html += ' <h4 class="modal-title">{{ text_shipping_method }}</h4>';
html += ' <button type="button" class="btn-close" data-bs-dismiss="modal"></button>';
html += ' </div>';
html += ' <div class="modal-body">';
html += ' <form id="form-shipping">';
html += ' <p>{{ text_estimate }}</p>';
for (i in json['shipping_methods']) {
html += '<p><strong>' + json['shipping_methods'][i]['name'] + '</strong></p>';
if (!json['shipping_methods'][i]['error']) {
for (j in json['shipping_methods'][i]['quote']) {
html += '<div class="form-check">';
var code = i + '-' + j.replaceAll('_', '-');
html += '<input type="radio" name="shipping_method" value="' + json['shipping_methods'][i]['quote'][j]['code'] + '" id="input-shipping-method-' + code + '"';
if (json['shipping_methods'][i]['quote'][j]['code'] == '{{ code }}') {
html += ' checked';
}
html += '/>';
html += ' <label for="input-shipping-method-' + code + '">' + json['shipping_methods'][i]['quote'][j]['name'] + ' - ' + json['shipping_methods'][i]['quote'][j]['text'] + '</label>';
html += '</div>';
}
} else {
html += '<div class="alert alert-danger alert-dismissible">' + json['shipping_methods'][i]['error'] + '</div>';
}
}
html += ' <div class="text-end">';
html += ' <button type="submit" id="button-shipping-method" class="btn btn-primary">{{ button_shipping }}</button>';
html += ' </div>';
html += ' </form>';
html += ' </div>';
html += ' </div>';
html += ' </div>';
html += '</div>';
$('body').append(html);
$('#modal-shipping').modal('show');
}
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
$(document).on('submit', '#form-shipping', function (e) {
e.preventDefault();
$.ajax({
url: 'index.php?route=extension/opencart/total/shipping.save&language={{ language }}',
type: 'post',
data: $('#form-shipping').serialize(),
dataType: 'json',
contentType: 'application/x-www-form-urlencoded',
beforeSend: function () {
$('#button-shipping-method').button('loading');
},
complete: function () {
$('#button-shipping-method').button('reset');
},
success: function (json) {
$('.alert-dismissible').remove();
if (json['error']) {
$('#alert').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa-solid fa-circle-exclamation"></i> ' + json['error'] + ' <button type="button" class="btn-close" data-bs-dismiss="alert"></button></div>');
}
if (json['success']) {
$('#alert').prepend('<div class="alert alert-success alert-dismissible"><i class="fa-solid fa-circle-exclamation"></i> ' + json['success'] + ' <button type="button" class="btn-close" data-bs-dismiss="alert"></button></div>');
$('#shopping-cart').load('index.php?route=checkout/cart.list&language={{ language }}');
$('#modal-shipping').modal('hide');
}
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
$('#input-country').on('change', function () {
var element = this;
$.ajax({
url: 'index.php?route=localisation/country&country_id=' + this.value + '&language={{ language }}',
dataType: 'json',
beforeSend: function () {
$(element).prop('disabled', true);
$('#input-zone').prop('disabled', true);
},
complete: function () {
$(element).prop('disabled', false);
$('#input-zone').prop('disabled', false);
},
success: function (json) {
if (json['postcode_required'] == '1') {
$('#input-postcode').parent().parent().addClass('required');
} else {
$('#input-postcode').parent().parent().removeClass('required');
}
html = '<option value="">{{ text_select }}</option>';
if (json['zone'] && json['zone'] != '') {
for (i = 0; i < json['zone'].length; i++) {
html += '<option value="' + json['zone'][i]['zone_id'] + '"';
if (json['zone'][i]['zone_id'] == '{{ zone_id }}') {
html += ' selected';
}
html += '>' + json['zone'][i]['name'] + '</option>';
}
} else {
html += '<option value="0" selected>{{ text_none }}</option>';
}
$('#input-zone').html(html);
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
$('#input-country').trigger('change');
//--></script>
</div>

View File

@ -0,0 +1,19 @@
<div class="accordion-item">
<h2 class="accordion-header"><button type="button" class="accordion-button collapsed" data-bs-toggle="collapse" data-bs-target="#collapse-voucher">{{ heading_title }}</button></h2>
<div id="collapse-voucher" class="accordion-collapse collapse" data-bs-parent="#accordion">
<div class="accordion-body">
<form id="form-voucher" action="{{ save }}" method="post" data-oc-toggle="ajax" data-oc-load="{{ list }}" data-oc-target="#shopping-cart">
<div class="row mb-3">
<label for="input-voucher" class="col-md-4 col-form-label">{{ entry_voucher }}</label>
<div class="col-md-8">
<input type="text" name="voucher" value="{{ voucher }}" placeholder="{{ entry_voucher }}" id="input-voucher" class="form-control"/>
</div>
</div>
<div class="text-end"><button type="submit" class="btn btn-primary">{{ button_voucher }}</button></div>
</form>
</div>
</div>
</div>