Post by Carbonarm » Thu May 31, 2012 4:56 am

I am pretty new to OC and to vQmod as well, but code php etc.
After reading a lot about adding custom code with vQmod, I havent been able to change just a litle code..
I must be doing something wrong!? Pleas help!

I want to add a custom checkbox to the checkout shipping_method.tpl and have added an extra field

Code: Select all

tinyint(contact_me)
to the order table in the database using phpmyadmin.

I have made this xml file and placed it in the vqmod/xml folder with custom name

Code: Select all

custom_shipping_method.xml
Sorry, I know the code is massive, but many files and code needs to be modified, at least thats what I think ;)

But even if I delete the file content but not the first search/add part of the code, it does not work for me!? :choke:

Code: Select all

<modification>
    <id>Custom fields to checkout shipping method</id>
    <version>1</version>
    <vqmver>1.0</vqmver>
    <author>Jakob Andersen</author>
    <file name="catalog/view/theme/default/template/checkout/shipping_method.tpl">
        <operation>
            <search position="before"><![CDATA[
								<b><?php echo $text_comments; ?></b>
            ]]></search>
            <add><![CDATA[
            		<input type="checkbox" name="contact_me" value="<?php echo $contact_me; ?>" id="shipping" checked="checked" />								
            ]]></add>
        </operation>
    </file>
    <file name="catalog/language/danish/checkout/checkout.php">
        <operation>
            <search position="before"><![CDATA[
                $_['text_comments']  = 'Tilføj en kommentar til din ordre';
            ]]></search>
            <add><![CDATA[
                $_['contact_me']  = 'Vil du kontaktes af sælger?';
            ]]></add>
        </operation>
    </file>
    <file name="catalog/controller/checkout/shipping_method.php">
    		<operation>
            <search position="before"><![CDATA[
            		$this->data['text_comments'] = $this->language->get('text_comments');
            ]]></search>
            <add><![CDATA[
                $this->data['contact_me'] = $this->language->get('contact_me');	
            ]]></add>
        </operation>
        <operation>
            <search position="before"><![CDATA[                
								if (isset($this->session->data['comment'])) {
									$this->data['comment'] = $this->session->data['comment'];
								} else {
									$this->data['comment'] = '';
								}
            ]]></search>
            <add><![CDATA[
                if (isset($this->session->data['contact_me'])) {
									$this->data['contact_me'] = $this->session->data['contact_me'];
								} else {
									$this->data['contact_me'] = '';
								}
            ]]></add>
        </operation>
        <operation>
            <search position="before"><![CDATA[
									$this->session->data['comment'] = strip_tags($this->request->post['comment']);
            ]]></search>
            <add><![CDATA[
                $this->session->data['contact_me'] = $this->request->post['contact_me'];
            ]]></add>
        </operation>
    </file>
    <file name="catalog/model/checkout/order.php">
        <operation>
            <search position="replace"><![CDATA[
            		$this->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()");
            ]]></search>
            <add><![CDATA[
            		$this->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()");
            ]]></add>
        </operation>
        <operation>
            <search position="before"><![CDATA[
            		'comment' => $order_query->row['comment'],
            ]]></search>
            <add><![CDATA[
            		'contact_me' => $order_query->row['contact_me'],
            ]]></add>
        </operation>
        <operation>
            <search position="replace"><![CDATA[
            	public function confirm($order_id, $order_status_id, $comment = '', $notify = false) {
            ]]></search>
            <add><![CDATA[
            	public function confirm($order_id, $order_status_id, $contact_me = '', $comment = '', $notify = false) {
            ]]></add>
        </operation>
        <operation>
            <search position="replace"><![CDATA[
            		$this->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()");
            ]]></search>
            <add><![CDATA[
            		$this->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()");
            ]]></add>
        </operation>
        <operation>
            <search position="before"><![CDATA[
							if ($comment && $notify) {
								$template->data['comment'] = nl2br($comment);
							} else {
								$template->data['comment'] = '';
							}
            ]]></search>
            <add><![CDATA[
							if ($contact_me) {
								$template->data['contact_me'] = $contact_me;
							} else {
								$template->data['contact_me'] = '';
							}
            ]]></add>
        </operation>
        <operation>
            <search position="replace"><![CDATA[
            	public function update($order_id, $order_status_id, $comment = '', $notify = false) {
            ]]></search>
            <add><![CDATA[
            	public function update($order_id, $order_status_id, $contact_me = '', $comment = '', $notify = false) {
            ]]></add>
        </operation>
        <operation>
            <search position="replace"><![CDATA[
            		$this->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()");	
            ]]></search>
            <add><![CDATA[
            		$this->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()");
            ]]></add>
        </operation>
    </file>
</modification>

Newbie

Posts

Joined
Thu May 31, 2012 4:44 am

Post by freifer » Fri Oct 05, 2012 1:13 pm

did you find solution for this ?

Newbie

Posts

Joined
Wed May 02, 2012 8:53 am
Who is online

Users browsing this forum: No registered users and 5 guests