Post by giri_ptl » Tue Dec 20, 2011 3:00 pm

I am facing a problem while inserting custom field value to order table

below is the code

1. catalog\language\english\checkout\checkout.php

Code: Select all

    $_['entry_salutation']      = 'Salutation:';
2. catalog\view\theme\default\template\checkout\payment.tpl

Code: Select all

      <tr>
          <td><?php echo $entry_salutation; ?></td>
          <td><input type="text" name="salutation" value="<?php echo $salutation; ?>" /></td>
        </tr>
       <tr>
3. \catalog\controller\checkout\payment.php

Code: Select all

     $this->data['entry_salutation'] = $this->language->get('entry_salutation');
     if (isset($this->request->post['salutation'])) {
                    $this->data['salutation'] = $this->request->post['salutation'];
                } else {
                    $this->data['salutation'] = '';
                }
4. \catalog\model\checkout\order.php

Code: Select all

      salutation  = '" . $this->db->escape($data['salutation']) . "'
this is wat i am doing to insert the field value to order table

but i am getting error please help me

thanks
vinay
Last edited by i2Paq on Tue Dec 20, 2011 3:06 pm, edited 1 time in total.
Reason: Code-tags added

Newbie

Posts

Joined
Tue Dec 13, 2011 5:28 pm

Post by alin » Tue Dec 20, 2011 4:18 pm

What is your error information?

GOLDEN LEOPARD SYSTEM SOLUTION
An ICT System Solution Company in Vietnam
Website: Store: http://shopcartplus.com or http://www.opencart.com/index.php?route ... rname=alin


User avatar
Active Member

Posts

Joined
Fri Jun 10, 2011 8:16 pm


Post by giri_ptl » Tue Dec 20, 2011 5:41 pm

SyntaxError: Unexpected token ILLEGAL

Newbie

Posts

Joined
Tue Dec 13, 2011 5:28 pm

Post by jimmyphong » Tue Dec 20, 2011 6:13 pm

Yes you get erorr is right !

you mean you add an input in step payment (same comment) on checkout page ?

if right !
please check file :catalog/view/theme/default/template/checkout/checkout.tpl (line 902)
when you click continue button in payment methol step : the code with this action:

Code: Select all

$('#button-payment').live('click', function() {
	$.ajax({
		url: 'index.php?route=checkout/payment', 
		type: 'post',
		data: $('#payment-method input[type=\'radio\']:checked, #payment-method input[type=\'checkbox\']:checked, #payment-method textarea'),
		dataType: 'json',
		beforeSend: function() {
			$('#button-payment').attr('disabled', true);
			$('#button-payment').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
		},	
		complete: function() {
			$('#button-payment').attr('disabled', false);
			$('.wait').remove();
		},			
		success: function(json) {
			$('.warning').remove();
			
			if (json['redirect']) {
				location = json['redirect'];
			}
			
			if (json['error']) {
				if (json['error']['warning']) {
					$('#payment-method .checkout-content').prepend('<div class="warning" style="display: none;">' + json['error']['warning'] + '</div>');
					
					$('.warning').fadeIn('slow');
				}			
			} else {
				$.ajax({
					url: 'index.php?route=checkout/confirm',
					dataType: 'json',
					success: function(json) {
						if (json['redirect']) {
							location = json['redirect'];
						}	
					
						if (json['output']) {
							$('#confirm .checkout-content').html(json['output']);
							
							$('#payment-method .checkout-content').slideUp('slow');
							
							$('#confirm .checkout-content').slideDown('slow');
							
							$('#payment-method .checkout-heading a').remove();
							
							$('#payment-method .checkout-heading').append('<a><?php echo $text_modify; ?></a>');	
						}
					},
					error: function(xhr, ajaxOptions, thrownError) {
						alert(thrownError);
					}
				});					
			}
		}
	});	
});
see the code with this ajax:

Code: Select all

data: $('#payment-method input[type=\'radio\']:checked, #payment-method input[type=\'checkbox\']:checked, #payment-method textarea'),
you must add more element for the input post data
//post data to payment
ex:

Code: Select all

data: $('#payment-method input[type=\'radio\']:checked, #payment-method input[type=\'checkbox\']:checked, #payment-method textarea,#payment-method input[name=\'salutation\']'),
openfile :
catalog\controller\checkout\payment.php

find (line 48)

Code: Select all

$this->session->data['comment'] = strip_tags($this->request->post['comment']);
add
//get salution value

Code: Select all

$this->session->data['salutation'] = strip_tags($this->request->post['salutation']);
openfile catalog\controller\checkout\confirm.php
find :

Code: Select all

$data['comment'] = $this->session->data['comment'];
add
//get salution when complete payment
find :

Code: Select all

$data['salutation'] = $this->session->data['salutation'];
Note :
and do step add in model :


try agian !

News CMS || Plus SEO || Live Price change with Option Select


Active Member

Posts

Joined
Sat Aug 13, 2011 2:48 am


Post by giri_ptl » Tue Dec 20, 2011 7:51 pm

yes sir this is working

thank u very much for your post, i am trying this from 3 days but no output, now i got it

thanks once again

Newbie

Posts

Joined
Tue Dec 13, 2011 5:28 pm

Post by pablich » Sat Mar 29, 2014 4:36 am

I'm trying to do the same, and jumps me the following error
sshot-3.png

sshot-3.png (26.46 KiB) Viewed 3820 times

I Detect the error appeared when I add this code

Code: Select all

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

New member

Posts

Joined
Thu Feb 13, 2014 12:26 am

Post by escurooo » Fri Jan 25, 2019 2:30 am

I have the same issue, I need to know if I can add field in the order table I want to add total quantity (sum the totals of each item quantity) and shows in the order table. I am using OC 3.0.2.0

Newbie

Posts

Joined
Fri Jan 11, 2019 3:03 am

Post by beautyepic » Sat Feb 02, 2019 6:44 pm

First thing: custom fields are not only text fields. You'll likely want to add dates, booleans, arrays...
You also have to deal with privileges and mandatory fields.
The best approach I think is to have a preference table and a data table separately.
Concerning your initial fields, it will be easier to manage them as custom fields, maybe with some "system" privileges in your pref table.
Another important point is custom fields groups. Most likely, your users will ask for it so build it from the start. That's another table.
At Sellsy we added CF long after releasing the software and we would have been faster if we took all this into consideration from the ground up.

Newbie

Posts

Joined
Fri Feb 01, 2019 6:12 pm

Who is online

Users browsing this forum: No registered users and 17 guests