I have created custom fields for my registration/checkout form with Opencart 2.0. They show up on the admin section under each order, and I have successfully added them to the order_invoice.tpl, but I need to add them to the confirmation email that is sent to the customer. I think I have located the correct controller file: catalog>controller>account>order.tpl But I think the issue is that the code used to print it out in the order_invoice.tpl is referencing a folder or file in the admin side.
This is the code I am trying to execute in catalog>view>theme>yourtheme>template>mail>order.tpl
<?php foreach ($account_custom_fields as $custom_field) { ?>
<strong><?php echo $custom_field['name']; ?></strong>:
<?php echo $custom_field['value']; ?><br />
<?php } ?>
This is the error I get:
Notice: Undefined variable: account_custom_fields in
/home/raphaelseventworks.com/www/ncbaorders/catalog/view/theme/journal2/template/mail/order.tpl
on line 70Warning: Invalid argument supplied for foreach() in
/home/raphaelseventworks.com/www/ncbaorders/catalog/view/theme/journal2/template/mail/order.tpl
on line 70
Does anyone know how print out custom fields in the order confirmation email? Or what code I need to add to catalog>controller>account>order.tpl to make this work?
Thanks!
If i am correct you are trying to send additional values to confirmation email after checkout
you need to work on
catalog/model/checkout/order.php::addOrderHistory()
After order is placed, the order history is changed, here you can load your view file and pass custom values form controller according to your need.
Good Luck
Related
I'm using multistore in Opencart 1.5. I want to show the total number of store that I have made and I want to show it in the setting/store page. Can anybody help?
The function $this->model_setting_store->getTotalStores() will return the number of stores excluding the default store.
So total number of stores:
In controller add the line:
$this->data['total_stores'] = $this->model_setting_store->getTotalStores()+1;
In template file use it as below:
<?php
echo $total_stores;
?>
However, to get it working in the controller file and avoid any errors first you need to load your model:
$this->load->model('setting/store');
I want to add a new field in virtuemart new product form, how can i do that ?
I add:
var $is_act = 1;
in "components\com_virtuemart\tables\products.php"
And
<?php echo VmHTML::checkbox('is_act', $this->product->is_act); ?>
And in database but what is appear is a checkbox without a string behind it, what is the wrong ?!
The VMHTL::checkbox function just create a check box without strings.
If you want to add string behind it you have to do something like this.
<?php echo JText::_('COM_VIRTUEMART_PRODUCT_IS_ACT') ?>
<?php echo VmHTML::checkbox('is_act', $this->product->is_act); ?>
And then COM_VIRTUEMART_PRODUCT_IS_ACT should be added inside language file too.
for more clearness just check VM default product_edit_information.php page inside
administrator/components/com_virtuemart/views/product/tmpl/
Hope its helps..
I am developing a Joomla 2.5 component. So I'm using Hello world example component for reference... In the edit view of the admin back end
<?php foreach($this->form->getFieldset('details') as $field): ?> <div>
<?php echo $field->label; echo $field->input;?> </div>
where the array $this->form->getFieldset('details') is stored.. and how to add new fields to the form that will store the data to another database table. where to change the fielda of the forms.
If you need to add more fields in your form then you can add new field in to the helloworld.xml browse to the following file on to
administrator->components->com_helloworld->models->forms->helloworld.xml
Open this file you will find the number of fields are listed over there you can add your own field by copy any of the field and rename it as you want.
You can also refer this link : J2.5:Developing a MVC Component/Adding backend actions
For example you want to add description field on to your form then you just need to add this line between the fieldset tag.
<field
name="description"
type="text"
label="COM_HELLOWORLD_HELLOWORLD_DESCRIPTION_LABEL"
description="COM_HELLOWORLD_HELLOWORLD_DESCRIPTION_DESC"
size="40"
class="inputbox"
default=""
/>
I would prefer you first read full tutorial of how to create MVC component for Joomla.Then you would be able to know how it works. Here the link :
J2.5:Developing a MVC Component/Developing a Basic Component
You may also use different form field type : Form field
Does anyone know how to, without purchasing an addon/extension, add php code to the product and category descriptions? If you try to add it automatically gets commented out when you save, e.g. <!-- <?php echo "test" ?> -->
Workaround: For anyone else.. I used borderless iframe to include an external .php file which contained the php code I needed ....
Where did I miss to add a line of code if I try to echo php variable inside OPENCART product.tpl file and it doesn't show up on site?
Notes: there is a field in database. I am able to save to this field from admin panel ( i added a custom field there).
Did You edit also the product controller to load the variable and pass it to the template? I guess not... Edit catalog/controller/product/product.php and add $this->data['MYVARIABLE'] = $product_info['MYVARIABLE']; somewhere before $this->render() is called.