News:

Looking for documentation? Take a look on our wiki

Main Menu

Custom Field Types (Explained)

Started by PRO, March 07, 2012, 18:04:25 PM

Previous topic - Next topic

Garyk01

#105
Solved this problem as follows: - open file customfields.php
1) After the 1190 line enter code:
function displayCustomMedia_M ($media_id, $table = 'product', $absUrl = FALSE) {

if (!class_exists ('TableMedias'))
require(JPATH_VM_ADMINISTRATOR . DS . 'tables' . DS . 'medias.php');
$db = JFactory::getDBO ();
$data = new TableMedias($db);

$data->load ((int)$media_id);

if (!class_exists ('VmMediaHandler'))
require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'mediahandler.php');
$media = VmMediaHandler::createMedia ($data, $table);

return $media->displayMediaThumb ('class="m-image"', true, 'onclick="return false"', TRUE, TRUE, $absUrl);

}

2 ) Line 1143 :
return $this->displayCustomMedia ($value);
changed to code:
return $this->displayCustomMedia_M ($value);
3 ) Line 1237 :
$value = self::displayCustomMedia ($productCustom->custom_value);
changed to code:
$value = self::displayCustomMedia_M ($productCustom->custom_value);
Get something like this - see image

PS This decision does not affect other types of fields , for example - related produсt .
Of course modify the code system is very bad, but other solutions not yet found . Of course , you can connect an additional script ( Tooltips ) , but with it all is not well displayed , and once the script - the additional load .
Developers can take note of this decision or make easier - I will be very grateful.

[attachment cleanup by admin]

dmic

Hi,

We are using VM on a school site, where parents are paying fees for exams, art materials, etc.

We need to have a field where shoppers can add the name of the child (children) that the payment relates to. When I try to do this with a custom field it is not working correctly as it is looking for additional payment.

Is there a way to do this?

Thanks

Dave

PRO

Quote from: dmic on January 08, 2014, 18:52:28 PM
Hi,

We are using VM on a school site, where parents are paying fees for exams, art materials, etc.

We need to have a field where shoppers can add the name of the child (children) that the payment relates to. When I try to do this with a custom field it is not working correctly as it is looking for additional payment.

Is there a way to do this?

Thanks

Dave

why not do "user fields" so it's when they checkout
?

Garyk01

