Email format with custom fields aligned vertically (vs table row)

  • Posts: 9
  • Thank you received: 0
  • Hikashop Business
3 days 19 hours ago #371487

-- HikaShop version -- : 6.4.0
-- Joomla version -- : 6.0.3
-- PHP version -- : 8.3.30
-- Browser(s) name and version -- : Firefox 149.0.2
-- Error-message(debug-mod must be tuned on) -- : No error message. Email format question.

Thank you in advance for your help. We soft-launched the wmrhill.com site so we could work out any kinks.

Question: How can I adjust the email template so custom fields align vertically and not in a table row?

Is there an existing template that is more suitable to that scenario?

We are using about 6 custom fields for a quoting system, and some of those have more than one option (ie natural white or lug jar). So the email message is cutting off.

Cheers,
Mary Layman
This email address is being protected from spambots. You need JavaScript enabled to view it.

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

  • Posts: 85448
  • Thank you received: 13977
  • MODERATOR
3 days 4 hours ago #371488

Hi,

Changing the template of the email won't help.
Could you provide a screenshot of the email so that we can better understand the situation ?

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

  • Posts: 9
  • Thank you received: 0
  • Hikashop Business
2 days 11 hours ago #371501

Thanks for looking into it.

Attachments:

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

  • Posts: 9
  • Thank you received: 0
  • Hikashop Business
2 days 11 hours ago #371502

Please note we have different custom fields: Style, Mold Number, Color, Finish, Packed, Liners, Capacity. The screenshot only had a few showing based on the product. Other products have all of them.

Also, Quote Cart now goes to Plastic Containers.

Super admin area:
username: adminyaya
password: Sp@nky4Darla!q

Last edit: 2 days 11 hours ago by posurreal. Reason: found a different issue

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

  • Posts: 85448
  • Thank you received: 13977
  • MODERATOR
2 days 4 hours ago #371503

Hi,

The reason your email is getting cut off is that product custom fields are displayed as extra columns in the product table. With 6 or 7 custom fields, each one adds a column to the table, making it much wider than what email clients can display.

The solution is to move the custom fields from separate columns into the product name cell, so they display vertically below the product name instead. This requires editing two files for the email template: the HTML layout and the preload file.

Go to System > Emails in the HikaShop backend, then click on "order_creation_notification" to edit it. You will see two sections: "HTML version" and "Preload". You need to change both.

In the "HTML version" section:
Find and remove this line in the table header:
{TXT:CUSTOMFIELD_NAME}
And remove this line in the product row:
{LINEVAR:CUSTOMFIELD_VALUE}

This removes the extra columns from the table. But you still need to display the custom fields somewhere. So in the "Preload" section, you will move them inside the product name.

In the "Preload" section:
Find the block that generates CUSTOMFIELD_VALUE (around line 200):

$cartProduct['CUSTOMFIELD_VALUE'] = '';
if(!empty($fields) && hikashop_level(1)){
    foreach($fields as $field){
        $namekey = $field->field_namekey;
        $productData = @$productClass->all_products[$item->product_id];
        $field->currentElement = $productData;
        $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>';
    }
}
Replace it with:
$cartProduct['CUSTOMFIELD_VALUE'] = '';
if(!empty($fields) && hikashop_level(1)){
    foreach($fields as $field){
        $namekey = $field->field_namekey;
        $productData = @$productClass->all_products[$item->product_id];
        $field->currentElement = $productData;
        if(!empty($productData->$namekey)){
            $t .= '<p style="margin:2px 0;font-size:11px;color:#555;"><strong>'.$fieldsClass->getFieldName($field).':</strong> '.$fieldsClass->show($field,$productData->$namekey).'</p>';
        }
    }
}
This appends each custom field as a "Label: Value" line below the product name, inside the same cell. Your table will then only have the 4 standard columns (Product Name, Price, Quantity, Total) and the custom field values will be listed vertically under each product name.

If you also use the order admin notification or order status notification or order notification emails, you will need to apply the same changes to those email templates as well.

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

Time to create page: 0.235 seconds
Powered by Kunena Forum