1. Controller dosyası: catalog/controller/extension/module/ içine "m2_pricing.php" olarak kayedet ve eklentiyi aktif et..
class ControllerExtensionModuleM2Pricing extends Controller {
public function index() {
$data['heading_title'] = $this->language->get('heading_title');
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$m2 = $this->request->post['m2'];
$price_per_m2 = 10; // Örnek olarak 1 metrekare başına 10 birimlik fiyat
$total_price = $m2 * $price_per_m2;
$data['total_price'] = $total_price;
}
$data['entry_m2'] = $this->language->get('entry_m2');
$data['button_calculate'] = $this->language->get('button_calculate');
$data['action'] = $this->url->link('extension/module/m2_pricing', '', true);
return $this->load->view('extension/module/m2_pricing', $data);
}
protected function validate() {
if (!isset($this->request->post['m2']) || !is_numeric($this->request->post['m2']) || $this->request->post['m2'] <= 0) {
$this->error['warning'] = $this->language->get('error_m2');
}
return !$this->error;
}
}
// 2. View dosyası: catalog/view/theme/default/template/extension/module/m2_pricing.tpl
<div class="m2-pricing">
<h2><?php echo $heading_title; ?></h2>
<form action="<?php echo $action; ?>" method="post">
<div class="form-group">
<label for="m2"><?php echo $entry_m2; ?>:</label>
<input type="text" name="m2" id="m2" class="form-control" />
</div>
<button type="submit" class="btn btn-primary"><?php echo $button_calculate; ?></button>
</form>
<?php if (isset($total_price)) { ?>
<p>Total Price: <?php echo $total_price; ?></p>
<?php } ?>
</div>
// 3. Dil dosyası: catalog/language/en-gb/extension/module/m2_pricing.php
$_['heading_title'] = 'M2 Pricing';
$_['entry_m2'] = 'Square Meters:';
$_['button_calculate'] = 'Calculate';
$_['error_m2'] = 'Please enter a valid number for square meters.';
?>
Allah razı olsun sizden
edit: sanırım modülde küsüratlı seçim yapılmıyor onu nasıl yapabiliriz?