Adding Custom Fields in OpenCart 1.5 Create Account, Using vQmod

  • SumoMe

EDIT Nov 5, 2011: This mod was tested on version 1.5.1.2

Last time I made a tutorial about adding custom fields in OpenCart 1.5, particularly in creating a new account. Today I will do the same using vQmod. But before I get to the tutorial, what is vQmod? According to its website,

VirtualQMod, or “vQmod” for short, is a new innovation in php modification override methods. Think of it as a universal “hook” that can be made to work with any project. The author goes by “Qphoria” (hence the Q), and is a co-developer of the OpenCart Ecommerce System

Basically, it is a safer alternative for modifying existing code (or “core files,” if I may), so that none of it is overwritten. In my opinion the advantage of using vQmod lies primarily in updating the original code while retaining one’s modifications, since the changes made are “virtual” and isolated beautifully.

The following tutorial requires you to be familiar of vQmod, so I suggest that you do some reading in the vQmod website. Have a look in the very intuitive Hello World example provided and surely you will get you right to it in no time.

Now for the tutorial, let’s get started:

Step 1: Add column to the database

Open your favorite MySQL database management tool or phpMyAdmin and look for the customer table. Add a new column for the salutation field, or you can also execute the following SQL script:

ALTER TABLE `customer` ADD `salutation` VARCHAR( 4 )
CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ;

Step 2: Install vQmod to OpenCart 1.5

Once you download vQmod, extract the vqmod folder in the package to the root folder of your OpenCart installation.

  • Install it by navigating to http://yourstore.com/vqmod/install in your web browser.
  • It will prompt you that the installation is successful afterwards.
  • Remember not to delete the install folder.

Step 3: Impose modifications in xml file.

Create an xml file in vqmod/xml folder and name it salutation_field_mod.xml (or whatever relevant file name you please). Open it and paste the following code:

