forked from loadkpi/oc2_minimum_order_amount
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
236 additions
and
5 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<modification> | ||
<name>Munimal order amount</name> | ||
<code>minimal_order_amount</code> | ||
<version>0.3</version> | ||
|
||
<file path="catalog/controller/checkout/checkout.php"> | ||
<operation> | ||
<search><![CDATA[ | ||
// Validate minimum quantity requirements. | ||
]]></search> | ||
<add position="before"><![CDATA[ | ||
//start module minimal_order_amount | ||
$this->load->model('setting/setting'); | ||
$minimal_order_amount = $this->model_setting_setting->getSetting('module_minimal_order_amount'); | ||
if (@$minimal_order_amount['module_minimal_order_amount_value_amount_value'] && $this->cart->getSubtotal() < $minimal_order_amount['module_minimal_order_amount_value_amount_value']){ | ||
$this->session->data['error'] = str_replace('%s', $minimal_order_amount['module_minimal_order_amount_value_amount_value'], $minimal_order_amount['module_minimal_order_amount_value_error_msg']); | ||
$this->response->redirect($this->url->link('checkout/cart')); | ||
} | ||
//end module minimal_order_amount | ||
]]></add> | ||
</operation> | ||
</file> | ||
|
||
<file path="catalog/controller/checkout/cart.php"> | ||
<operation> | ||
<search><![CDATA[ | ||
if ($this->cart->hasProducts() || !empty($this->session->data['vouchers'])) { | ||
]]></search> | ||
<add position="after"><![CDATA[ | ||
///start module minimal_order_amount | ||
$this->load->model('setting/setting'); | ||
$minimal_order_amount = $this->model_setting_setting->getSetting('module_minimal_order_amount'); | ||
//end module minimal_order_amount | ||
]]></add> | ||
</operation> | ||
<operation> | ||
<search><![CDATA[ | ||
unset($this->session->data['error']); | ||
]]></search> | ||
<add position="after"><![CDATA[ | ||
//start module minimal_order_amount | ||
} elseif (@$minimal_order_amount['module_minimal_order_amount_value_amount_value'] && $this->cart->getSubtotal() < $minimal_order_amount['module_minimal_order_amount_value_amount_value']) { | ||
$this->load->language('module/minimal_order_amount'); | ||
$data['error_warning'] = str_replace('%s', $minimal_order_amount['module_minimal_order_amount_value_amount_value'], $minimal_order_amount['module_minimal_order_amount_value_error_msg']); | ||
//end module minimal_order_amount]]></add> | ||
</operation> | ||
</file> | ||
</modification> |
95 changes: 95 additions & 0 deletions
95
3.0.x.x/upload/admin/controller/extension/module/minimal_order_amount.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?php | ||
class ControllerExtensionModuleMinimalOrderAmount extends Controller { | ||
private $error = array(); | ||
|
||
public function index() { | ||
$this->load->language('extension/module/minimal_order_amount'); | ||
$this->load->model('setting/setting'); | ||
|
||
$this->document->setTitle($this->language->get('heading_title')); | ||
|
||
if ($this->request->server['REQUEST_METHOD'] == 'POST') { | ||
$data['value_amount_value'] = $this->request->post['module_minimal_order_amount_value_amount_value']; | ||
$data['value_error_msg'] = $this->request->post['module_minimal_order_amount_value_error_msg']; | ||
|
||
if ($this->validate()) { | ||
$this->model_setting_setting->editSetting('module_minimal_order_amount', $this->request->post); | ||
$this->session->data['success'] = $this->language->get('text_success'); | ||
$this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'], true)); | ||
} | ||
} else { | ||
$minimal_order_amount = $this->model_setting_setting->getSetting('module_minimal_order_amount'); | ||
|
||
$data['value_amount_value'] = (isset($minimal_order_amount['module_minimal_order_amount_value_amount_value'])) ? $minimal_order_amount['module_minimal_order_amount_value_amount_value'] : 0; | ||
$data['value_error_msg'] = (isset($minimal_order_amount['module_minimal_order_amount_value_error_msg'])) ? $minimal_order_amount['module_minimal_order_amount_value_error_msg'] : $this->language->get('value_error_msg'); | ||
} | ||
|
||
$data['store_currency'] = $this->config->get('config_currency'); | ||
|
||
if (isset($this->error['warning'])) { | ||
$data['error_warning'] = $this->error['warning']; | ||
} else { | ||
$data['error_warning'] = ''; | ||
} | ||
|
||
if (isset($this->error['amount_value'])) { | ||
$data['amount_value'] = $this->error['amount_value']; | ||
} else { | ||
$data['amount_value'] = ''; | ||
} | ||
|
||
if (isset($this->error['error_msg'])) { | ||
$data['error_msg'] = $this->error['error_msg']; | ||
} else { | ||
$data['error_msg'] = ''; | ||
} | ||
|
||
$data['breadcrumbs'] = array(); | ||
|
||
$data['breadcrumbs'][] = array( | ||
'text' => $this->language->get('text_home'), | ||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true), | ||
); | ||
|
||
$data['breadcrumbs'][] = array( | ||
'text' => $this->language->get('text_extension'), | ||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true) | ||
); | ||
|
||
$data['breadcrumbs'][] = array( | ||
'text' => $this->language->get('heading_title'), | ||
'href' => $this->url->link('extension/module/minimal_order_amount', 'user_token=' . $this->session->data['user_token'], true), | ||
); | ||
|
||
$data['action'] = $this->url->link('extension/module/minimal_order_amount', 'user_token=' . $this->session->data['user_token'], true); | ||
|
||
$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true); | ||
|
||
$data['header'] = $this->load->controller('common/header'); | ||
$data['column_left'] = $this->load->controller('common/column_left'); | ||
$data['footer'] = $this->load->controller('common/footer'); | ||
|
||
$this->response->setOutput($this->load->view('extension/module/minimal_order_amount', $data)); | ||
|
||
} | ||
|
||
protected function validate() { | ||
if (!$this->user->hasPermission('modify', 'extension/module/minimal_order_amount')) { | ||
$this->error['warning'] = $this->language->get('error_permission'); | ||
} | ||
|
||
if (!$this->request->post['module_minimal_order_amount_value_amount_value']) { | ||
$this->error['amount_value'] = $this->language->get('error_amount_value'); | ||
} | ||
|
||
if (!is_numeric($this->request->post['module_minimal_order_amount_value_amount_value'])) { | ||
$this->error['amount_value'] = $this->language->get('error_int_amount_value'); | ||
} | ||
|
||
if (!$this->request->post['module_minimal_order_amount_value_error_msg']) { | ||
$this->error['error_msg'] = $this->language->get('error_error_msg'); | ||
} | ||
|
||
return !$this->error; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
3.0.x.x/upload/admin/language/en-gb/extension/module/minimal_order_amount.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
// Heading | ||
$_['heading_title'] = 'Minimal Order Amount'; | ||
$_['heading_label'] = 'Edit minimal amount for your orders'; | ||
|
||
// Text | ||
$_['text_extension'] = 'Extensions'; | ||
$_['text_success'] = 'Success: You have modified minimal order amount!'; | ||
|
||
// Entry | ||
$_['entry_currency'] = 'Store Currency:'; | ||
$_['entry_amount_value'] = 'Minimal order amount:'; | ||
$_['entry_error_msg'] = 'Warning message:'; | ||
|
||
//Button | ||
$_['button_save'] = 'Save'; | ||
$_['button_cancel'] = 'Cancel'; | ||
|
||
//Other | ||
$_['value_error_msg'] = 'You must have an order with a minimum of %s USD to place your order!'; | ||
$_['tip_error_msg'] = 'You can use "%s" as a placeholder for you minimal amount value'; | ||
|
||
// Errors | ||
$_['error_permission'] = 'Warning: You do not have permission to change minimal order amount!'; | ||
$_['error_amount_value'] = 'Warning: "minimal order amount" is Required'; | ||
$_['error_int_amount_value'] = 'Warning: "minimal order amount" must be a Numeric'; | ||
$_['error_error_msg'] = 'Warning: "message" value is Required'; | ||
|
||
|
58 changes: 58 additions & 0 deletions
58
3.0.x.x/upload/admin/view/template/extension/module/minimal_order_amount.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{{ header }}{{ column_left }} | ||
<div id="content"> | ||
<div class="page-header"> | ||
<div class="container-fluid"> | ||
<div class="pull-right"> | ||
<button type="submit" form="form-module" data-toggle="tooltip" title="{{ button_save }}" class="btn btn-primary"><i class="fa fa-save"></i></button> | ||
<a href="{{ cancel }}" data-toggle="tooltip" title="{{ button_cancel }}" class="btn btn-default"><i class="fa fa-reply"></i></a></div> | ||
<h1>{{ heading_title }}</h1> | ||
<ul class="breadcrumb"> | ||
{% for breadcrumb in breadcrumbs %} | ||
<li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li> | ||
{% endfor %} | ||
</ul> | ||
</div> | ||
</div> | ||
<div class="container-fluid"> | ||
{% if error_warning %} | ||
<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> {{ error_warning }} | ||
<button type="button" class="close" data-dismiss="alert">×</button> | ||
</div | ||
{% endif %} | ||
<div class="panel panel-default"> | ||
<div class="panel-heading"> | ||
<h3 class="panel-title"><i class="fa fa-pencil"></i> {{ heading_label }}</h3> | ||
</div> | ||
<div class="panel-body"> | ||
<form action="{{ action }}" method="post" enctype="multipart/form-data" id="form-module" class="form-horizontal"> | ||
<div class="form-group"> | ||
<label class="col-sm-2 control-label">{{ entry_currency }}</label> | ||
<div class="col-sm-10"> | ||
<input type="text" disabled="disabled" value="{{ store_currency }}" class="form-control" /> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label class="col-sm-2 control-label">{{ entry_amount_value }}</label> | ||
<div class="col-sm-10"> | ||
<input type="text" value="{{ value_amount_value }}" class="form-control" name="module_minimal_order_amount_value_amount_value" /> | ||
{% if amount_value %} | ||
<div class="text-danger">{{ amount_value }}</div> | ||
{% endif %} | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label class="col-sm-2 control-label">{{ entry_error_msg }}</label> | ||
<div class="col-sm-10"> | ||
<textarea name="module_minimal_order_amount_value_error_msg" cols="40" rows="5" placeholder="{{ placeholder_error_msg }}" class="form-control">{{ value_error_msg }}</textarea> | ||
<p>{{ tip_error_msg }}</p> | ||
{% if error_msg %} | ||
<div class="text-danger">{{ error_msg }}</div> | ||
{% endif %} | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{{ footer }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters