jQuery(document).ready(function($) {
jQuery("#shipping_zone").on('click', function(){
var variations = ( $( "#shipping_zone" ).is(':checked')) ? 1 : 0;
if(variations == "1"){
jQuery.ajax({
method: "POST",
url: ajaxurl,
data: { 'action': 'woosea_shipping_zones' }
})
.done(function( data ) {
data = JSON.parse( data );
$('#shipping_zones').after('
Select shipping zone: You have multiple shipping zones configured for your shop. Do you want to add all Shipping zones to your product feed or just a one?
');
})
.fail(function( data ) {
console.log('Failed AJAX Call :( /// Return Data: ' + data);
});
} else {
$('#select_shipping_zone').remove();
}
});
jQuery("#channel_hash").on("change", function(){
var channel_hash = $("#channel_hash").find('option:selected').text();
if(channel_hash == 'Google Remarketing - DRM'){ // Ugly hack, should be configurable per channel
$("#fileformat option[value='xml']").remove();
$("#fileformat option[value='txt']").remove();
$("#fileformat option[value='tsv']").remove();
$('#file').after('
Delimiter:
');
} else if(channel_hash == 'Guenstiger.de'){ // Ugly hack, should be configurable per channel
$("#fileformat option[value='xml']").remove();
$("#fileformat option[value='txt']").remove();
$("#fileformat option[value='tsv']").remove();
$('#file').after('
Delimiter:
');
} else if(channel_hash == 'Google - DSA'){ // Ugly hack, should be configurable per channel
$("#fileformat option[value='xml']").remove();
$("#fileformat option[value='txt']").remove();
$("#fileformat option[value='tsv']").remove();
$('#file').after('
Delimiter:
');
} else if(channel_hash == 'Wish.com'){ // Ugly hack, should be configurable per channel
$("#fileformat option[value='xml']").remove();
$("#fileformat option[value='txt']").remove();
$("#fileformat option[value='tsv']").remove();
$('#file').after('
Delimiter:
');
} else if(channel_hash == 'Google Local Products Inventory'){ // Ugly hack, should be configurable per channel
$("#fileformat option[value='csv']").remove();
$("#fileformat option[value='tsv']").remove();
$('#file').after('
Delimiter:
');
} else if(channel_hash == 'Google Shopping'){ // Ugly hack, should be configurable per channel
$("#fileformat option[value='txt']").remove();
$("#fileformat option[value='csv']").remove();
$("#fileformat option[value='tsv']").remove();
$('#file').after('
Delimiter:
');
} else if(channel_hash == 'Fashionchick.nl'){ // Ugly hack, should be configurable per channel
$("#fileformat option[value='tsv']").remove();
$("#fileformat option[value='xml']").remove();
$('#file').after('
Delimiter:
');
} else if(channel_hash == 'Bol.com'){ // Ugly hack, should be configurable per channel
$("#fileformat option[value='tsv']").remove();
$("#fileformat option[value='xml']").remove();
$('#file').after('
Delimiter:
');
} else if(channel_hash == 'Snapchat Product Catalog'){ // Ugly hack, should be configurable per channel
$("#fileformat option[value='tsv']").remove();
$("#fileformat option[value='xml']").remove();
$("#fileformat option[value='txt']").remove();
$('#file').after('
Delimiter:
');
} else {
$("#fileformat")
.empty()
.append('')
;
}
});
// The Aelia currency has changed, make sure to warn the user to also change the currency prefix and/or suffix
//$('.aelia_switch').change(function(){
$('.aelia_switch').on('change', function(){
var popup_dialog = alert("You have changed the Aelia currency, this will change pricing in your product feed. Make sure the currency prefix and/or suffix on the field mapping page is correct.");
});
jQuery("#countries").on("change", function(){
var country = this.value;
jQuery.ajax({
method: "POST",
url: ajaxurl,
data: { 'action': 'woosea_channel', 'country': country }
})
.done(function( data ) {
data = JSON.parse( data );
var select = $('#channel_hash');
select.empty();
$.each(data, function(index, val) {
if(val.type == 'Custom Feed'){
if($('optgroup[label="Custom Feed"]').length == 0){
var optgroup_customfeed = $('