I'm trying to add a pdf file in my products via an input field in the admin product page, in the description section. For now I've created the field (product_file) in the view part and it sends the attached pdf. My issues is that I don't know exactly where the form sends the params and I can't assign my product_file field to save the name as a string in the database and at the same time to save the file as pdf in a folder in the main directory. I work with Joomla 3.4.1 and Virtuemart 3.0.6.4. Any advice is greatly appreciated.
p.s. I know that there is paid extension for VM3, but I do not have the resources for that.
You should create a new custom field with these settings:
Custom Field Type: String
Title: File
Layout position: file
Then put the following code to the: templates/*your_template/html/com_virtuemart/productdetails/default.php
(copied from: components/com_virtuemart/sublayouts/customfields.php
and customized position).
$product = $this->product;
$position = 'file';
$class = 'product-fields';
if (!empty($product->customfieldsSorted[$position])) {
$custom_title = null;
foreach ($product->customfieldsSorted[$position] as $field) {
if ( $field->is_hidden ) //OSP http://forum.virtuemart.net/index.php?topic=99320.0
continue;
?><div class="product-field product-field-type-<?php echo $field->field_type ?>">
<?php if (!$customTitle and $field->custom_title != $custom_title and $field->show_title) { ?>
<span class="product-fields-title-wrapper"><span class="product-fields-title"><strong><?php echo vmText::_ ($field->custom_title) ?></strong></span>
<?php if ($field->custom_tip) {
echo JHtml::tooltip ($field->custom_tip, vmText::_ ($field->custom_title), 'tooltip.png');
} ?></span>
<?php }
if (!empty($field->display)){
?><div class="product-field-display"><a href="images/stories/virtuemart/pdf/<?php echo $field->display; ?>">pdf file</a></div><?php
}
if (!empty($field->custom_desc)){
?><div class="product-field-desc"><?php echo vmText::_($field->custom_desc) ?></div> <?php
}
?>
</div>
<?php
$custom_title = $field->custom_title;
}
}
?>
The pdf file has to be added to images/stories/virtuemart/pdf/
folder.