<modification>
	<id>Salutation Field Modification</id>
	<version>1</version>
	<vqmver>1.0.8</vqmver>
	<author>maca</author>
	<file name="catalog/view/theme/default/template/account/register.tpl">
		<operation>
			<search position="before"><![CDATA[
				<td><span class="required">*</span> <?php echo $entry_firstname; ?></td>
			]]></search>
			<add><![CDATA[
				<td><?php echo $entry_salutation; ?></td>
				<td><input type="text" name="salutation" value="<?php echo $salutation; ?>" /></td>
				</tr>
				<tr>
			]]></add>
		</operation>
	</file>
	<file name="catalog/language/english/account/register.php">
		<operation>
			<search position="before"><![CDATA[
				$_['entry_firstname']      = 'First Name:';
			]]></search>
			<add><![CDATA[
				$_['entry_salutation'] = 'Salutation:';
			]]></add>
		</operation>
	</file>
	<file name="catalog/controller/account/register.php">
		<operation>
			<search position="before"><![CDATA[
				$this->data['entry_firstname'] = $this->language->get('entry_firstname');
			]]></search>
			<add><![CDATA[
				$this->data['entry_salutation'] = $this->language->get('entry_salutation');
			]]></add>
		</operation>
		<operation>
			<search position="before"><![CDATA[
				if (isset($this->request->post['firstname'])) {
			]]></search>
			<add><![CDATA[
				if (isset($this->request->post['salutation'])) {
					$this->data['salutation'] = $this->request->post['salutation'];
				} else {
					$this->data['salutation'] = '';
				}
			]]></add>
		</operation>
	</file>
	<file name="catalog/model/account/customer.php">
		<operation>
			<search position="replace"><![CDATA[
				$this->db->query("INSERT INTO " . DB_PREFIX . "customer SET store_id = '" . (int)$this->config->get('config_store_id') . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', fax = '" . $this->db->escape($data['fax']) . "', password = '" . $this->db->escape(md5($data['password'])) . "', newsletter = '" . (isset($data['newsletter']) ? (int)$data['newsletter'] : 0) . "', customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "', status = '1', date_added = NOW()");
			]]></search>
			<add><![CDATA[
				$this->db->query("INSERT INTO " . DB_PREFIX . "customer SET store_id = '" . (int)$this->config->get('config_store_id') . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', fax = '" . $this->db->escape($data['fax']) . "', password = '" . $this->db->escape(md5($data['password'])) . "', newsletter = '" . (isset($data['newsletter']) ? (int)$data['newsletter'] : 0) . "', customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "', status = '1', date_added = NOW(), salutation = '" . $this->db->escape($data['salutation']) . "'");
			]]></add>
		</operation>
	</file>
</modification>

To reconcile this method to the last post,

Save the file and the modifications should work. Please notify me in the comments section if you notice some errors in the code above.

Click here for Part 2:

Adding Custom Fields in OpenCart 1.5 Using vQmod: Administration Panel

About maca

Hello, my name is Karlo Macariola. I once dreamed to be a painter or an animator but when I typed my first line of code I immediately fell in love with programming. Today my passions are with web development and web design though sometimes I still withdraw to my first love which is drawing. DeviantArt | Twitter | Facebook
This entry was posted in Web Development & Design and tagged , , , . Bookmark the permalink.

17 Responses to Adding Custom Fields in OpenCart 1.5 Create Account, Using vQmod

  1. Pingback: Adding Custom Fields in OpenCart 1.5 Using vQmod: Administration Panel | Maca is Rambling

  2. Pingback: OpenCart: How do I add custom fields to my store pages | Maca is Rambling

  3. Theproductdiva says:

    Thank you for this post!!!!!!

  4. guest says:

    wow this was pretty easy. thanks for this post. what would be added to the xml so that salutation can be changed by the customer via their profile page once logged in? blessings!

    • Johnny says:

      Struggling with that myself. I have changed the edit.php files and the tpl it views the updated field okay but when I change it it says success but it has not updated.

  5. Johnny says:

    Anyone know how to pass this new field into the order.tpl for email notifications?

  6. pankaj says:

    hi all
    please solve my problem. i want to add custom field in my opencart site(http://indianfashionshoes.com/) in product page.Anyone can select country then choose size and this will display cart page.like the url:
    http://www.punjabfootwear.com/selectsize.php.

  7. Jakob says:

    Hi there Im running OC 1.5.2.1 and tried this method by adding a field ind the order table in the db called ‘contact_me’ tinyint(4) for registrating a input checkbox for the customer to check if they want the shopowner to contact them regarding specific thing.

    I tried the ‘old’ way and changed the code in the core files, but in the frontend OC showed an error because of the new field in the model/order.php sql in line 4.

    I tried the vqmod way and the code is below, I put the custom_name.xml in the vqmod xml folder

    Custom fieds to checkout shipping method template
    1
    1.0
    Jakob andersen

    <![CDATA[


    ]]>
    <![CDATA[

    ]]>

    data['text_comments'] = $this->language->get('text_comments');
    ]]>
    data['contact_me'] = $this->language->get('contact_me');
    ]]>

    session->data['comment'])) {
    $this->data['comment'] = $this->session->data['comment'];
    } else {
    $this->data['comment'] = '';
    }
    ]]>
    session->data['contact_me'])) {
    $this->data['contact_me'] = $this->session->data['contact_me'];
    } else {
    $this->data['contact_me'] = '';
    }
    ]]>

    session->data['comment'] = strip_tags($this->request->post['comment']);
    }
    }

    $this->response->setOutput(json_encode($json));
    ]]>
    session->data['contact_me'] = $this->request->post['contact_me'];
    ]]>

    db->query("INSERT INTO `" . DB_PREFIX . "order` SET invoice_prefix = '" . $this->db->escape($data['invoice_prefix']) . "', store_id = '" . (int)$data['store_id'] . "', store_name = '" . $this->db->escape($data['store_name']) . "', store_url = '" . $this->db->escape($data['store_url']) . "', customer_id = '" . (int)$data['customer_id'] . "', customer_group_id = '" . (int)$data['customer_group_id'] . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', fax = '" . $this->db->escape($data['fax']) . "', shipping_firstname = '" . $this->db->escape($data['shipping_firstname']) . "', shipping_lastname = '" . $this->db->escape($data['shipping_lastname']) . "', shipping_company = '" . $this->db->escape($data['shipping_company']) . "', shipping_address_1 = '" . $this->db->escape($data['shipping_address_1']) . "', shipping_address_2 = '" . $this->db->escape($data['shipping_address_2']) . "', shipping_city = '" . $this->db->escape($data['shipping_city']) . "', shipping_postcode = '" . $this->db->escape($data['shipping_postcode']) . "', shipping_country = '" . $this->db->escape($data['shipping_country']) . "', shipping_country_id = '" . (int)$data['shipping_country_id'] . "', shipping_zone = '" . $this->db->escape($data['shipping_zone']) . "', shipping_zone_id = '" . (int)$data['shipping_zone_id'] . "', shipping_address_format = '" . $this->db->escape($data['shipping_address_format']) . "', shipping_method = '" . $this->db->escape($data['shipping_method']) . "', shipping_code = '" . $this->db->escape($data['shipping_code']) . "', payment_firstname = '" . $this->db->escape($data['payment_firstname']) . "', payment_lastname = '" . $this->db->escape($data['payment_lastname']) . "', payment_company = '" . $this->db->escape($data['payment_company']) . "', payment_address_1 = '" . $this->db->escape($data['payment_address_1']) . "', payment_address_2 = '" . $this->db->escape($data['payment_address_2']) . "', payment_city = '" . $this->db->escape($data['payment_city']) . "', payment_postcode = '" . $this->db->escape($data['payment_postcode']) . "', payment_country = '" . $this->db->escape($data['payment_country']) . "', payment_country_id = '" . (int)$data['payment_country_id'] . "', payment_zone = '" . $this->db->escape($data['payment_zone']) . "', payment_zone_id = '" . (int)$data['payment_zone_id'] . "', payment_address_format = '" . $this->db->escape($data['payment_address_format']) . "', payment_method = '" . $this->db->escape($data['payment_method']) . "', payment_code = '" . $this->db->escape($data['payment_code']) . "', comment = '" . $this->db->escape($data['comment']) . "', total = '" . (float)$data['total'] . "', affiliate_id = '" . (int)$data['affiliate_id'] . "', commission = '" . (float)$data['commission'] . "', language_id = '" . (int)$data['language_id'] . "', currency_id = '" . (int)$data['currency_id'] . "', currency_code = '" . $this->db->escape($data['currency_code']) . "', currency_value = '" . (float)$data['currency_value'] . "', ip = '" . $this->db->escape($data['ip']) . "', forwarded_ip = '" . $this->db->escape($data['forwarded_ip']) . "', user_agent = '" . $this->db->escape($data['user_agent']) . "', accept_language = '" . $this->db->escape($data['accept_language']) . "', date_added = NOW(), date_modified = NOW()");
    ]]>
    db->query("INSERT INTO `" . DB_PREFIX . "order` SET invoice_prefix = '" . $this->db->escape($data['invoice_prefix']) . "', store_id = '" . (int)$data['store_id'] . "', store_name = '" . $this->db->escape($data['store_name']) . "', store_url = '" . $this->db->escape($data['store_url']) . "', customer_id = '" . (int)$data['customer_id'] . "', customer_group_id = '" . (int)$data['customer_group_id'] . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', fax = '" . $this->db->escape($data['fax']) . "', shipping_firstname = '" . $this->db->escape($data['shipping_firstname']) . "', shipping_lastname = '" . $this->db->escape($data['shipping_lastname']) . "', shipping_company = '" . $this->db->escape($data['shipping_company']) . "', shipping_address_1 = '" . $this->db->escape($data['shipping_address_1']) . "', shipping_address_2 = '" . $this->db->escape($data['shipping_address_2']) . "', shipping_city = '" . $this->db->escape($data['shipping_city']) . "', shipping_postcode = '" . $this->db->escape($data['shipping_postcode']) . "', shipping_country = '" . $this->db->escape($data['shipping_country']) . "', shipping_country_id = '" . (int)$data['shipping_country_id'] . "', shipping_zone = '" . $this->db->escape($data['shipping_zone']) . "', shipping_zone_id = '" . (int)$data['shipping_zone_id'] . "', shipping_address_format = '" . $this->db->escape($data['shipping_address_format']) . "', shipping_method = '" . $this->db->escape($data['shipping_method']) . "', shipping_code = '" . $this->db->escape($data['shipping_code']) . "', payment_firstname = '" . $this->db->escape($data['payment_firstname']) . "', payment_lastname = '" . $this->db->escape($data['payment_lastname']) . "', payment_company = '" . $this->db->escape($data['payment_company']) . "', payment_address_1 = '" . $this->db->escape($data['payment_address_1']) . "', payment_address_2 = '" . $this->db->escape($data['payment_address_2']) . "', payment_city = '" . $this->db->escape($data['payment_city']) . "', payment_postcode = '" . $this->db->escape($data['payment_postcode']) . "', payment_country = '" . $this->db->escape($data['payment_country']) . "', payment_country_id = '" . (int)$data['payment_country_id'] . "', payment_zone = '" . $this->db->escape($data['payment_zone']) . "', payment_zone_id = '" . (int)$data['payment_zone_id'] . "', payment_address_format = '" . $this->db->escape($data['payment_address_format']) . "', payment_method = '" . $this->db->escape($data['payment_method']) . "', payment_code = '" . $this->db->escape($data['payment_code']) . "', contact_me = '" . (isset($data['contact_me']) ? (int)$data['contact_me'] : 0) . "', comment = '" . $this->db->escape($data['comment']) . "', total = '" . (float)$data['total'] . "', affiliate_id = '" . (int)$data['affiliate_id'] . "', commission = '" . (float)$data['commission'] . "', language_id = '" . (int)$data['language_id'] . "', currency_id = '" . (int)$data['currency_id'] . "', currency_code = '" . $this->db->escape($data['currency_code']) . "', currency_value = '" . (float)$data['currency_value'] . "', ip = '" . $this->db->escape($data['ip']) . "', forwarded_ip = '" . $this->db->escape($data['forwarded_ip']) . "', user_agent = '" . $this->db->escape($data['user_agent']) . "', accept_language = '" . $this->db->escape($data['accept_language']) . "', date_added = NOW(), date_modified = NOW()");
    ]]>

    $order_query->row['comment'],
    ]]>
    $order_query->row['contact_me'],
    ]]>

    db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int)$order_id . "', order_status_id = '" . (int)$order_status_id . "', notify = '1', comment = '" . $this->db->escape(($comment && $notify) ? $comment : '') . "', date_added = NOW()");
    ]]>
    db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int)$order_id . "', order_status_id = '" . (int)$order_status_id . "', notify = '1', contact_me = '" . $this->db->($contact_me) ? $contact_me : '' . "',comment = '" . $this->db->escape(($comment && $notify) ? $comment : '') . "', date_added = NOW()");
    ]]>

    data['comment'] = nl2br($comment);
    } else {
    $template->data['comment'] = '';
    }
    ]]>
    data['contact_me'] = nl2br($contact_me);
    } else {
    $template->data['contact_me'] = '';
    }
    ]]>

    db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int)$order_id . "', order_status_id = '" . (int)$order_status_id . "', notify = '" . (int)$notify . "', comment = '" . $this->db->escape($comment) . "', date_added = NOW()");

    // Send out any gift voucher mails
    ]]>
    db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int)$order_id . "', order_status_id = '" . (int)$order_status_id . "', notify = '" . (int)$notify . "', contact_me = '" . (int)$contact_me . "', comment = '" . $this->db->escape($comment) . "', date_added = NOW()");

    // Send out any gift voucher mails
    ]]>


    It still doesnt work!!!??? Please help!

  8. Jakob says:

    sry wrong code before this is the xml

    Custom fieds to checkout shipping method template
    1
    1.0
    Jakob andersen

    <![CDATA[


    ]]>
    <![CDATA[

    ]]>

    data[‘text_comments’] = $this->language->get(‘text_comments’);
    ]]>
    data[‘contact_me’] = $this->language->get(‘contact_me’);
    ]]>

    session->data[‘comment’])) {
    $this->data[‘comment’] = $this->session->data[‘comment’];
    } else {
    $this->data[‘comment’] = ”;
    }
    ]]>
    session->data[‘contact_me’])) {
    $this->data[‘contact_me’] = $this->session->data[‘contact_me’];
    } else {
    $this->data[‘contact_me’] = ”;
    }
    ]]>

    session->data[‘comment’] = strip_tags($this->request->post[‘comment’]);
    }
    }

    $this->response->setOutput(json_encode($json));
    ]]>
    session->data[‘contact_me’] = $this->request->post[‘contact_me’];
    ]]>

    db->query(“INSERT INTO `” . DB_PREFIX . “order` SET invoice_prefix = ‘” . $this->db->escape($data[‘invoice_prefix’]) . “‘, store_id = ‘” . (int)$data[‘store_id’] . “‘, store_name = ‘” . $this->db->escape($data[‘store_name’]) . “‘, store_url = ‘” . $this->db->escape($data[‘store_url’]) . “‘, customer_id = ‘” . (int)$data[‘customer_id’] . “‘, customer_group_id = ‘” . (int)$data[‘customer_group_id’] . “‘, firstname = ‘” . $this->db->escape($data[‘firstname’]) . “‘, lastname = ‘” . $this->db->escape($data[‘lastname’]) . “‘, email = ‘” . $this->db->escape($data[’email’]) . “‘, telephone = ‘” . $this->db->escape($data[‘telephone’]) . “‘, fax = ‘” . $this->db->escape($data[‘fax’]) . “‘, shipping_firstname = ‘” . $this->db->escape($data[‘shipping_firstname’]) . “‘, shipping_lastname = ‘” . $this->db->escape($data[‘shipping_lastname’]) . “‘, shipping_company = ‘” . $this->db->escape($data[‘shipping_company’]) . “‘, shipping_address_1 = ‘” . $this->db->escape($data[‘shipping_address_1’]) . “‘, shipping_address_2 = ‘” . $this->db->escape($data[‘shipping_address_2’]) . “‘, shipping_city = ‘” . $this->db->escape($data[‘shipping_city’]) . “‘, shipping_postcode = ‘” . $this->db->escape($data[‘shipping_postcode’]) . “‘, shipping_country = ‘” . $this->db->escape($data[‘shipping_country’]) . “‘, shipping_country_id = ‘” . (int)$data[‘shipping_country_id’] . “‘, shipping_zone = ‘” . $this->db->escape($data[‘shipping_zone’]) . “‘, shipping_zone_id = ‘” . (int)$data[‘shipping_zone_id’] . “‘, shipping_address_format = ‘” . $this->db->escape($data[‘shipping_address_format’]) . “‘, shipping_method = ‘” . $this->db->escape($data[‘shipping_method’]) . “‘, shipping_code = ‘” . $this->db->escape($data[‘shipping_code’]) . “‘, payment_firstname = ‘” . $this->db->escape($data[‘payment_firstname’]) . “‘, payment_lastname = ‘” . $this->db->escape($data[‘payment_lastname’]) . “‘, payment_company = ‘” . $this->db->escape($data[‘payment_company’]) . “‘, payment_address_1 = ‘” . $this->db->escape($data[‘payment_address_1’]) . “‘, payment_address_2 = ‘” . $this->db->escape($data[‘payment_address_2’]) . “‘, payment_city = ‘” . $this->db->escape($data[‘payment_city’]) . “‘, payment_postcode = ‘” . $this->db->escape($data[‘payment_postcode’]) . “‘, payment_country = ‘” . $this->db->escape($data[‘payment_country’]) . “‘, payment_country_id = ‘” . (int)$data[‘payment_country_id’] . “‘, payment_zone = ‘” . $this->db->escape($data[‘payment_zone’]) . “‘, payment_zone_id = ‘” . (int)$data[‘payment_zone_id’] . “‘, payment_address_format = ‘” . $this->db->escape($data[‘payment_address_format’]) . “‘, payment_method = ‘” . $this->db->escape($data[‘payment_method’]) . “‘, payment_code = ‘” . $this->db->escape($data[‘payment_code’]) . “‘, comment = ‘” . $this->db->escape($data[‘comment’]) . “‘, total = ‘” . (float)$data[‘total’] . “‘, affiliate_id = ‘” . (int)$data[‘affiliate_id’] . “‘, commission = ‘” . (float)$data[‘commission’] . “‘, language_id = ‘” . (int)$data[‘language_id’] . “‘, currency_id = ‘” . (int)$data[‘currency_id’] . “‘, currency_code = ‘” . $this->db->escape($data[‘currency_code’]) . “‘, currency_value = ‘” . (float)$data[‘currency_value’] . “‘, ip = ‘” . $this->db->escape($data[‘ip’]) . “‘, forwarded_ip = ‘” . $this->db->escape($data[‘forwarded_ip’]) . “‘, user_agent = ‘” . $this->db->escape($data[‘user_agent’]) . “‘, accept_language = ‘” . $this->db->escape($data[‘accept_language’]) . “‘, date_added = NOW(), date_modified = NOW()”);
    ]]>
    db->query(“INSERT INTO `” . DB_PREFIX . “order` SET invoice_prefix = ‘” . $this->db->escape($data[‘invoice_prefix’]) . “‘, store_id = ‘” . (int)$data[‘store_id’] . “‘, store_name = ‘” . $this->db->escape($data[‘store_name’]) . “‘, store_url = ‘” . $this->db->escape($data[‘store_url’]) . “‘, customer_id = ‘” . (int)$data[‘customer_id’] . “‘, customer_group_id = ‘” . (int)$data[‘customer_group_id’] . “‘, firstname = ‘” . $this->db->escape($data[‘firstname’]) . “‘, lastname = ‘” . $this->db->escape($data[‘lastname’]) . “‘, email = ‘” . $this->db->escape($data[’email’]) . “‘, telephone = ‘” . $this->db->escape($data[‘telephone’]) . “‘, fax = ‘” . $this->db->escape($data[‘fax’]) . “‘, shipping_firstname = ‘” . $this->db->escape($data[‘shipping_firstname’]) . “‘, shipping_lastname = ‘” . $this->db->escape($data[‘shipping_lastname’]) . “‘, shipping_company = ‘” . $this->db->escape($data[‘shipping_company’]) . “‘, shipping_address_1 = ‘” . $this->db->escape($data[‘shipping_address_1’]) . “‘, shipping_address_2 = ‘” . $this->db->escape($data[‘shipping_address_2’]) . “‘, shipping_city = ‘” . $this->db->escape($data[‘shipping_city’]) . “‘, shipping_postcode = ‘” . $this->db->escape($data[‘shipping_postcode’]) . “‘, shipping_country = ‘” . $this->db->escape($data[‘shipping_country’]) . “‘, shipping_country_id = ‘” . (int)$data[‘shipping_country_id’] . “‘, shipping_zone = ‘” . $this->db->escape($data[‘shipping_zone’]) . “‘, shipping_zone_id = ‘” . (int)$data[‘shipping_zone_id’] . “‘, shipping_address_format = ‘” . $this->db->escape($data[‘shipping_address_format’]) . “‘, shipping_method = ‘” . $this->db->escape($data[‘shipping_method’]) . “‘, shipping_code = ‘” . $this->db->escape($data[‘shipping_code’]) . “‘, payment_firstname = ‘” . $this->db->escape($data[‘payment_firstname’]) . “‘, payment_lastname = ‘” . $this->db->escape($data[‘payment_lastname’]) . “‘, payment_company = ‘” . $this->db->escape($data[‘payment_company’]) . “‘, payment_address_1 = ‘” . $this->db->escape($data[‘payment_address_1’]) . “‘, payment_address_2 = ‘” . $this->db->escape($data[‘payment_address_2’]) . “‘, payment_city = ‘” . $this->db->escape($data[‘payment_city’]) . “‘, payment_postcode = ‘” . $this->db->escape($data[‘payment_postcode’]) . “‘, payment_country = ‘” . $this->db->escape($data[‘payment_country’]) . “‘, payment_country_id = ‘” . (int)$data[‘payment_country_id’] . “‘, payment_zone = ‘” . $this->db->escape($data[‘payment_zone’]) . “‘, payment_zone_id = ‘” . (int)$data[‘payment_zone_id’] . “‘, payment_address_format = ‘” . $this->db->escape($data[‘payment_address_format’]) . “‘, payment_method = ‘” . $this->db->escape($data[‘payment_method’]) . “‘, payment_code = ‘” . $this->db->escape($data[‘payment_code’]) . “‘, contact_me = ‘” . (isset($data[‘contact_me’]) ? (int)$data[‘contact_me’] : 0) . “‘, comment = ‘” . $this->db->escape($data[‘comment’]) . “‘, total = ‘” . (float)$data[‘total’] . “‘, affiliate_id = ‘” . (int)$data[‘affiliate_id’] . “‘, commission = ‘” . (float)$data[‘commission’] . “‘, language_id = ‘” . (int)$data[‘language_id’] . “‘, currency_id = ‘” . (int)$data[‘currency_id’] . “‘, currency_code = ‘” . $this->db->escape($data[‘currency_code’]) . “‘, currency_value = ‘” . (float)$data[‘currency_value’] . “‘, ip = ‘” . $this->db->escape($data[‘ip’]) . “‘, forwarded_ip = ‘” . $this->db->escape($data[‘forwarded_ip’]) . “‘, user_agent = ‘” . $this->db->escape($data[‘user_agent’]) . “‘, accept_language = ‘” . $this->db->escape($data[‘accept_language’]) . “‘, date_added = NOW(), date_modified = NOW()”);
    ]]>

    $order_query->row[‘comment’],
    ]]>
    $order_query->row[‘contact_me’],
    ]]>

    db->query(“INSERT INTO ” . DB_PREFIX . “order_history SET order_id = ‘” . (int)$order_id . “‘, order_status_id = ‘” . (int)$order_status_id . “‘, notify = ‘1’, comment = ‘” . $this->db->escape(($comment && $notify) ? $comment : ”) . “‘, date_added = NOW()”);
    ]]>
    db->query(“INSERT INTO ” . DB_PREFIX . “order_history SET order_id = ‘” . (int)$order_id . “‘, order_status_id = ‘” . (int)$order_status_id . “‘, notify = ‘1’, contact_me = ‘” . $this->db->($contact_me) ? $contact_me : ” . “‘,comment = ‘” . $this->db->escape(($comment && $notify) ? $comment : ”) . “‘, date_added = NOW()”);
    ]]>

    data[‘comment’] = nl2br($comment);
    } else {
    $template->data[‘comment’] = ”;
    }
    ]]>
    data[‘contact_me’] = nl2br($contact_me);
    } else {
    $template->data[‘contact_me’] = ”;
    }
    ]]>

    db->query(“INSERT INTO ” . DB_PREFIX . “order_history SET order_id = ‘” . (int)$order_id . “‘, order_status_id = ‘” . (int)$order_status_id . “‘, notify = ‘” . (int)$notify . “‘, comment = ‘” . $this->db->escape($comment) . “‘, date_added = NOW()”);

    // Send out any gift voucher mails
    ]]>
    db->query(“INSERT INTO ” . DB_PREFIX . “order_history SET order_id = ‘” . (int)$order_id . “‘, order_status_id = ‘” . (int)$order_status_id . “‘, notify = ‘” . (int)$notify . “‘, contact_me = ‘” . (int)$contact_me . “‘, comment = ‘” . $this->db->escape($comment) . “‘, date_added = NOW()”);

    // Send out any gift voucher mails
    ]]>

  9. Daneczech says:

    I try your tutorial but anything works… My website run on Opencart 1.5.1. I install vqmod extension well, but the xml files doesn’t run, even if I make exactly the same as here… Is it normal doctor? ^^

    Thanks in advance,

    D.

  10. how customer edit this custom made field details…??? can u help me please…???

  11. ann86 says:

    Hi there,

    I have followed the instruction that you have specified…
    1.created the database field in customer table
    2.created the xml and saved it in the vqmod/xml folder
    Refreshed the page still nothing shows up in the registration page. Is there anything I am missing Do I need to link the newly created xml to the vqmod_opencart.xml? Please reply its urgent.

  12. George says:

    Hi thanks for the help i i intend to change the product > option to add custom fields in the radio option instead of small , medium , large.

    Thanks for the help!!

  13. interested says:

    Please advise what should be changed in account/edit.php as well as other related files in order to change salutation by a customer

  14. mike says:

    Is this a safe method? I mean does it provide protection against xss and sql injection and so on?
    The only security I see are the

    $this->db->escape($variable)

    lines.
    Regards Mike

  15. ANR says:

    How customer edit this custom made field details…???

  16. sajjad says:

    how to i add a drop down box in the registration form ??? please reply me 🙁

Leave a Reply

Your email address will not be published. Required fields are marked *