Post by Photospirit » Fri Jun 05, 2020 2:14 am

Hi,
I want to have the customer notification checkbox to be changed dynamically depending on the selected order status.

For example, if I change order status to "Shipped", then the notify customer checkbox should be "ticked". If I change it to "Closed" then the notify checkbox should "not be ticked".

I'm using OC 2.3.0.2

Thanks for any hint/support.
Cheers, Chris

New member

Posts

Joined
Sat Oct 23, 2010 8:16 pm

Post by pprmkr » Fri Jun 05, 2020 3:11 am

Code: Select all

$(document).delegate('#input-order-status', 'change', function() {
	var selectedStatus = $(this).children("option:selected").val();
	var notifyOn = ['1','4','8','12'];
	
	if (notifyOn.includes(selectedStatus)) {
		console.log('Selected trigger on: ' + selectedStatus);
		$('#input-notify').prop('checked',true);
	} else {
		console.log('Selected trigger off: ' + selectedStatus);
		$('#input-notify').prop('checked',false);
	}
		
});
Piece of script to play with ...

User avatar
Active Member

Posts

Joined
Sat Jan 08, 2011 11:05 pm
Location - Netherlands

Post by OSWorX » Fri Jun 05, 2020 3:48 pm

pprmkr wrote:
Fri Jun 05, 2020 3:11 am

Code: Select all

$(document).delegate('#input-order-status', 'change', function() {
	var selectedStatus = $(this).children("option:selected").val();
	var notifyOn = ['1','4','8','12'];
	
	if (notifyOn.includes(selectedStatus)) {
		console.log('Selected trigger on: ' + selectedStatus);
		$('#input-notify').prop('checked',true);
	} else {
		console.log('Selected trigger off: ' + selectedStatus);
		$('#input-notify').prop('checked',false);
	}
		
});
Piece of script to play with ...
delegate is deprecated, read: https://api.jquery.com/delegate/

Better do it this way:

Code: Select all

$(document).on('change', '#input-order-status',  function() {
	var selectedStatus = $(this).children("option:selected").val();
	var notifyOn = ['1','4','8','12'];
	
	if (notifyOn.includes(selectedStatus)) {
		console.log('Selected trigger on: ' + selectedStatus);
		$('#input-notify').prop('checked',true);
	} else {
		console.log('Selected trigger off: ' + selectedStatus);
		$('#input-notify').prop('checked',false);
	}
		
});

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member
Online

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by Photospirit » Fri Jun 05, 2020 7:17 pm

Cool...thanks for the fast help.. works perfectly. :)

New member

Posts

Joined
Sat Oct 23, 2010 8:16 pm

Post by OSWorX » Fri Jun 05, 2020 7:45 pm

Or to be on the latest development:

Code: Select all

$(document).on('change', '#input-order-status', function() {
	let selectedStatus = $(this).children("option:selected").val(), notifyOn = ['1','4','8','12'];
	
	if (notifyOn.includes(selectedStatus)) {
		// console.log('Selected trigger on: ' + selectedStatus); // optional console output
		$('#input-notify').prop('checked',true);
	} else {
		// console.log('Selected trigger off: ' + selectedStatus); // optional console output
		$('#input-notify').prop('checked',false);
	}
});

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member
Online

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria
Who is online

Users browsing this forum: No registered users and 19 guests