Quote from: lipes on June 06, 2012, 18:17:55 PM
yep now its showing the image CF in the Category with products... it's working with:
<?php $custom_title null
if (!empty(
$product->customfields)) {
foreach (
$product->customfields as $field) {
if (
$field->is_hidden //OSP http://forum.virtuemart.net/index.php?topic=99320.0
continue;
if (
$field->display) { ?>

<span class="product-field-display"><?php echo $field->display ?></span>
<?php ?> <?php ?> <?php }  ?>

Please forgive me for my english
Help me - faced with such a situation:
In the category of multiple identical items displayed in different colors to each other - for example:
- "Product white" - "Product black"  -  "Product red" -
category for each product displayed a customfield "image"
code:<?php $custom_title null
if (!empty(
$product->customfields)) {
foreach (
$product->customfields as $field) {
    if( 
$field->layout_pos=='image'){
if (
$field->is_hidden //OSP http://forum.virtuemart.net/index.php?topic=99320.0
continue;
if (
$field->display) { ?>

<span class="product-field-display"><?php echo $field->display ?></span>
<?php ?> <?php ?> <?php 
?>


But if in the admin panel to the "Product white " in Relatedprodutsts add "Product black ", "Product red", then in these products ("Product black", "Product red") does not appear in the category customfield "image".
What needs to be corrected?
The productdetails displays all ok ....

Help me please...

sondh

Hi,
I have a custom field on my site which allows to select cakes in KG. Now i have cakes eggless and with eggs... Is it possible to have a custom field where when some selects eggless he is charged per kg.. Every KG he selects if it is eggless the price differs... How can i achieve this?

Example:Normal 1Kg - 100, 2Kg - 200
But if he selects the option eggless. I want the price to increase as per kg e.g if 1Kg - +50, if 2Kg - +100

Possible?

lindapowers

I =Integer
P =Parent
B= Bolean (True)

?????????????????????

leealex

Quote from: Garyk01 on February 18, 2014, 20:23:43 PM
Quote from: lipes on June 06, 2012, 18:17:55 PM
yep now its showing the image CF in the Category with products... it's working with:
<?php $custom_title null
if (!empty(
$product->customfields)) {
foreach (
$product->customfields as $field) {
if (
$field->is_hidden //OSP http://forum.virtuemart.net/index.php?topic=99320.0
continue;
if (
$field->display) { ?>

<span class="product-field-display"><?php echo $field->display ?></span>
<?php ?> <?php ?> <?php }  ?>

Please forgive me for my english
Help me - faced with such a situation:
In the category of multiple identical items displayed in different colors to each other - for example:
- "Product white" - "Product black"  -  "Product red" -
category for each product displayed a customfield "image"
code:<?php $custom_title null
if (!empty(
$product->customfields)) {
foreach (
$product->customfields as $field) {
    if( 
$field->layout_pos=='image'){
if (
$field->is_hidden //OSP http://forum.virtuemart.net/index.php?topic=99320.0
continue;
if (
$field->display) { ?>

<span class="product-field-display"><?php echo $field->display ?></span>
<?php ?> <?php ?> <?php 
?>


But if in the admin panel to the "Product white " in Relatedprodutsts add "Product black ", "Product red", then in these products ("Product black", "Product red") does not appear in the category customfield "image".
What needs to be corrected?
The productdetails displays all ok ....

Help me please...

I have the same problem, can anyone help us?  :'(



[attachment cleanup by admin]

komir

#112
Quote from: leealex on May 16, 2014, 11:49:05 AM
Quote from: Garyk01 on February 18, 2014, 20:23:43 PM
Quote from: lipes on June 06, 2012, 18:17:55 PM
yep now its showing the image CF in the Category with products... it's working with:
<?php $custom_title null
if (!empty(
$product->customfields)) {
foreach (
$product->customfields as $field) {
if (
$field->is_hidden //OSP http://forum.virtuemart.net/index.php?topic=99320.0
continue;
if (
$field->display) { ?>

<span class="product-field-display"><?php echo $field->display ?></span>
<?php ?> <?php ?> <?php }  ?>

Please forgive me for my english
Help me - faced with such a situation:
In the category of multiple identical items displayed in different colors to each other - for example:
- "
Product white" - "Product black"  -  "Product red" -
category for each product displayed a customfield "image"
code:<?php $custom_title null
if (!empty(
$product->customfields)) {
foreach (
$product->customfields as $field) {
    if( 
$field->layout_pos=='image'){
if (
$field->is_hidden //OSP http://forum.virtuemart.net/index.php?topic=99320.0
continue;
if (
$field->display) { ?>

<span class="product-field-display"><?php echo $field->display ?></span>
<?php ?> <?php ?> <?php 
?>


But if in the admin panel to the "Product white " in Relatedprodutsts add "Product black ", "Product red", then in these products ("Product black", "Product red") does not appear in the category customfield "image".
What needs to be corrected?
The productdetails displays all ok ....

Help me please...

I have the same problem, can anyone help us?  :'(
No one ? :(

patben

<?php  foreach ($product->customfields as $catproduct)?>
<?php echo $catproduct->field_type?>


I use some code like this in category page but it shows only one fieldtype per product and not all is any other code i can use. I care about the E field type but in some products that have i it display S and in other E, products have both E and S field type. I dont want to display the field type i want to use it for an If condition. And it work only in product that display the E field type.

Thank you

vieke

Quote from: PRO on March 08, 2012, 19:13:18 PM
Using a String for external images


Create a Custom field  type "string" named "external"
In Edit Product apply the field. Paste the url to the image in the field.
This below is the code for displaying the image.

<div class="product-fields">
       <?php
       $custom_title = null;
       foreach ($this->product->customfieldsSorted[external] as $field) {
      if ($field->display) {
          ?>
          <?php if ($field->custom_title != $custom_title) { ?>
            <img src="<?php echo $field->display ?>" alt="<?php echo $this->product->product_name ?>"  />
<?php } ?>
          <?php } ?> <?php } ?>
        </div>


Using a String to Link to related articles, installation instructions etc.


Create a Custom field  type "string" with the name "Installation Instructions" or whatever you want the anchor text to be.
Assign it to the position "link"
In Edit Product apply the field. Paste the url
This below is the code for displaying the link.

<div class="product-fields">
       <?php
       $custom_title = null;
       foreach ($this->product->customfieldsSorted[link] as $field) {
      if ($field->display) {
          ?>
          <?php if ($field->custom_title != $custom_title) { ?>
             <a href="<?php echo $field->display ?>" ><?php echo JText::_($field->custom_title); ?></a>
<?php } ?>
          <?php } ?> <?php } ?>
        </div>

i tried this, but for me, the custom field renders with a label and inside an input field, does anybody have any idea why this is an how i can fix this ?

This is my php


<?php echo "<a href='" $field->display "'>" vmText::($field->custom_title) . "</a>" ?>


but in the frontend it renders like this:


<span class="product-field-display"><input id="1960" checked="checked" type="radio" value="196" name="customPrice[0][28]"><label for="1960" class="other-customfield">http://google.com </label></span>

be

Hi,

I used the layout position to show my customfield where I need it.
But now I have a field from the field-type "Allgemeine Variable für Produktvarianten" (i don't know how this is called in english) and use this as a list width different standardvalues.
I added a screenshot with all customfield values.

My problem now is if i want to output the customfield in that way:

$custom_title = null;
    foreach ($this->product->customfieldsSorted[Ausgabe] as $field) { ?>
            <?php if ($field->display) {
                if (
$field->custom_title != $custom_title) { ?>

                    <span class="product-fields-title" ><?php echo JText::_($field->custom_title); ?></span>
                <?php ?>
                <span class="product-field-display"><?php echo JText::_($field->display); ?></span>
            <?php ?>
    <?php }


The field will not be shown. What have I to change to get this work?

Cheers

PRO

Quote from: be on March 13, 2017, 18:37:12 PM
Hi,

I used the layout position to show my customfield where I need it.
But now I have a field from the field-type "Allgemeine Variable für Produktvarianten" (i don't know how this is called in english) and use this as a list width different standardvalues.
I added a screenshot with all customfield values.

My problem now is if i want to output the customfield in that way:

$custom_title = null;
    foreach ($this->product->customfieldsSorted[Ausgabe] as $field) { ?>
            <?php if ($field->display) {
                if (
$field->custom_title != $custom_title) { ?>

                    <span class="product-fields-title" ><?php echo JText::_($field->custom_title); ?></span>
                <?php ?>
                <span class="product-field-display"><?php echo JText::_($field->display); ?></span>
            <?php ?>
    <?php }


The field will not be shown. What have I to change to get this work?

Cheers


what vm version,  and where are you trying to have it display?

annpaul

Where is the attachment that explains all the custom field types??