If possible, I prefer to do it using vqmod. otherwise it is fine. thanks alot.
Something like viewtopic.php?t=36625&start=40 but for OC 3.x. as file structure and template management completely changed.
Actually, it does.Displaying a download link, a text and a image is different, let alone saving such data.
Regardless, I would create an extra field in _product table for that situation, alter the admin part to save the desired field in each product and just get the field data in catalog. The files involved are :
admin/controller/catalog/product.php
admin/language/en-gb/catalog/product.php
admin/model/catalog/product.php
admin/view/template/catalog/product_form.twig
catalog/controller/product/product.php
catalog/language/en-gb/product/product.php
catalog/model/catalog/product.php
catalog/view/theme/default/template/product/product.twig
This structure assumes you're using english as your main language and the default template.
Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com
Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com
Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
I have one issue though, it is working perfectly for inputs of type text, select, radio ... and so on but I have not managed to get the value of the files such as pdfs and images. for images, just the path is sufficient but nothing is saved in the database for them. How can I resolve this? thanks.
For now am trying to save the value of input with type set to file. How can i do it? or am i approaching it the wrong way?
Code: Select all
$this->load->model('tool/image');
$this->load->model('tool/upload');
$data['products'] = array();
foreach ($this->cart->getProducts() as $product) {
if ($product['image']) {
$image = $this->model_tool_image->resize($product['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_cart_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_cart_height'));
} else {
$image = '';
}
$option_data = array();
foreach ($product['option'] as $option) {
if ($option['type'] != 'file') {
$value = $option['value'];
} else {
$upload_info = $this->model_tool_upload->getUploadByCode($option['value']);
if ($upload_info) {
$value = $upload_info['name'];
} else {
$value = '';
}
}
$option_data[] = array(
'name' => $option['name'],
'value' => (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value),
'type' => $option['type']
);
}
// Display prices
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
$unit_price = $this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax'));
$price = $this->currency->format($unit_price, $this->session->data['currency']);
$total = $this->currency->format($unit_price * $product['quantity'], $this->session->data['currency']);
} else {
$price = false;
$total = false;
}
$data['products'][] = array(
'cart_id' => $product['cart_id'],
'thumb' => $image,
'name' => $product['name'],
'model' => $product['model'],
'option' => $option_data,
'recurring' => ($product['recurring'] ? $product['recurring']['name'] : ''),
'quantity' => $product['quantity'],
'price' => $price,
'total' => $total,
'href' => $this->url->link('product/product', 'product_id=' . $product['product_id'])
);
}
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Code: Select all
if (isset($this->request->$_FILES['filename']['name'])){
$data['filename'] = $this->request->$_FILES['filename']['name'];
} elseif (isset($product_info)) {
$data['filename'] = $product_info['filename'];
} else {
$data['filename'] = '';
Code: Select all
<input type="file" name="filename" value="<?php echo $filename; ?>" id="filename" />
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Code: Select all
if (isset($this->request->get['product_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) {
$product_info = $this->model_catalog_product->getProduct($this->request->get['product_id']);
}
Code: Select all
<input type="text">
Code: Select all
<input type="file" />
Code: Select all
if (!empty($this->request->files['file']['name']) && is_file($this->request->files['file']['tmp_name'])) {
Code: Select all
if (isset($this->request->$_FILES['filename']['name'])){
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
It is uploaded on the same screen as the screen where uploads are made on the admin dashboard. i wanted to put a screen shot but i dont know how to get the image feature of this editor to work.
Oh actually, I just got another better idea. instead of using this file option which takes it from the user's machine, what type do i have to use to get that image uploader from OC;s storage? I think that will be much easier to debug and even its functionality is better.
Attachments
screenshot.png (4.26 KiB) Viewed 55486 times
Code: Select all
DIR_IMAGE . basename($product_info['filename']);
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
so I abandon this:
Code: Select all
if (!empty($this->request->files['file']['name']) && is_file($this->request->files['file']['tmp_name'])) {
Code: Select all
$data['filename'] = DIR_IMAGE . basename($product_info['filename']);
Users browsing this forum: No registered users and 4 guests