Page 1 of 1

Update some columns sale/order from admin

Posted: Sun Nov 18, 2018 6:12 pm
by orik3ll0
Hello guys,

From admin panel orders page, i press see order button( "sale/order/info" page) and i have added 1 more "select" input and on submit button, i want to send this "select" input value and update this value in db, but can not find in which file it does insert and update of tables.

It sends data by ajax on button click

Code: Select all

$('#button-history').on('click', function() {
	$.ajax({
		url: '<?php echo $catalog; ?>index.php?route=api/order/history&token=' + token + '&store_id=<?php echo $store_id; ?>&order_id=<?php echo $order_id; ?>',
		type: 'post',
		dataType: 'json',
		data: 'order_status_id=' + encodeURIComponent($('select[name=\'order_status_id\']').val()) + '&notify=' + ($('input[name=\'notify\']').prop('checked') ? 1 : 0) + '&override=' + ($('input[name=\'override\']').prop('checked') ? 1 : 0) + '&append=' + ($('input[name=\'append\']').prop('checked') ? 1 : 0) + '&comment=' + encodeURIComponent($('textarea[name=\'comment\']').val()),
		beforeSend: function() {
			$('#button-history').button('loading');
		},
		complete: function() {
			$('#button-history').button('reset');
		},
		success: function(json) {
		    //alert(data);
			$('.alert').remove();

			if (json['error']) {
				$('#history').before('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>');
			}

			if (json['success']) {
				$('#history').load('index.php?route=sale/order/history&token=<?php echo $token; ?>&order_id=<?php echo $order_id; ?>');

				$('#history').before('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>');

				$('textarea[name=\'comment\']').val('');
			}
		},
		error: function(xhr, ajaxOptions, thrownError) {
			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
		}
	});
});
okay, i am adding my select input inside <form> tag and adding my value tot data

Code: Select all

data: 'seller_sel=' + encodeURIComponent($('select[name=\'seller_sel\']').val()) + 'order_status_id=' + encodeURIComponent($('select[name=\'order_status_id\']').val()) + '&notify=' + ($('input[name=\'notify\']').prop('checked') ? 1 : 0) + '&override=' + ($('input[name=\'override\']').prop('checked') ? 1 : 0) + '&append=' + ($('input[name=\'append\']').prop('checked') ? 1 : 0) + '&comment=' + encodeURIComponent($('textarea[name=\'comment\']').val()),
So on submit it does insert into `prefix_order_history` and updates `order_status_id`.... I can not find model where it does this insert and update to change query. Please tell me where can i find query

Re: Update some columns sale/order from admin

Posted: Sun Nov 18, 2018 9:03 pm
by OSWorX
You have to call

Code: Select all

catlog/api/order > edit
to edit existing orders.
And I guess you have to edit also this function and the model

Code: Select all

catlog/checkout/order > editOrder
if you want to add / edit additonal fields.

Re: Update some columns sale/order from admin

Posted: Mon Nov 19, 2018 4:47 am
by orik3ll0
OSWorX wrote:
Sun Nov 18, 2018 9:03 pm
You have to call

Code: Select all

catlog/api/order > edit
to edit existing orders.
And I guess you have to edit also this function and the model

Code: Select all

catlog/checkout/order > editOrder
if you want to add / edit additonal fields.
Thank you for your reply and asnwer!) I did not know that it could be out of admin folder :-\

Re: Update some columns sale/order from admin

Posted: Mon Nov 19, 2018 3:28 pm
by OSWorX
Well ... you are editing the code.
Therefore you are reading the code.

And there is (see first posting):

Code: Select all

url: '<?php echo $catalog; ?>index.php?route=api/order/history
That is pointing to the catalog .. O0