Author Topic: Custom Field Types (Explained)  (Read 101531 times)

Garyk01

  • Beginner
  • *
  • Posts: 13
Re: Custom Field Types (Explained)
« Reply #105 on: January 04, 2014, 14:57:42 pm »
Solved this problem as follows: - open file customfields.php
1) After the 1190 line enter code:
Code: [Select]
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 :
Code: [Select]
return $this->displayCustomMedia ($value);changed to code:
Code: [Select]
return $this->displayCustomMedia_M ($value);3 ) Line 1237 :
Code: [Select]
$value = self::displayCustomMedia ($productCustom->custom_value);changed to code:
Code: [Select]
$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

  • Beginner
  • *
  • Posts: 2
Re: Custom Field Types (Explained)
« Reply #106 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

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10275
  • VirtueMart Version: 3+
Re: Custom Field Types (Explained)
« Reply #107 on: January 16, 2014, 02:02:33 am »
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
?
I do NOT do development work for hire.

Garyk01

  • Beginner
  • *
  • Posts: 13
Re: Custom Field Types (Explained)
« Reply #108 on: February 18, 2014, 20:23:43 pm »
yep now its showing the image CF in the Category with products... it's working with:
Code: [Select]
<?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:
Code: [Select]
<?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

  • Beginner
  • *
  • Posts: 3
Re: Custom Field Types (Explained)
« Reply #109 on: May 05, 2014, 08:41:29 am »
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

  • Full Member
  • ***
  • Posts: 1332
  • If you're going through hell, keep going.
    • Venta de naranjas online y mandarinas
  • Skype Name: manu.gonzalez91
  • VirtueMart Version: Latest avi
Re: Custom Field Types (Explained)
« Reply #110 on: May 05, 2014, 13:15:37 pm »
I =Integer
P =Parent
B= Bolean (True)

?????????????????????
http://www.comenaranjas.com - Navel oranges and clementines from Spain

leealex

  • Beginner
  • *
  • Posts: 1
    • Easy Income
  • Skype Name: leealex82
  • VirtueMart Version: 2.6.0a
Re: Custom Field Types (Explained)
« Reply #111 on: May 16, 2014, 11:49:05 am »
yep now its showing the image CF in the Category with products... it's working with:
Code: [Select]
<?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:
Code: [Select]
<?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

  • Beginner
  • *
  • Posts: 29
    • Superfast SSD hosting
Re: Custom Field Types (Explained)
« Reply #112 on: September 27, 2014, 13:24:32 pm »
yep now its showing the image CF in the Category with products... it's working with:
Code: [Select]
<?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:
Code: [Select]
<?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

  • Jr. Member
  • **
  • Posts: 55
Re: Custom Field Types (Explained)
« Reply #113 on: December 23, 2014, 20:51:37 pm »
Code: [Select]
<?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

  • Beginner
  • *
  • Posts: 8
Re: Custom Field Types (Explained)
« Reply #114 on: April 17, 2015, 17:05:55 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

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

but in the frontend it renders like this:

Code: [Select]
<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

  • Beginner
  • *
  • Posts: 36
Re: Custom Field Types (Explained)
« Reply #115 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:
Code: [Select]
$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

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10275
  • VirtueMart Version: 3+
Re: Custom Field Types (Explained)
« Reply #116 on: March 14, 2017, 09:40:28 am »
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:
Code: [Select]
$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?
I do NOT do development work for hire.