Custom fields output too much margin around each one

  • Posts: 31
  • Thank you received: 1
  • Hikashop Business
4 years 3 weeks ago #325264

-- HikaShop version -- : 4.4.0
-- Joomla version -- : 3.9.1
-- PHP version -- : 7.4.10
-- Browser(s) name and version -- : Firefox Developer 82.0b9(64-bit)

Hi

I am using 6 custom fields per line item on a product line.

When it produces the output for the custom feilds in emails and reports there is way to much space around each one.

I want to modify all the output so this space is reduced.

I have found one example but the custom fields seem to be embedded inside {LINEVAR:PRODUCT_NAME}. assuming this is where they are.

Example
Email - "Order creation notification"


Where do I find the layout or construction of {LINEVAR:PRODUCT_NAME}.

Thank you

Neville Matthews

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
4 years 3 weeks ago #325266

Hi,

When you edit the email via the menu System>Emails, you have first the HTML version where you found the tag you're talking about, in the HTML code of the email.
If you scroll down, you'll see the "preload" area, which contains PHP code to generate all the tags used in the HTML version.
There, you'll see this piece of code which adds the data of the custom item fields to the product name tag:

if(!empty($itemFields)){
			foreach($itemFields as $field){
				$namekey = $field->field_namekey;
				if(empty($item->$namekey) || !strlen($item->$namekey)) continue;
				$t .= '<p>'.$fieldsClass->getFieldName($field).': '.$fieldsClass->show($field,$item->$namekey,'admin_email').'</p>';
			}
		}
Note that this code is for custom fields of the table "item" that the customer can fill in on the product details page above the add to cart button.
If you're talking about custom fields of the table "product", that you fill in in the backend product edition area, then it's these pieces of code:
$null = null;
	$fields = null;
	$texts['CUSTOMFIELD_NAME'] = '';
	$texts['FOOTER_COLSPAN'] = 3;
	if(hikashop_level(1)){
		$fields = $fieldsClass->getFields('display:mail_admin_notif=1',$null,'product');
		if(!empty($fields)){
			$product_customfields = array();
			$usefulFields = array();
			foreach($fields as $field){
				$namekey = $field->field_namekey;
				foreach($productClass->all_products as $product){
					if(!empty($product->$namekey)){
						$usefulFields[] = $field;
						break;
					}
				}
			}
			$fields = $usefulFields;
		}
		if(!empty($fields)){
			foreach($fields as $field){
				$texts['FOOTER_COLSPAN']++;
				$texts['CUSTOMFIELD_NAME'].='<td style="border-bottom:1px solid #ddd;padding-bottom:3px;text-align:right;color:#1c8faf !important;font-size:12px;font-weight:bold;">'.$fieldsClass->getFieldName($field).'</td>';
			}
		}
	}
$cartProduct['CUSTOMFIELD_VALUE'] = '';
		if(!empty($fields) && hikashop_level(1)){
			foreach($fields as $field){
				$namekey = $field->field_namekey;
				$productData = @$productClass->all_products[$item->product_id];
				$cartProduct['CUSTOMFIELD_VALUE'] .= '<td style="border-bottom:1px solid #ddd;padding-bottom:3px;text-align:right">'.(empty($productData->$namekey)?'':$fieldsClass->show($field,$productData->$namekey)).'</td>';
			}
		}

The following user(s) said Thank You: nevillematthews

Please Log in or Create an account to join the conversation.

Time to create page: 0.049 seconds
Powered by Kunena Forum