Page 1 of 1

Customize shopper fields for custom logic

PostPosted: Fri Jan 08, 2016 1:46 pm
by admin
hello,

this guide shows how to customize the shopper fields per custom logic without modifying any core files in OPC or VM

if you need a custom field within checkout (and/or registration) the normal way of doing this is:

- create a BT field (Show in account maintaince) if you want it to be stored per customer datas and it's reload upon the customer login (#__virtuemart_userinfos + #__virtuemart_order_userinfos)
- OR create a "cart field" (Show in Cart form) (also called order field in opc) if you only want to associate the data with the orders created (only #__virtuemart_order_userinfos)

- this field can be skipped by the renderer in OPC if marked as "custom rendered" within opc shopper fields tab
- this field can be always required (i.e. empty and requires user input) when marked as "order field" within opc shopper fields config

- if you choose "custom rendering" in opc, you must manually modify /components/com_onepage/themes/YOUR THEME/onepage.unlogged (+logged+registration) .tpl.php files to render it inside the main checkout FORM.

- the fields in opc are rendered normally in /components/com_onepage/themes/YOUR THEME/overrides/list_user_fields (and _shipping).tpl.php where you can customize it per your own logic

- the OPC config is only related to the checkout (and/or registration) only, and it does not alter email/order details or 3rd party email or order managers
- if you create a normal BT field of type hidden or text, it will show within the order manager at the backend as a normal field (this is what you want)


- to hide the fields from order details view:
\components\com_virtuemart\views\orders\tmpl\details_order.php

locate:

Code: Select all
foreach ($this->userfields['fields'] as $field) {


and adjust with a line of (add this line under the foreach loop:

Code: Select all
if ($field['name'] === 'mycustomname') continue; // to filter by a specific name of the field
if ($field['type'] === 'hidden') continue; // to supress hidden fields


- the same can be done for PDF invoice here:
\components\com_virtuemart\views\invoice\tmpl\invoice_order.php

- and emails here:
\components\com_virtuemart\views\invoice\tmpl\mail_html_shopperaddresses.php

- and raw html emails here:
\components\com_virtuemart\views\invoice\tmpl\mail_raw_shopperaddresses.php


IMPORTANT:
you should copy the layout files to your own Joomla themes before you modify them. The general joomla override path is:

/templates/YOUR JOOMLA TEMPLATE/html/com_virtuemart/invoice (or other views like orders)/mail_html_shopperaddresses.php (whereas the mail_html is the layout, and shopperaddresses is a sublayout loaded from some other layout file)

best regards, stan