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
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);
}
});
delegate is deprecated, read: https://api.jquery.com/delegate/pprmkr wrote: ↑Fri Jun 05, 2020 3:11 amPiece of script to play with ...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); } });
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.
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.
Who is online
Users browsing this forum: No registered users and 19 guests