| 1 |
<?php |
| 2 |
/** |
| 3 |
* Admin - Delivery Setting Page. |
| 4 |
* |
| 5 |
* @package Welcart |
| 6 |
*/ |
| 7 |
|
| 8 |
$delivery_method = isset( $this->options['delivery_method'] ) ? $this->options['delivery_method'] : array(); |
| 9 |
$shipping_charge = isset( $this->options['shipping_charge'] ) ? $this->options['shipping_charge'] : array(); |
| 10 |
$target_market = ( isset( $this->options['system']['target_market'] ) && ! empty( $this->options['system']['target_market'] ) ) ? $this->options['system']['target_market'] : usces_get_local_target_market(); |
| 11 |
foreach ( (array) $target_market as $tm ) { |
| 12 |
$prefs[ $tm ] = get_usces_states( $tm ); |
| 13 |
array_shift( $prefs[ $tm ] ); |
| 14 |
} |
| 15 |
$shipping_charge = apply_filters( 'usces_filter_admin_shipping_charge', $shipping_charge, $target_market, $prefs ); |
| 16 |
$delivery_time_limit['hour'] = isset( $this->options['delivery_time_limit']['hour'] ) ? $this->options['delivery_time_limit']['hour'] : '00'; |
| 17 |
$delivery_time_limit['min'] = isset( $this->options['delivery_time_limit']['min'] ) ? $this->options['delivery_time_limit']['min'] : '00'; |
| 18 |
$shortest_delivery_time = isset( $this->options['shortest_delivery_time'] ) ? $this->options['shortest_delivery_time'] : '0'; |
| 19 |
$delivery_after_days = ( empty( $this->options['delivery_after_days'] ) ) ? 15 : (int) $this->options['delivery_after_days']; |
| 20 |
$delivery_days = isset( $this->options['delivery_days'] ) ? $this->options['delivery_days'] : array(); |
| 21 |
$base_country = $this->options['system']['base_country']; |
| 22 |
?> |
| 23 |
<script type="text/javascript"> |
| 24 |
jQuery(function($){ |
| 25 |
|
| 26 |
$(".charge_text").bind("change", function(){ usces_check_money($(this)); }); |
| 27 |
$(".days_text").bind("change", function(){ usces_check_num($(this)); }); |
| 28 |
|
| 29 |
<?php |
| 30 |
if ( ! array_key_exists( $base_country, (array) $target_market ) ) { |
| 31 |
$base_country = $target_market[0]; |
| 32 |
} |
| 33 |
$i = 0; |
| 34 |
?> |
| 35 |
var target_market = []; |
| 36 |
<?php foreach ( (array) $target_market as $tm ) : ?> |
| 37 |
target_market[<?php echo esc_js( $i ); ?>] = "<?php echo esc_js( $tm ); ?>"; |
| 38 |
<?php $i++; ?> |
| 39 |
<?php endforeach; ?> |
| 40 |
var base_country = "<?php echo esc_js( $base_country ); ?>"; |
| 41 |
|
| 42 |
var delivery_method = []; |
| 43 |
<?php |
| 44 |
$delivery_method_count = ( is_array( $delivery_method ) ) ? count( $delivery_method ) : 0; |
| 45 |
for ( $i = 0; $i < $delivery_method_count; $i++ ) { |
| 46 |
$delivery_method[ $i ]['time'] = usces_change_line_break( $delivery_method[ $i ]['time'] ); |
| 47 |
$lines = explode( "\n", $delivery_method[ $i ]['time'] ); |
| 48 |
?> |
| 49 |
delivery_method[<?php echo esc_js( $i ); ?>] = []; |
| 50 |
delivery_method[<?php echo esc_js( $i ); ?>]['id'] = <?php echo esc_js( (int) $delivery_method[ $i ]['id'] ); ?>; |
| 51 |
delivery_method[<?php echo esc_js( $i ); ?>]['name'] = "<?php echo esc_js( $delivery_method[ $i ]['name'] ); ?>"; |
| 52 |
delivery_method[<?php echo esc_js( $i ); ?>]['charge'] = <?php echo esc_js( (int) $delivery_method[ $i ]['charge'] ); ?>; |
| 53 |
delivery_method[<?php echo esc_js( $i ); ?>]['days'] = <?php echo esc_js( (int) $delivery_method[ $i ]['days'] ); ?>; |
| 54 |
sttr = ''; |
| 55 |
<?php |
| 56 |
foreach ( (array) $lines as $line ) { |
| 57 |
if ( trim( $line ) != '' ) { |
| 58 |
?> |
| 59 |
sttr += "<?php echo esc_js( trim( $line ) ); ?>\n"; |
| 60 |
<?php |
| 61 |
} |
| 62 |
} |
| 63 |
?> |
| 64 |
delivery_method[<?php echo esc_js( $i ); ?>]['time'] = sttr; |
| 65 |
delivery_method[<?php echo esc_js( $i ); ?>]['nocod'] = "<?php echo esc_js( $delivery_method[ $i ]['nocod'] ); ?>"; |
| 66 |
delivery_method[<?php echo esc_js( $i ); ?>]['intl'] = "<?php echo ( ! empty( $delivery_method[ $i ]['intl'] ) ) ? esc_js( $delivery_method[ $i ]['intl'] ) : '0'; ?>"; |
| 67 |
delivery_method[<?php echo esc_js( $i ); ?>]['cool_category'] = "<?php echo ( ! empty( $delivery_method[ $i ]['cool_category'] ) ) ? esc_js( $delivery_method[ $i ]['cool_category'] ) : '0'; ?>"; |
| 68 |
<?php } ?> |
| 69 |
|
| 70 |
var pref = []; |
| 71 |
<?php foreach ( (array) $target_market as $tm ) { ?> |
| 72 |
pref["<?php echo esc_js( $tm ); ?>"] = []; |
| 73 |
<?php foreach ( (array) $prefs[ $tm ] as $pref ) { ?> |
| 74 |
pref["<?php echo esc_js( $tm ); ?>"].push("<?php echo esc_js( $pref ); ?>"); |
| 75 |
<?php |
| 76 |
} |
| 77 |
} |
| 78 |
?> |
| 79 |
|
| 80 |
var shipping_charge = []; |
| 81 |
<?php |
| 82 |
$shipping_charge_count = ( is_array( $shipping_charge ) ) ? count( $shipping_charge ) : 0; |
| 83 |
for ( $i = 0; $i < $shipping_charge_count; $i++ ) { |
| 84 |
?> |
| 85 |
shipping_charge[<?php echo esc_js( $i ); ?>] = []; |
| 86 |
shipping_charge[<?php echo esc_js( $i ); ?>]["id"] = <?php echo esc_js( (int) $shipping_charge[ $i ]['id'] ); ?>; |
| 87 |
shipping_charge[<?php echo esc_js( $i ); ?>]["name"] = "<?php echo esc_js( $shipping_charge[ $i ]['name'] ); ?>"; |
| 88 |
<?php foreach ( (array) $target_market as $tm ) { ?> |
| 89 |
shipping_charge[<?php echo esc_js( $i ); ?>]["<?php echo esc_js( $tm ); ?>"] = []; |
| 90 |
|
| 91 |
<?php $target_prefs = apply_filters( 'usces_filter_admin_shipping_prefs', $prefs, $shipping_charge[ $i ], $target_market ); ?> |
| 92 |
|
| 93 |
<?php foreach ( (array) $target_prefs[ $tm ] as $pref ) { ?> |
| 94 |
<?php if ( isset( $shipping_charge[ $i ][ $tm ][ $pref ] ) ) : ?> |
| 95 |
shipping_charge[<?php echo esc_js( $i ); ?>]["<?php echo esc_js( $tm ); ?>"]["<?php echo esc_js( $pref ); ?>"] = "<?php echo esc_js( (float) $shipping_charge[ $i ][ $tm ][ $pref ] ); ?>"; |
| 96 |
<?php else : ?> |
| 97 |
shipping_charge[<?php echo esc_js( $i ); ?>]["<?php echo esc_js( $tm ); ?>"]["<?php echo esc_js( $pref ); ?>"] = "0"; |
| 98 |
<?php endif; ?> |
| 99 |
<?php |
| 100 |
} |
| 101 |
} |
| 102 |
} |
| 103 |
?> |
| 104 |
|
| 105 |
var delivery_days = []; |
| 106 |
<?php |
| 107 |
$delivery_days_count = ( is_array( $delivery_days ) ) ? count( $delivery_days ) : 0; |
| 108 |
for ( $i = 0; $i < $delivery_days_count; $i++ ) { |
| 109 |
?> |
| 110 |
delivery_days[<?php echo esc_js( $i ); ?>] = []; |
| 111 |
delivery_days[<?php echo esc_js( $i ); ?>]["id"] = <?php echo esc_js( (int) $delivery_days[ $i ]['id'] ); ?>; |
| 112 |
delivery_days[<?php echo esc_js( $i ); ?>]["name"] = "<?php echo esc_js( $delivery_days[ $i ]['name'] ); ?>"; |
| 113 |
<?php foreach ( (array) $target_market as $tm ) { ?> |
| 114 |
delivery_days[<?php echo esc_js( $i ); ?>]["<?php echo esc_js( $tm ); ?>"] = []; |
| 115 |
<?php foreach ( (array) $prefs[ $tm ] as $pref ) { ?> |
| 116 |
<?php if ( isset( $delivery_days[ $i ][ $tm ][ $pref ] ) ) : ?> |
| 117 |
delivery_days[<?php echo esc_js( $i ); ?>]["<?php echo esc_js( $tm ); ?>"]["<?php echo esc_js( $pref ); ?>"] = "<?php echo esc_js( (int) $delivery_days[ $i ][ $tm ][ $pref ] ); ?>"; |
| 118 |
<?php else : ?> |
| 119 |
delivery_days[<?php echo esc_js( $i ); ?>]["<?php echo esc_js( $tm ); ?>"]["<?php echo esc_js( $pref ); ?>"] = "0"; |
| 120 |
<?php endif; ?> |
| 121 |
<?php |
| 122 |
} |
| 123 |
} |
| 124 |
} |
| 125 |
|
| 126 |
$cool_categories = array( |
| 127 |
array( |
| 128 |
'id' => 0, |
| 129 |
'name' => __( 'normal', 'usces' ), |
| 130 |
), |
| 131 |
array( |
| 132 |
'id' => 1, |
| 133 |
'name' => __( 'frozen', 'usces' ), |
| 134 |
), |
| 135 |
array( |
| 136 |
'id' => 2, |
| 137 |
'name' => __( 'refrige', 'usces' ), |
| 138 |
), |
| 139 |
); |
| 140 |
?> |
| 141 |
var cool_categories = <?php echo json_encode( $cool_categories ); ?> |
| 142 |
|
| 143 |
var selected_method = 0; |
| 144 |
function get_delivery_method_charge(selected){ |
| 145 |
var index = 0; |
| 146 |
for(var i=0; i<delivery_method.length; i++){ |
| 147 |
if(selected === delivery_method[i]['id']){ |
| 148 |
index = i; |
| 149 |
} |
| 150 |
} |
| 151 |
if(undefined === delivery_method[index]){ |
| 152 |
return -1; |
| 153 |
}else{ |
| 154 |
return delivery_method[index]['charge']; |
| 155 |
} |
| 156 |
} |
| 157 |
|
| 158 |
$("#delivery_method_charge").click(function () { |
| 159 |
if(shipping_charge.length == 0){ |
| 160 |
alert('<?php esc_html_e( 'Please set the shipping price', 'usces' ); ?>'); |
| 161 |
} |
| 162 |
}); |
| 163 |
|
| 164 |
function get_delivery_method_days(selected){ |
| 165 |
var index = 0; |
| 166 |
for(var i=0; i<delivery_method.length; i++){ |
| 167 |
if(selected === delivery_method[i]['id']){ |
| 168 |
index = i; |
| 169 |
} |
| 170 |
} |
| 171 |
if(undefined === delivery_method[index]){ |
| 172 |
return -1; |
| 173 |
}else{ |
| 174 |
return delivery_method[index]['days']; |
| 175 |
} |
| 176 |
} |
| 177 |
|
| 178 |
$("#delivery_method_days").click(function () { |
| 179 |
if(delivery_days.length == 0){ |
| 180 |
alert('<?php esc_html_e( 'Please set the delivery days', 'usces' ); ?>'); |
| 181 |
} |
| 182 |
}); |
| 183 |
|
| 184 |
function get_delivery_cool_category(selected){ |
| 185 |
var index = 0; |
| 186 |
for(var i=0; i<delivery_method.length; i++){ |
| 187 |
if(selected === delivery_method[i]['id']){ |
| 188 |
index = i; |
| 189 |
} |
| 190 |
} |
| 191 |
if(undefined === delivery_method[index] || undefined === delivery_method[index]['cool_category']){ |
| 192 |
return 0; |
| 193 |
}else{ |
| 194 |
return delivery_method[index]['cool_category']; |
| 195 |
} |
| 196 |
} |
| 197 |
|
| 198 |
$("#new_delivery_method_action").click(function () { |
| 199 |
if(delivery_method.length === 0) return false; |
| 200 |
$("#delivery_method_name").html('<input name="delivery_method_name" type="text" value="" />'); |
| 201 |
$("#delivery_method_name2").html(''); |
| 202 |
$("#delivery_method_time").val(''); |
| 203 |
$("#delivery_method_button").html('<input name="cancel_delivery_method" id="cancel_delivery_method" type="button" class="button" value="<?php esc_attr_e( 'Cancel', 'usces' ); ?>" onclick="operation.disp_delivery_method(0);" /> <input name="add_delivery_method" id="add_delivery_method" type="button" class="button" value="<?php esc_attr_e( 'Add', 'usces' ); ?>" onclick="operation.add_delivery_method();" />'); |
| 204 |
$("#delivery_method_nocod").html('<input name="delivery_method_nocod" type="checkbox" value="1" />'); |
| 205 |
$("#delivery_method_intl").html('<input name="delivery_method_intl" id="delivery_method_intl_0" type="radio" value="0" checked /><label for="delivery_method_intl_0"><?php esc_html_e( 'Domestic Shipment', 'usces' ); ?></label> <input name="delivery_method_intl" id="delivery_method_intl_1" type="radio" value="1" /><label for="delivery_method_intl_1"><?php esc_html_e( 'International Shipment', 'usces' ); ?></label>'); |
| 206 |
$("input[name='delivery_method_name']").focus().select(); |
| 207 |
operation.make_delivery_method_charge(-1); |
| 208 |
operation.make_delivery_method_days(-1); |
| 209 |
operation.make_delivery_cool_category(0); |
| 210 |
}); |
| 211 |
|
| 212 |
$("#moveup_action").click(function () { |
| 213 |
var id = $("#delivery_method_name_select option:selected").val()-0; |
| 214 |
operation.moveup_delivery_method(id); |
| 215 |
operation.disp_delivery_method(id); |
| 216 |
}); |
| 217 |
|
| 218 |
$("#movedown_action").click(function () { |
| 219 |
var id = $("#delivery_method_name_select option:selected").val()-0; |
| 220 |
operation.movedown_delivery_method(id); |
| 221 |
operation.disp_delivery_method(id); |
| 222 |
}); |
| 223 |
|
| 224 |
$("#new_shipping_charge_action").click(function () { |
| 225 |
var valuehtml = ''; |
| 226 |
for( var j = 0; j < target_market.length; j++ ) { |
| 227 |
var tm = target_market[j]; |
| 228 |
valuehtml += "<div id='shipping_charge_"+tm+"'>"; |
| 229 |
for( var i = 0; i < pref[tm].length; i++ ) { |
| 230 |
var p = pref[tm][i]; |
| 231 |
valuehtml += "<div class='clearfix'><label class='shipping_charge_label'>"+p+"</label><input type='text' name=\"shipping_charge_value_"+tm+"["+p+"]\" value='' class='charge_text' /><?php usces_crcode(); ?></div>\n"; |
| 232 |
} |
| 233 |
valuehtml += "</div>"; |
| 234 |
} |
| 235 |
$("#shipping_charge_country").val(base_country); |
| 236 |
$("#shipping_charge_name").html('<input name="shipping_charge_name" type="text" value="" />'); |
| 237 |
$("#shipping_charge_name2").html(''); |
| 238 |
$("#shipping_charge_value").html(valuehtml); |
| 239 |
$("#shipping_charge_button").html('<input name="cancel_shipping_charge" id="cancel_shipping_charge" type="button" class="button" value="<?php esc_attr_e( 'Cancel', 'usces' ); ?>" onclick="operation.disp_shipping_charge(0);" /> <input name="add_shipping_charge" id="add_shipping_charge" type="button" class="button" value="<?php esc_attr_e( 'Add', 'usces' ); ?>" onclick="operation.add_shipping_charge();" />'); |
| 240 |
$("input[name='shipping_charge_name']").focus().select(); |
| 241 |
$(".charge_text").bind("change", function(){ usces_check_money($(this)); }); |
| 242 |
for( var i = 0; i < target_market.length; i++ ) { |
| 243 |
if( base_country == target_market[i] ) { |
| 244 |
$("#shipping_charge_"+target_market[i]).css("display",""); |
| 245 |
} else { |
| 246 |
$("#shipping_charge_"+target_market[i]).css("display","none"); |
| 247 |
} |
| 248 |
} |
| 249 |
}); |
| 250 |
|
| 251 |
$("#new_delivery_days_action").click(function () { |
| 252 |
var valuehtml = ''; |
| 253 |
for( var j = 0; j < target_market.length; j++ ) { |
| 254 |
var tm = target_market[j]; |
| 255 |
valuehtml += "<div id='delivery_days_"+tm+"'>"; |
| 256 |
for( var i = 0; i < pref[tm].length; i++ ) { |
| 257 |
var p = pref[tm][i]; |
| 258 |
valuehtml += "<div class='clearfix'><label class='delivery_days_label'>"+p+"</label><input type='text' name=\"delivery_days_value_"+tm+"["+p+"]\" value='' class='days_text' /><?php esc_html_e( 'day', 'usces' ); ?></div>\n"; |
| 259 |
} |
| 260 |
valuehtml += "</div>"; |
| 261 |
} |
| 262 |
$("#delivery_days_country").val(base_country); |
| 263 |
$("#delivery_days_name").html('<input name="delivery_days_name" type="text" value="" />'); |
| 264 |
$("#delivery_days_name2").html(''); |
| 265 |
$("#delivery_days_value").html(valuehtml); |
| 266 |
$("#delivery_days_button").html('<input name="cancel_delivery_days" id="cancel_delivery_days" type="button" class="button" value="<?php esc_attr_e( 'Cancel', 'usces' ); ?>" onclick="operation.disp_delivery_days(0);" /> <input name="add_delivery_days" id="add_delivery_days" type="button" class="button" value="<?php esc_attr_e( 'Add', 'usces' ); ?>" onclick="operation.add_delivery_days();" />'); |
| 267 |
$("input[name='delivery_days_name']").focus().select(); |
| 268 |
$(".days_text").bind("change", function(){ usces_check_num($(this)); }); |
| 269 |
for( var i = 0; i < target_market.length; i++ ) { |
| 270 |
if( base_country == target_market[i] ) { |
| 271 |
$("#delivery_days_"+target_market[i]).css("display",""); |
| 272 |
} else { |
| 273 |
$("#delivery_days_"+target_market[i]).css("display","none"); |
| 274 |
} |
| 275 |
} |
| 276 |
}); |
| 277 |
|
| 278 |
operation = { |
| 279 |
disp_delivery_method :function (id){ |
| 280 |
selected_method = id; |
| 281 |
var index = false; |
| 282 |
for(var i=0; i<delivery_method.length; i++){ |
| 283 |
if(id === delivery_method[i]['id']){ |
| 284 |
index = i; |
| 285 |
} |
| 286 |
} |
| 287 |
if(false === index){ |
| 288 |
selected = 0; |
| 289 |
}else{ |
| 290 |
selected = index; |
| 291 |
} |
| 292 |
if(delivery_method.length === 0) { |
| 293 |
$("#delivery_method_name").html('<input name="delivery_method_name" type="text" value="" />'); |
| 294 |
$("#delivery_method_name2").html(''); |
| 295 |
$("#delivery_method_time").val(''); |
| 296 |
$("#delivery_method_button").html('<input name="add_delivery_method" id="add_delivery_method" type="button" class="button" value="<?php esc_attr_e( 'Add', 'usces' ); ?>" onclick="operation.add_delivery_method();" />'); |
| 297 |
$("#delivery_method_nocod").html('<input name="delivery_method_nocod" type="checkbox" value="1" />'); |
| 298 |
$("#delivery_method_intl").html('<input name="delivery_method_intl" id="delivery_method_intl_0" type="radio" value="0" checked /><label for="delivery_method_intl_0"><?php esc_html_e( 'Domestic Shipment', 'usces' ); ?></label> <input name="delivery_method_intl" id="delivery_method_intl_1" type="radio" value="1" /><label for="delivery_method_intl_1"><?php esc_html_e( 'International Shipment', 'usces' ); ?></label>'); |
| 299 |
operation.make_delivery_method_charge(-1); |
| 300 |
operation.make_delivery_method_days(-1); |
| 301 |
operation.make_delivery_cool_category(0); |
| 302 |
}else{ |
| 303 |
var name_select = '<select name="delivery_method_name_select" id="delivery_method_name_select" onchange="operation.onchange_delivery_select(this.selectedIndex);">'+"\n"; |
| 304 |
for(var i=0; i<delivery_method.length; i++){ |
| 305 |
if(selected === i){ |
| 306 |
name_select += '<option value="'+delivery_method[i]['id']+'" selected="selected">'+delivery_method[i]['id']+' : ' + esc_js( delivery_method[i]['name'] ) + '</option>'+"\n"; |
| 307 |
}else{ |
| 308 |
name_select += '<option value="'+delivery_method[i]['id']+'">'+delivery_method[i]['id']+' : '+esc_js( delivery_method[i]['name'] )+'</option>'+"\n"; |
| 309 |
} |
| 310 |
} |
| 311 |
name_select += "</select>\n"; |
| 312 |
$("#delivery_method_name").html(name_select); |
| 313 |
$("#delivery_method_name2").html('<input name="delivery_method_name" type="text" value="'+esc_js( delivery_method[selected]['name'] )+'" />'); |
| 314 |
$("#delivery_method_time").val(delivery_method[selected]['time']); |
| 315 |
$("#delivery_method_button").html("<input name='delete_delivery_method' id='delete_delivery_method' type='button' class='button' value='<?php esc_attr_e( 'Delete', 'usces' ); ?>' onclick='operation.delete_delivery_method();' /> <input name='update_delivery_method' id='update_delivery_method' type='button' class='button' value='<?php esc_attr_e( 'update', 'usces' ); ?>' onclick='operation.update_delivery_method();' />"); |
| 316 |
var checked_nocod = (delivery_method[selected]['nocod'] == '1') ? ' checked' : ''; |
| 317 |
$("#delivery_method_nocod").html('<input name="delivery_method_nocod" type="checkbox" value="1"'+checked_nocod+' />'); |
| 318 |
var checked_intl_0 = (delivery_method[selected]['intl'] == '0') ? ' checked' : ''; |
| 319 |
var checked_intl_1 = (delivery_method[selected]['intl'] == '1') ? ' checked' : ''; |
| 320 |
$("#delivery_method_intl").html('<input name="delivery_method_intl" id="delivery_method_intl_0" type="radio" value="0"'+checked_intl_0+' /><label for="delivery_method_intl_0"><?php esc_html_e( 'Domestic Shipment', 'usces' ); ?></label> <input name="delivery_method_intl" id="delivery_method_intl_1" type="radio" value="1"'+checked_intl_1+' /><label for="delivery_method_intl_1"><?php esc_html_e( 'International Shipment', 'usces' ); ?></label>'); |
| 321 |
operation.make_delivery_method_charge(get_delivery_method_charge(selected_method)); |
| 322 |
operation.make_delivery_method_days(get_delivery_method_days(selected_method)); |
| 323 |
operation.make_delivery_cool_category(get_delivery_cool_category(selected_method)); |
| 324 |
} |
| 325 |
}, |
| 326 |
|
| 327 |
add_delivery_method : function() { |
| 328 |
if($("input[name='delivery_method_name']").val() == "") return; |
| 329 |
|
| 330 |
var wc_nonce = $("#wc_nonce").val(); |
| 331 |
var _wp_http_referer = $("input[name='_wp_http_referer']").val(); |
| 332 |
|
| 333 |
$("#delivery_method_loading").html('<img src="<?php echo esc_url( USCES_PLUGIN_URL ); ?>/images/loading-publish.gif" />'); |
| 334 |
var name = encodeURIComponent($("input[name='delivery_method_name']").val()); |
| 335 |
var time = encodeURIComponent($("#delivery_method_time").val()); |
| 336 |
var charge = $("#delivery_method_charge option:selected").val(); |
| 337 |
var days = $("#delivery_method_days option:selected").val(); |
| 338 |
var nocod = ($(':input[name=delivery_method_nocod]').prop('checked')) ? '1' : '0'; |
| 339 |
var intl = $(':radio[name=delivery_method_intl]:checked').val(); |
| 340 |
var cool_cat = $("#delivery_cool_category option:selected").val(); |
| 341 |
|
| 342 |
var s = operation.settings; |
| 343 |
s.data = "action=shop_options_ajax&mode=add_delivery_method&name=" + name + "&timeband=" + time + "&charge=" + charge + "&days=" + days + "&nocod=" + nocod + "&intl=" + intl + "&cool_category=" + cool_cat + "&wc_nonce=" + encodeURIComponent(wc_nonce)+ "&_wp_http_referer=" + encodeURIComponent(_wp_http_referer); |
| 344 |
$.ajax( s ).done(function( response ){ |
| 345 |
var data = JSON.parse(response); |
| 346 |
var index = delivery_method.length; |
| 347 |
delivery_method[index] = []; |
| 348 |
delivery_method[index]['id'] = data.id; |
| 349 |
delivery_method[index]['name'] = esc_js( data.name ); |
| 350 |
delivery_method[index]['time'] = data.time; |
| 351 |
delivery_method[index]['charge'] = data.charge - 0; |
| 352 |
delivery_method[index]['days'] = data.days - 0; |
| 353 |
delivery_method[index]['nocod'] = data.nocod; |
| 354 |
delivery_method[index]['intl'] = data.intl; |
| 355 |
delivery_method[index]['cool_category'] = data.cool_cat - 0; |
| 356 |
operation.disp_delivery_method(data.id); |
| 357 |
$("#delivery_method_loading").html(''); |
| 358 |
}).fail(function( msg ){ |
| 359 |
$("#delivery_method_loading").html(''); |
| 360 |
}); |
| 361 |
return false; |
| 362 |
}, |
| 363 |
|
| 364 |
update_delivery_method : function() { |
| 365 |
if($("input[name='delivery_method_name']").val() == "") return; |
| 366 |
|
| 367 |
var wc_nonce = $("#wc_nonce").val(); |
| 368 |
var _wp_http_referer = $("input[name='_wp_http_referer']").val(); |
| 369 |
|
| 370 |
$("#delivery_method_loading").html('<img src="<?php echo esc_url( USCES_PLUGIN_URL ); ?>/images/loading-publish.gif" />'); |
| 371 |
var id = $("#delivery_method_name_select option:selected").val(); |
| 372 |
var name = encodeURIComponent($("input[name='delivery_method_name']").val()); |
| 373 |
var time = encodeURIComponent($("#delivery_method_time").val()); |
| 374 |
var charge = $("#delivery_method_charge option:selected").val(); |
| 375 |
var days = $("#delivery_method_days option:selected").val(); |
| 376 |
var nocod = ($(':input[name=delivery_method_nocod]').prop('checked')) ? '1' : '0'; |
| 377 |
var intl = $(':radio[name=delivery_method_intl]:checked').val(); |
| 378 |
var cool_cat = $("#delivery_cool_category option:selected").val(); |
| 379 |
|
| 380 |
var s = operation.settings; |
| 381 |
s.data = "action=shop_options_ajax&mode=update_delivery_method&name=" + name + "&id=" + id + "&timeband=" + time + "&charge=" + charge + "&days=" + days + "&nocod=" + nocod + "&intl=" + intl + "&cool_category=" + cool_cat + "&wc_nonce=" + encodeURIComponent(wc_nonce)+ "&_wp_http_referer=" + encodeURIComponent(_wp_http_referer); |
| 382 |
$.ajax( s ).done(function( response ){ |
| 383 |
var data = JSON.parse(response); |
| 384 |
var id = data.id - 0; |
| 385 |
for(var i = 0; i < delivery_method.length; i++){ |
| 386 |
if(id === delivery_method[i]['id']){ |
| 387 |
index = i; |
| 388 |
break; |
| 389 |
} |
| 390 |
} |
| 391 |
delivery_method[index] = []; |
| 392 |
delivery_method[index]['id'] = id; |
| 393 |
delivery_method[index]['name'] = esc_js( data.name ); |
| 394 |
delivery_method[index]['time'] = data.time; |
| 395 |
delivery_method[index]['charge'] = data.charge - 0; |
| 396 |
delivery_method[index]['days'] = data.days - 0; |
| 397 |
delivery_method[index]['nocod'] = data.nocod; |
| 398 |
delivery_method[index]['intl'] = data.intl; |
| 399 |
delivery_method[index]['cool_category'] = data.cool_category - 0; |
| 400 |
operation.disp_delivery_method(data.id); |
| 401 |
operation.disp_delivery_method(id); |
| 402 |
$("#delivery_method_loading").html(''); |
| 403 |
}).fail(function( msg ){ |
| 404 |
$("#delivery_method_loading").html(''); |
| 405 |
}); |
| 406 |
return false; |
| 407 |
}, |
| 408 |
|
| 409 |
delete_delivery_method : function() { |
| 410 |
var delname = $("#delivery_method_name_select option:selected").html(); |
| 411 |
|
| 412 |
var wc_nonce = $("#wc_nonce").val(); |
| 413 |
var _wp_http_referer = $("input[name='_wp_http_referer']").val(); |
| 414 |
|
| 415 |
if(!confirm(<?php _e( "'Are you sure of deleting the delivery method ' + delname + ' ?'", 'usces' ); ?>)) return false; |
| 416 |
|
| 417 |
$("#delivery_method_loading").html('<img src="<?php echo esc_url( USCES_PLUGIN_URL ); ?>/images/loading-publish.gif" />'); |
| 418 |
var id = $("#delivery_method_name_select option:selected").val(); |
| 419 |
|
| 420 |
var s = operation.settings; |
| 421 |
s.data = "action=shop_options_ajax&mode=delete_delivery_method&id=" + id + "&wc_nonce=" + encodeURIComponent(wc_nonce)+ "&_wp_http_referer=" + encodeURIComponent(_wp_http_referer); |
| 422 |
$.ajax( s ).done(function( response ){ |
| 423 |
data = JSON.parse(response); |
| 424 |
var id = data.id - 0; |
| 425 |
delivery_method = delivery_method.filter(function(method) { |
| 426 |
return method['id'] != id; |
| 427 |
}); |
| 428 |
operation.disp_delivery_method(0); |
| 429 |
$("#delivery_method_loading").html(''); |
| 430 |
}).fail(function( msg ){ |
| 431 |
$("#delivery_method_loading").html(''); |
| 432 |
}); |
| 433 |
return false; |
| 434 |
}, |
| 435 |
|
| 436 |
onchange_delivery_select : function(index) { |
| 437 |
var id = $("#delivery_method_name_select option:eq("+index+")").val()-0; |
| 438 |
operation.disp_delivery_method(id); |
| 439 |
}, |
| 440 |
|
| 441 |
make_delivery_method_charge : function(selected) { |
| 442 |
var option = '<select name="delivery_method_charge" id="delivery_method_charge">'+"\n"; |
| 443 |
|
| 444 |
if(selected === -1){ |
| 445 |
option += '<option value="-1" selected="selected"><?php esc_attr_e( 'Not fixing shipping.', 'usces' ); ?></option>'+"\n"; |
| 446 |
}else{ |
| 447 |
option += '<option value="-1"><?php esc_attr_e( 'Not fixing shipping.', 'usces' ); ?></option>'+"\n"; |
| 448 |
} |
| 449 |
for(var i=0; i<shipping_charge.length; i++){ |
| 450 |
if(selected === shipping_charge[i]['id']){ |
| 451 |
option += '<option value="'+shipping_charge[i]['id']+'" selected="selected">'+esc_js( shipping_charge[i]['name'] )+'</option>'+"\n"; |
| 452 |
}else{ |
| 453 |
option += '<option value="'+shipping_charge[i]['id']+'">'+esc_js( shipping_charge[i]['name'] )+'</option>'+"\n"; |
| 454 |
} |
| 455 |
} |
| 456 |
option += '</select>'; |
| 457 |
$("#delivery_method_charge_td").html(option); |
| 458 |
}, |
| 459 |
|
| 460 |
make_delivery_method_days : function(selected) { |
| 461 |
var option = '<select name="delivery_method_days" id="delivery_method_days">'+"\n"; |
| 462 |
|
| 463 |
if(selected === -1){ |
| 464 |
option += '<option value="-1" selected="selected"><?php esc_attr_e( 'Delivery Date Not Specified', 'usces' ); ?></option>'+"\n"; |
| 465 |
}else{ |
| 466 |
option += '<option value="-1"><?php esc_attr_e( 'Delivery Date Not Specified', 'usces' ); ?></option>'+"\n"; |
| 467 |
} |
| 468 |
for(var i=0; i<delivery_days.length; i++){ |
| 469 |
if(selected === delivery_days[i]['id']){ |
| 470 |
option += '<option value="'+delivery_days[i]['id']+'" selected="selected">'+esc_js( delivery_days[i]['name'] )+'</option>'+"\n"; |
| 471 |
}else{ |
| 472 |
option += '<option value="'+delivery_days[i]['id']+'">'+esc_js( delivery_days[i]['name'] )+'</option>'+"\n"; |
| 473 |
} |
| 474 |
} |
| 475 |
option += '</select>'; |
| 476 |
$("#delivery_method_days_td").html(option); |
| 477 |
}, |
| 478 |
|
| 479 |
make_delivery_cool_category : function(selected) { |
| 480 |
selected = parseInt(selected); |
| 481 |
var option = '<select name="delivery_cool_category" id="delivery_cool_category">'+"\n"; |
| 482 |
|
| 483 |
for(var i=0; i<cool_categories.length; i++){ |
| 484 |
if(selected === cool_categories[i]['id']){ |
| 485 |
option += '<option value="'+cool_categories[i]['id']+'" selected="selected">'+esc_js( cool_categories[i]['name'] )+'</option>'+"\n"; |
| 486 |
}else{ |
| 487 |
option += '<option value="'+cool_categories[i]['id']+'">'+esc_js( cool_categories[i]['name'] )+'</option>'+"\n"; |
| 488 |
} |
| 489 |
} |
| 490 |
option += '</select>'; |
| 491 |
$("#delivery_cool_category_td").html(option); |
| 492 |
}, |
| 493 |
|
| 494 |
moveup_delivery_method : function(selected) { |
| 495 |
var wc_nonce = $("#wc_nonce").val(); |
| 496 |
var _wp_http_referer = $("input[name='_wp_http_referer']").val(); |
| 497 |
|
| 498 |
var index = 0; |
| 499 |
for(var i=0; i<delivery_method.length; i++){ |
| 500 |
if(selected === delivery_method[i]['id']){ |
| 501 |
index = i; |
| 502 |
} |
| 503 |
} |
| 504 |
if( 0 === index ) return; |
| 505 |
|
| 506 |
$("#delivery_method_loading").html('<img src="<?php echo esc_url( USCES_PLUGIN_URL ); ?>/images/loading-publish.gif" />'); |
| 507 |
|
| 508 |
var s = operation.settings; |
| 509 |
s.data = "action=shop_options_ajax&mode=moveup_delivery_method&id=" + selected + "&wc_nonce=" + encodeURIComponent(wc_nonce)+ "&_wp_http_referer=" + encodeURIComponent(_wp_http_referer); |
| 510 |
$.ajax( s ).done(function( response ){ |
| 511 |
var data = JSON.parse(response); |
| 512 |
var id = data.id.split(','); |
| 513 |
var name = data.name.split(','); |
| 514 |
var time = data.time.split(','); |
| 515 |
var charge = data.charge.split(','); |
| 516 |
var days = data.days.split(','); |
| 517 |
var nocod = data.nocod.split(','); |
| 518 |
var intl = data.intl.split(','); |
| 519 |
var cool_cate = data.cool_category.split(','); |
| 520 |
var selected = data.selected - 0; |
| 521 |
var ct = delivery_method.length; |
| 522 |
for(var i=0; i<ct; i++){ |
| 523 |
delivery_method[i]['id'] = id[i]-0; |
| 524 |
delivery_method[i]['name'] = esc_js( name[i] ); |
| 525 |
delivery_method[i]['time'] = time[i]; |
| 526 |
delivery_method[i]['charge'] = charge[i]-0; |
| 527 |
delivery_method[i]['days'] = days[i]-0; |
| 528 |
delivery_method[i]['nocod'] = nocod[i]; |
| 529 |
delivery_method[i]['intl'] = intl[i]; |
| 530 |
delivery_method[i]['cool_category'] = cool_cate[i]-0; |
| 531 |
} |
| 532 |
operation.disp_delivery_method(selected); |
| 533 |
$("#delivery_method_loading").html(''); |
| 534 |
}).fail(function( msg ){ |
| 535 |
$("#delivery_method_loading").html(''); |
| 536 |
}); |
| 537 |
return false; |
| 538 |
}, |
| 539 |
|
| 540 |
movedown_delivery_method : function(selected) { |
| 541 |
var wc_nonce = $("#wc_nonce").val(); |
| 542 |
var _wp_http_referer = $("input[name='_wp_http_referer']").val(); |
| 543 |
|
| 544 |
var index = 0; |
| 545 |
var ct = delivery_method.length; |
| 546 |
for(var i=0; i<ct; i++){ |
| 547 |
if(selected === delivery_method[i]['id']){ |
| 548 |
index = i; |
| 549 |
} |
| 550 |
} |
| 551 |
if( index >= ct-1 ) return; |
| 552 |
|
| 553 |
$("#delivery_method_loading").html('<img src="<?php echo esc_url( USCES_PLUGIN_URL ); ?>/images/loading-publish.gif" />'); |
| 554 |
|
| 555 |
var s = operation.settings; |
| 556 |
s.data = "action=shop_options_ajax&mode=movedown_delivery_method&id=" + selected + "&wc_nonce=" + encodeURIComponent(wc_nonce)+ "&_wp_http_referer=" + encodeURIComponent(_wp_http_referer); |
| 557 |
$.ajax( s ).done(function( response ){ |
| 558 |
var data = JSON.parse(response); |
| 559 |
var id = data.id.split(','); |
| 560 |
var name = data.name.split(','); |
| 561 |
var time = data.time.split(','); |
| 562 |
var charge = data.charge.split(','); |
| 563 |
var days = data.days.split(','); |
| 564 |
var nocod = data.nocod.split(','); |
| 565 |
var intl = data.intl.split(','); |
| 566 |
var cool_cate = data.cool_category.split(','); |
| 567 |
var selected = data.selected - 0; |
| 568 |
var ct = delivery_method.length; |
| 569 |
for(var i=0; i<ct; i++){ |
| 570 |
delivery_method[i]['id'] = id[i]-0; |
| 571 |
delivery_method[i]['name'] = esc_js( name[i] ); |
| 572 |
delivery_method[i]['time'] = time[i]; |
| 573 |
delivery_method[i]['charge'] = charge[i]-0; |
| 574 |
delivery_method[i]['days'] = days[i]-0; |
| 575 |
delivery_method[i]['nocod'] = nocod[i]; |
| 576 |
delivery_method[i]['intl'] = intl[i]; |
| 577 |
delivery_method[i]['cool_category'] = cool_cate[i]-0; |
| 578 |
} |
| 579 |
operation.disp_delivery_method(selected); |
| 580 |
$("#delivery_method_loading").html(''); |
| 581 |
$("#delivery_method_loading").html(''); |
| 582 |
}); |
| 583 |
return false; |
| 584 |
}, |
| 585 |
|
| 586 |
disp_shipping_charge : function (id){ |
| 587 |
var valuehtml = ''; |
| 588 |
if(shipping_charge.length === 0) { |
| 589 |
for( var j = 0; j < target_market.length; j++ ) { |
| 590 |
var tm = target_market[j]; |
| 591 |
valuehtml += "<div id='shipping_charge_"+tm+"'>"; |
| 592 |
for( var i = 0; i < pref[tm].length; i++ ) { |
| 593 |
var p = pref[tm][i]; |
| 594 |
valuehtml += "<div class='clearfix'><label class='shipping_charge_label'>"+p+"</label><input type='text' name=\"shipping_charge_value_"+tm+"["+p+"]\" value='' class='charge_text' /><?php usces_crcode(); ?></div>\n"; |
| 595 |
} |
| 596 |
valuehtml += "</div>"; |
| 597 |
} |
| 598 |
$("#shipping_charge_name").html('<input name="shipping_charge_name" type="text" value="" />'); |
| 599 |
$("#shipping_charge_name2").html(''); |
| 600 |
$("#shipping_charge_value").html(valuehtml); |
| 601 |
$("#shipping_charge_button").html('<input name="add_shipping_charge" id="add_shipping_charge" type="button" class="button" value="<?php esc_attr_e( 'Add', 'usces' ); ?>" onclick="operation.add_shipping_charge();" />'); |
| 602 |
}else{ |
| 603 |
var selected = 0; |
| 604 |
var name_select = '<select name="shipping_charge_name_select" id="shipping_charge_name_select" onchange="operation.onchange_shipping_charge(this.selectedIndex);">'+"\n"; |
| 605 |
for(var i=0; i<shipping_charge.length; i++){ |
| 606 |
if(shipping_charge[i]['id'] === id){ |
| 607 |
selected = i; |
| 608 |
name_select += '<option value="'+shipping_charge[i]['id']+'" selected="selected">'+esc_js( shipping_charge[i]['name'] )+'</option>'+"\n"; |
| 609 |
}else{ |
| 610 |
name_select += '<option value="'+shipping_charge[i]['id']+'">'+esc_js( shipping_charge[i]['name'] )+'</option>'+"\n"; |
| 611 |
} |
| 612 |
} |
| 613 |
name_select += "</select>\n"; |
| 614 |
var value = ''; |
| 615 |
for( var j = 0; j < target_market.length; j++ ) { |
| 616 |
var tm = target_market[j]; |
| 617 |
valuehtml += "<div id='shipping_charge_"+tm+"'>"; |
| 618 |
for( var i = 0; i < pref[tm].length; i++ ) { |
| 619 |
var p = pref[tm][i]; |
| 620 |
value = ( shipping_charge[selected][tm][p] == undefined ) ? '' : shipping_charge[selected][tm][p]; |
| 621 |
valuehtml += "<div class='clearfix'><label class='shipping_charge_label'>"+p+"</label><input type='text' name=\"shipping_charge_value_"+tm+"["+p+"]\" value='"+esc_js( value )+"' class='charge_text' /><?php usces_crcode(); ?></div>\n"; |
| 622 |
} |
| 623 |
valuehtml += "</div>"; |
| 624 |
} |
| 625 |
$("#shipping_charge_name").html(name_select); |
| 626 |
$("#shipping_charge_name2").html('<input name="shipping_charge_name" type="text" value="'+esc_js( shipping_charge[selected]['name'] )+'" />'); |
| 627 |
$("#shipping_charge_value").html(valuehtml); |
| 628 |
$("#shipping_charge_button").html("<input name='delete_shipping_charge' id='delete_shipping_charge' type='button' class='button' value='<?php esc_attr_e( 'Delete', 'usces' ); ?>' onclick='operation.delete_shipping_charge();' /> <input name='update_shipping_charge' id='update_shipping_charge' type='button' class='button' value='<?php esc_attr_e( 'update', 'usces' ); ?>' onclick='operation.update_shipping_charge();' />"); |
| 629 |
} |
| 630 |
$(".charge_text").bind("change", function(){ usces_check_money($(this)); }); |
| 631 |
var country = $("#shipping_charge_country option:selected").val(); |
| 632 |
for( var i = 0; i < target_market.length; i++ ) { |
| 633 |
if( country == target_market[i] ) { |
| 634 |
$("#shipping_charge_"+target_market[i]).css("display",""); |
| 635 |
} else { |
| 636 |
$("#shipping_charge_"+target_market[i]).css("display","none"); |
| 637 |
} |
| 638 |
} |
| 639 |
}, |
| 640 |
|
| 641 |
add_shipping_charge : function() { |
| 642 |
var wc_nonce = $("#wc_nonce").val(); |
| 643 |
var _wp_http_referer = $("input[name='_wp_http_referer']").val(); |
| 644 |
|
| 645 |
var error = 0; |
| 646 |
if($("input[name='shipping_charge_name']").val() == "") { |
| 647 |
error++; |
| 648 |
$("input[name='shipping_charge_name']").css({'background-color': '#FFA'}).click(function() { |
| 649 |
$(this).css({'background-color': '#FFF'}); |
| 650 |
}); |
| 651 |
} |
| 652 |
for( var j = 0; j < target_market.length; j++ ) { |
| 653 |
var tm = target_market[j]; |
| 654 |
for( var i = 0; i < pref[tm].length; i++ ) { |
| 655 |
var p = pref[tm][i]; |
| 656 |
var value = $("input[name=\"shipping_charge_value_"+tm+"\["+p+"\]\"]").val(); |
| 657 |
if( "" == value || !checkMoney(value) ) { |
| 658 |
error++; |
| 659 |
$("input[name=\"shipping_charge_value_"+tm+"\["+p+"\]\"]").css({'background-color': '#FFA'}).click(function() { |
| 660 |
$(this).css({'background-color': '#FFF'}); |
| 661 |
}); |
| 662 |
} |
| 663 |
} |
| 664 |
} |
| 665 |
if( 0 < error ) { |
| 666 |
alert("<?php esc_html_e( 'There is incomplete data.', 'usces' ); ?>"); |
| 667 |
return false; |
| 668 |
} |
| 669 |
|
| 670 |
$("#shipping_charge_loading").html('<img src="<?php echo esc_url( USCES_PLUGIN_URL ); ?>/images/loading-publish.gif" />'); |
| 671 |
var name = encodeURIComponent($("input[name='shipping_charge_name']").val()); |
| 672 |
var query = ''; |
| 673 |
for( var j = 0; j < target_market.length; j++ ) { |
| 674 |
var tm = target_market[j]; |
| 675 |
for( var i = 0; i < pref[tm].length; i++ ) { |
| 676 |
query += '&value_'+tm+'[]='+$("input[name=\"shipping_charge_value_"+tm+"\["+pref[tm][i]+"\]\"]").val(); |
| 677 |
} |
| 678 |
} |
| 679 |
|
| 680 |
var s = operation.settings; |
| 681 |
s.data = "action=shop_options_ajax&mode=add_shipping_charge&name="+name+query + "&wc_nonce=" + encodeURIComponent(wc_nonce)+ "&_wp_http_referer=" + encodeURIComponent(_wp_http_referer); |
| 682 |
$.ajax( s ).done(function ( data ){ |
| 683 |
var id = data - 0; |
| 684 |
var index = shipping_charge.length; |
| 685 |
shipping_charge[index] = []; |
| 686 |
shipping_charge[index]['id'] = id; |
| 687 |
shipping_charge[index]['name'] = $("input[name='shipping_charge_name']").val(); |
| 688 |
for( var j = 0; j < target_market.length; j++ ) { |
| 689 |
var tm = target_market[j]; |
| 690 |
shipping_charge[index][tm] = []; |
| 691 |
for( var i = 0; i < pref[tm].length; i++ ) { |
| 692 |
var p = pref[tm][i]; |
| 693 |
shipping_charge[index][tm][p] = $("input[name=\"shipping_charge_value_"+tm+"\["+p+"\]\"]").val(); |
| 694 |
} |
| 695 |
} |
| 696 |
operation.disp_shipping_charge(id); |
| 697 |
operation.make_delivery_method_charge(get_delivery_method_charge(selected_method)); |
| 698 |
$("#shipping_charge_loading").html(''); |
| 699 |
|
| 700 |
}).fail(function( msg ){ |
| 701 |
$("#delivery_method_loading").html(''); |
| 702 |
}); |
| 703 |
return false; |
| 704 |
}, |
| 705 |
|
| 706 |
update_shipping_charge : function() { |
| 707 |
var wc_nonce = $("#wc_nonce").val(); |
| 708 |
var _wp_http_referer = $("input[name='_wp_http_referer']").val(); |
| 709 |
|
| 710 |
var error = 0; |
| 711 |
if($("input[name='shipping_charge_name']").val() == "") { |
| 712 |
error++; |
| 713 |
$("input[name='shipping_charge_name']").css({'background-color': '#FFA'}).click(function() { |
| 714 |
$(this).css({'background-color': '#FFF'}); |
| 715 |
}); |
| 716 |
} |
| 717 |
for( var j = 0; j < target_market.length; j++ ) { |
| 718 |
var tm = target_market[j]; |
| 719 |
for( var i = 0; i < pref[tm].length; i++ ) { |
| 720 |
var p = pref[tm][i]; |
| 721 |
var value = $("input[name=\"shipping_charge_value_"+tm+"\["+p+"\]\"]").val(); |
| 722 |
if( "" == value || !checkMoney(value) ) { |
| 723 |
error++; |
| 724 |
$("input[name=\"shipping_charge_value_"+tm+"\["+p+"\]\"]").css({'background-color': '#FFA'}).click(function() { |
| 725 |
$(this).css({'background-color': '#FFF'}); |
| 726 |
}); |
| 727 |
} |
| 728 |
} |
| 729 |
} |
| 730 |
if( 0 < error ) { |
| 731 |
alert("<?php esc_html_e( 'There is incomplete data.', 'usces' ); ?>"); |
| 732 |
return false; |
| 733 |
} |
| 734 |
|
| 735 |
$("#shipping_charge_loading").html('<img src="<?php echo esc_url( USCES_PLUGIN_URL ); ?>/images/loading-publish.gif" />'); |
| 736 |
var id = $("#shipping_charge_name_select option:selected").val(); |
| 737 |
var name = encodeURIComponent($("input[name='shipping_charge_name']").val()); |
| 738 |
var query = ''; |
| 739 |
for( var j = 0; j < target_market.length; j++ ) { |
| 740 |
var tm = target_market[j]; |
| 741 |
for( var i = 0; i < pref[tm].length; i++ ){ |
| 742 |
query += '&value_'+tm+'[]='+$("input[name=\"shipping_charge_value_"+tm+"\["+pref[tm][i]+"\]\"]").val(); |
| 743 |
} |
| 744 |
} |
| 745 |
var s = operation.settings; |
| 746 |
<?php do_action( 'usces_action_ajax_para_update_shipping_charge' ); ?> |
| 747 |
|
| 748 |
s.data = "action=shop_options_ajax&mode=update_shipping_charge&id="+id+"&name="+name+query + "&wc_nonce=" + encodeURIComponent(wc_nonce)+ "&_wp_http_referer=" + encodeURIComponent(_wp_http_referer); |
| 749 |
$.ajax( s ).done(function( data ){ |
| 750 |
var id = data - 0; |
| 751 |
for(var i=0; i<shipping_charge.length; i++){ |
| 752 |
if(id === shipping_charge[i]['id']){ |
| 753 |
index = i; |
| 754 |
} |
| 755 |
} |
| 756 |
shipping_charge[index]['name'] = $("input[name='shipping_charge_name']").val(); |
| 757 |
for( var j = 0; j < target_market.length; j++ ) { |
| 758 |
var tm = target_market[j]; |
| 759 |
for( var i = 0; i < pref[tm].length; i++ ) { |
| 760 |
var p = pref[tm][i]; |
| 761 |
shipping_charge[index][tm][p] = $("input[name=\"shipping_charge_value_"+tm+"\["+p+"\]\"]").val(); |
| 762 |
} |
| 763 |
} |
| 764 |
operation.disp_shipping_charge(id); |
| 765 |
operation.make_delivery_method_charge(get_delivery_method_charge(selected_method)); |
| 766 |
$("#shipping_charge_loading").html(''); |
| 767 |
}).fail(function( msg ){ |
| 768 |
$("#delivery_method_loading").html(''); |
| 769 |
}); |
| 770 |
return false; |
| 771 |
}, |
| 772 |
|
| 773 |
delete_shipping_charge : function() { |
| 774 |
var wc_nonce = $("#wc_nonce").val(); |
| 775 |
var _wp_http_referer = $("input[name='_wp_http_referer']").val(); |
| 776 |
|
| 777 |
var delname = $("#shipping_charge_name_select option:selected").html(); |
| 778 |
if(!confirm(<?php _e( "'Are you sure of deleting shipping [' + delname + ']?'", 'usces' ); ?>)) return false; |
| 779 |
|
| 780 |
$("#shipping_charge_loading").html('<img src="<?php echo esc_url( USCES_PLUGIN_URL ); ?>/images/loading-publish.gif" />'); |
| 781 |
var id = $("#shipping_charge_name_select option:selected").val(); |
| 782 |
var s = operation.settings; |
| 783 |
s.data = "action=shop_options_ajax&mode=delete_shipping_charge&id=" + id + "&wc_nonce=" + encodeURIComponent(wc_nonce)+ "&_wp_http_referer=" + encodeURIComponent(_wp_http_referer); |
| 784 |
$.ajax( s ).done(function( data ){ |
| 785 |
var id = data - 0; |
| 786 |
shipping_charge = shipping_charge.filter(function(charge) { |
| 787 |
return charge['id'] != id; |
| 788 |
}); |
| 789 |
operation.disp_shipping_charge(0); |
| 790 |
operation.make_delivery_method_charge(get_delivery_method_charge(selected_method)); |
| 791 |
$("#shipping_charge_loading").html(''); |
| 792 |
}).fail(function( msg ){ |
| 793 |
$("#delivery_method_loading").html(''); |
| 794 |
}); |
| 795 |
return false; |
| 796 |
}, |
| 797 |
|
| 798 |
onchange_shipping_charge : function(index) { |
| 799 |
var id = $("#shipping_charge_name_select option:eq("+index+")").val()-0; |
| 800 |
operation.disp_shipping_charge(id); |
| 801 |
}, |
| 802 |
|
| 803 |
allCharge : function () { |
| 804 |
var charge = $("#allcharge").val(); |
| 805 |
if( charge == '' ) return; |
| 806 |
if( confirm(<?php echo sprintf( __( "'Are you sure of setting shiping to %s' + charge + ' for all the prefecture?'", 'usces' ), esc_js( usces_crsymbol( 'return', 'js' ) ) ); ?>) ){ |
| 807 |
var country = $("#shipping_charge_country option:selected").val(); |
| 808 |
for( var i = 0; i < pref[country].length; i++ ) { |
| 809 |
$("input[name=\"shipping_charge_value_"+country+"\["+pref[country][i]+"\]\"]").val(charge); |
| 810 |
} |
| 811 |
$("#allcharge").val(""); |
| 812 |
} |
| 813 |
}, |
| 814 |
|
| 815 |
disp_delivery_days :function (id){ |
| 816 |
var valuehtml = ''; |
| 817 |
if(delivery_days.length === 0) { |
| 818 |
for( var j = 0; j < target_market.length; j++ ) { |
| 819 |
var tm = target_market[j]; |
| 820 |
valuehtml += "<div id='delivery_days_"+tm+"'>"; |
| 821 |
for( var i = 0; i < pref[tm].length; i++ ) { |
| 822 |
var p = pref[tm][i]; |
| 823 |
valuehtml += "<div class='clearfix'><label class='delivery_days_label'>"+p+"</label><input type='text' name=\"delivery_days_value_"+tm+"["+p+"]\" value='' class='charge_text' /><?php esc_html_e( 'day', 'usces' ); ?></div>\n"; |
| 824 |
} |
| 825 |
valuehtml += "</div>"; |
| 826 |
} |
| 827 |
$("#delivery_days_name").html('<input name="delivery_days_name" type="text" value="" />'); |
| 828 |
$("#delivery_days_name2").html(''); |
| 829 |
$("#delivery_days_value").html(valuehtml); |
| 830 |
$("#delivery_days_button").html('<input name="add_delivery_days" id="add_delivery_days" type="button" class="button" value="<?php esc_attr_e( 'Add', 'usces' ); ?>" onclick="operation.add_delivery_days();" />'); |
| 831 |
}else{ |
| 832 |
var selected = 0; |
| 833 |
var name_select = '<select name="delivery_days_name_select" id="delivery_days_name_select" onchange="operation.onchange_delivery_days(this.selectedIndex);">'+"\n"; |
| 834 |
for(var i=0; i<delivery_days.length; i++){ |
| 835 |
if(delivery_days[i]['id'] === id){ |
| 836 |
selected = i; |
| 837 |
name_select += '<option value="'+delivery_days[i]['id']+'" selected="selected">'+esc_js( delivery_days[i]['name'] )+'</option>'+"\n"; |
| 838 |
}else{ |
| 839 |
name_select += '<option value="'+delivery_days[i]['id']+'">'+esc_js( delivery_days[i]['name'] )+'</option>'+"\n"; |
| 840 |
} |
| 841 |
} |
| 842 |
name_select += "</select>\n"; |
| 843 |
var value = ''; |
| 844 |
for( var j = 0; j < target_market.length; j++ ) { |
| 845 |
var tm = target_market[j]; |
| 846 |
valuehtml += "<div id='delivery_days_"+tm+"'>"; |
| 847 |
for( var i = 0; i < pref[tm].length; i++ ) { |
| 848 |
var p = pref[tm][i]; |
| 849 |
value = ( delivery_days[selected][tm][p] == undefined ) ? '' : delivery_days[selected][tm][p]; |
| 850 |
valuehtml += "<div class='clearfix'><label class='delivery_days_label'>"+p+"</label><input type='text' name=\"delivery_days_value_"+tm+"["+p+"]\" value='"+esc_js( value )+"' class='charge_text' /><?php esc_html_e( 'day', 'usces' ); ?></div>\n"; |
| 851 |
} |
| 852 |
valuehtml += "</div>"; |
| 853 |
} |
| 854 |
$("#delivery_days_name").html(name_select); |
| 855 |
$("#delivery_days_name2").html('<input name="delivery_days_name" type="text" value="'+esc_js( delivery_days[selected]['name'] )+'" />'); |
| 856 |
$("#delivery_days_value").html(valuehtml); |
| 857 |
$("#delivery_days_button").html("<input name='delete_delivery_days' id='delete_delivery_days' type='button' class='button' value='<?php esc_attr_e( 'Delete', 'usces' ); ?>' onclick='operation.delete_delivery_days();' /> <input name='update_delivery_days' id='update_delivery_days' type='button' class='button' value='<?php esc_attr_e( 'update', 'usces' ); ?>' onclick='operation.update_delivery_days();' />"); |
| 858 |
} |
| 859 |
$(".days_text").bind("change", function(){ usces_check_num($(this)); }); |
| 860 |
var country = $("#delivery_days_country option:selected").val(); |
| 861 |
for( var i = 0; i < target_market.length; i++ ) { |
| 862 |
if( country == target_market[i] ) { |
| 863 |
$("#delivery_days_"+target_market[i]).css("display",""); |
| 864 |
} else { |
| 865 |
$("#delivery_days_"+target_market[i]).css("display","none"); |
| 866 |
} |
| 867 |
} |
| 868 |
}, |
| 869 |
|
| 870 |
add_delivery_days : function() { |
| 871 |
var wc_nonce = $("#wc_nonce").val(); |
| 872 |
var _wp_http_referer = $("input[name='_wp_http_referer']").val(); |
| 873 |
|
| 874 |
var error = 0; |
| 875 |
if($("input[name='delivery_days_name']").val() == "") { |
| 876 |
error++; |
| 877 |
$("input[name='delivery_days_name']").css({'background-color': '#FFA'}).click(function() { |
| 878 |
$(this).css({'background-color': '#FFF'}); |
| 879 |
}); |
| 880 |
} |
| 881 |
for( var j = 0; j < target_market.length; j++ ) { |
| 882 |
var tm = target_market[j]; |
| 883 |
for( var i = 0; i < pref[tm].length; i++ ) { |
| 884 |
var p = pref[tm][i]; |
| 885 |
var value = $("input[name=\"delivery_days_value_"+tm+"\["+p+"\]\"]").val(); |
| 886 |
if( "" == value || !checkNum(value) ) { |
| 887 |
error++; |
| 888 |
$("input[name=\"delivery_days_value_"+tm+"\["+p+"\]\"]").css({'background-color': '#FFA'}).click(function() { |
| 889 |
$(this).css({'background-color': '#FFF'}); |
| 890 |
}); |
| 891 |
} |
| 892 |
} |
| 893 |
} |
| 894 |
if( 0 < error ) { |
| 895 |
alert("<?php esc_html_e( 'There is incomplete data.', 'usces' ); ?>"); |
| 896 |
return false; |
| 897 |
} |
| 898 |
|
| 899 |
$("#delivery_days_loading").html('<img src="<?php echo esc_url( USCES_PLUGIN_URL ); ?>/images/loading-publish.gif" />'); |
| 900 |
var name = $("input[name='delivery_days_name']").val(); |
| 901 |
var query = ''; |
| 902 |
for( var j = 0; j < target_market.length; j++ ) { |
| 903 |
var tm = target_market[j]; |
| 904 |
for( var i = 0; i < pref[tm].length; i++ ) { |
| 905 |
query += '&value_'+tm+'[]='+$("input[name=\"delivery_days_value_"+tm+"\["+pref[tm][i]+"\]\"]").val(); |
| 906 |
} |
| 907 |
} |
| 908 |
|
| 909 |
var s = operation.settings; |
| 910 |
s.data = "action=shop_options_ajax&mode=add_delivery_days&name="+name+query + "&wc_nonce=" + encodeURIComponent(wc_nonce)+ "&_wp_http_referer=" + encodeURIComponent(_wp_http_referer); |
| 911 |
$.ajax( s ).done(function( data ){ |
| 912 |
var id = data - 0; |
| 913 |
var index = delivery_days.length; |
| 914 |
delivery_days[index] = []; |
| 915 |
delivery_days[index]['id'] = id; |
| 916 |
delivery_days[index]['name'] = $("input[name='delivery_days_name']").val(); |
| 917 |
for( var j = 0; j < target_market.length; j++ ) { |
| 918 |
var tm = target_market[j]; |
| 919 |
delivery_days[index][tm] = []; |
| 920 |
for( var i = 0; i < pref[tm].length; i++ ) { |
| 921 |
var p = pref[tm][i]; |
| 922 |
delivery_days[index][tm][p] = $("input[name=\"delivery_days_value_"+tm+"\["+p+"\]\"]").val(); |
| 923 |
} |
| 924 |
} |
| 925 |
operation.disp_delivery_days(id); |
| 926 |
operation.make_delivery_method_days(get_delivery_method_days(selected_method)); |
| 927 |
$("#delivery_days_loading").html(''); |
| 928 |
}).fail(function( msg ){ |
| 929 |
$("#delivery_method_loading").html(''); |
| 930 |
}); |
| 931 |
return false; |
| 932 |
}, |
| 933 |
|
| 934 |
update_delivery_days : function() { |
| 935 |
var wc_nonce = $("#wc_nonce").val(); |
| 936 |
var _wp_http_referer = $("input[name='_wp_http_referer']").val(); |
| 937 |
|
| 938 |
var error = 0; |
| 939 |
if($("input[name='delivery_days_name']").val() == "") { |
| 940 |
error++; |
| 941 |
$("input[name='delivery_days_name']").css({'background-color': '#FFA'}).click(function() { |
| 942 |
$(this).css({'background-color': '#FFF'}); |
| 943 |
}); |
| 944 |
} |
| 945 |
for( var j = 0; j < target_market.length; j++ ) { |
| 946 |
var tm = target_market[j]; |
| 947 |
for( var i = 0; i < pref[tm].length; i++ ) { |
| 948 |
var p = pref[tm][i]; |
| 949 |
var value = $("input[name=\"delivery_days_value_"+tm+"\["+p+"\]\"]").val(); |
| 950 |
if( "" == value || !checkNum(value) ) { |
| 951 |
error++; |
| 952 |
$("input[name=\"delivery_days_value_"+tm+"\["+p+"\]\"]").css({'background-color': '#FFA'}).click(function() { |
| 953 |
$(this).css({'background-color': '#FFF'}); |
| 954 |
}); |
| 955 |
} |
| 956 |
} |
| 957 |
} |
| 958 |
if( 0 < error ) { |
| 959 |
alert("<?php esc_html_e( 'There is incomplete data.', 'usces' ); ?>"); |
| 960 |
return false; |
| 961 |
} |
| 962 |
|
| 963 |
$("#delivery_days_loading").html('<img src="<?php echo esc_url( USCES_PLUGIN_URL ); ?>/images/loading-publish.gif" />'); |
| 964 |
var id = $("#delivery_days_name_select option:selected").val(); |
| 965 |
var name = $("input[name='delivery_days_name']").val(); |
| 966 |
var query = ''; |
| 967 |
for( var j = 0; j < target_market.length; j++ ) { |
| 968 |
var tm = target_market[j]; |
| 969 |
for( var i = 0; i < pref[tm].length; i++ ){ |
| 970 |
query += '&value_'+tm+'[]='+$("input[name=\"delivery_days_value_"+tm+"\["+pref[tm][i]+"\]\"]").val(); |
| 971 |
} |
| 972 |
} |
| 973 |
var s = operation.settings; |
| 974 |
s.data = "action=shop_options_ajax&mode=update_delivery_days&id="+id+"&name="+name+query + "&wc_nonce=" + encodeURIComponent(wc_nonce)+ "&_wp_http_referer=" + encodeURIComponent(_wp_http_referer); |
| 975 |
$.ajax( s ).done(function( data ){ |
| 976 |
var id = data - 0; |
| 977 |
for(var i=0; i<delivery_days.length; i++){ |
| 978 |
if(id === delivery_days[i]['id']){ |
| 979 |
index = i; |
| 980 |
} |
| 981 |
} |
| 982 |
delivery_days[index]['name'] = $("input[name='delivery_days_name']").val(); |
| 983 |
for( var j = 0; j < target_market.length; j++ ) { |
| 984 |
var tm = target_market[j]; |
| 985 |
for( var i = 0; i < pref[tm].length; i++ ) { |
| 986 |
var p = pref[tm][i]; |
| 987 |
delivery_days[index][tm][p] = $("input[name=\"delivery_days_value_"+tm+"\["+p+"\]\"]").val(); |
| 988 |
} |
| 989 |
} |
| 990 |
operation.disp_delivery_days(id); |
| 991 |
operation.make_delivery_method_days(get_delivery_method_days(selected_method)); |
| 992 |
$("#delivery_days_loading").html(''); |
| 993 |
}).fail(function( msg ){ |
| 994 |
$("#delivery_method_loading").html(''); |
| 995 |
}); |
| 996 |
return false; |
| 997 |
}, |
| 998 |
|
| 999 |
delete_delivery_days : function() { |
| 1000 |
var wc_nonce = $("#wc_nonce").val(); |
| 1001 |
var _wp_http_referer = $("input[name='_wp_http_referer']").val(); |
| 1002 |
|
| 1003 |
var delname = $("#delivery_days_name_select option:selected").html(); |
| 1004 |
if(!confirm(<?php _e( "'Okay to Delete Delivery Days Setting ' + delname + '?'", 'usces' ); ?>)) return false; |
| 1005 |
|
| 1006 |
$("#delivery_days_loading").html('<img src="<?php echo esc_url( USCES_PLUGIN_URL ); ?>/images/loading-publish.gif" />'); |
| 1007 |
var id = $("#delivery_days_name_select option:selected").val(); |
| 1008 |
var s = operation.settings; |
| 1009 |
s.data = "action=shop_options_ajax&mode=delete_delivery_days&id=" + id + "&wc_nonce=" + encodeURIComponent(wc_nonce)+ "&_wp_http_referer=" + encodeURIComponent(_wp_http_referer); |
| 1010 |
$.ajax( s ).done(function( data ){ |
| 1011 |
var id = data - 0; |
| 1012 |
delivery_days = delivery_days.filter(function(delivery_day) { |
| 1013 |
return delivery_day['id'] != id; |
| 1014 |
}); |
| 1015 |
operation.disp_delivery_days(0); |
| 1016 |
operation.make_delivery_method_days(get_delivery_method_days(selected_method)); |
| 1017 |
$("#delivery_days_loading").html(''); |
| 1018 |
}).fail(function( msg ){ |
| 1019 |
$("#delivery_method_loading").html(''); |
| 1020 |
}); |
| 1021 |
return false; |
| 1022 |
}, |
| 1023 |
|
| 1024 |
onchange_delivery_days : function(index) { |
| 1025 |
var id = $("#delivery_days_name_select option:eq("+index+")").val()-0; |
| 1026 |
operation.disp_delivery_days(id); |
| 1027 |
}, |
| 1028 |
|
| 1029 |
allDeliveryDays : function () { |
| 1030 |
var days = $("#all_delivery_days").val(); |
| 1031 |
if( days == '' ) return; |
| 1032 |
if( confirm(<?php _e( "'Okay to Change All Delivery Days to ' + days + '?'", 'usces' ); ?>) ){ |
| 1033 |
var country = $("#delivery_days_country option:selected").val(); |
| 1034 |
for( var i = 0; i < pref[country].length; i++ ) { |
| 1035 |
$("input[name=\"delivery_days_value_"+country+"\["+pref[country][i]+"\]\"]").val(days); |
| 1036 |
} |
| 1037 |
$("#all_delivery_days").val(""); |
| 1038 |
} |
| 1039 |
}, |
| 1040 |
|
| 1041 |
settings: { |
| 1042 |
url: uscesL10n.requestFile, |
| 1043 |
type: 'POST', |
| 1044 |
cache: false, |
| 1045 |
} |
| 1046 |
}; |
| 1047 |
|
| 1048 |
$("#shipping_charge_country").change(function () { |
| 1049 |
var country = $("#shipping_charge_country option:selected").val(); |
| 1050 |
for( var i = 0; i < target_market.length; i++ ) { |
| 1051 |
if( country == target_market[i] ) { |
| 1052 |
$("#shipping_charge_"+target_market[i]).css("display",""); |
| 1053 |
} else { |
| 1054 |
$("#shipping_charge_"+target_market[i]).css("display","none"); |
| 1055 |
} |
| 1056 |
} |
| 1057 |
}); |
| 1058 |
|
| 1059 |
$("#delivery_days_country").change(function () { |
| 1060 |
var country = $("#delivery_days_country option:selected").val(); |
| 1061 |
for( var i = 0; i < target_market.length; i++ ) { |
| 1062 |
if( country == target_market[i] ) { |
| 1063 |
$("#delivery_days_"+target_market[i]).css("display",""); |
| 1064 |
} else { |
| 1065 |
$("#delivery_days_"+target_market[i]).css("display","none"); |
| 1066 |
} |
| 1067 |
} |
| 1068 |
}); |
| 1069 |
}); |
| 1070 |
|
| 1071 |
jQuery(document).ready(function($){ |
| 1072 |
operation.disp_delivery_method(-1); |
| 1073 |
operation.disp_shipping_charge(-1); |
| 1074 |
operation.disp_delivery_days(-1); |
| 1075 |
|
| 1076 |
if( $.fn.jquery < "1.10" ) { |
| 1077 |
var $tabs = $('#uscestabs_delivery').tabs({ |
| 1078 |
cookie: { |
| 1079 |
// store cookie for a day, without, it would be a session cookie |
| 1080 |
expires: 1 |
| 1081 |
} |
| 1082 |
}); |
| 1083 |
} else { |
| 1084 |
$( "#uscestabs_delivery" ).tabs({ |
| 1085 |
active: ($.cookie("uscestabs_delivery")) ? $.cookie("uscestabs_delivery") : 0 |
| 1086 |
, activate: function( event, ui ){ |
| 1087 |
$.cookie("uscestabs_delivery", $(this).tabs("option", "active")); |
| 1088 |
} |
| 1089 |
}); |
| 1090 |
} |
| 1091 |
}); |
| 1092 |
</script> |
| 1093 |
<div class="wrap"> |
| 1094 |
<div class="usces_admin"> |
| 1095 |
<h1>Welcart Shop <?php esc_html_e( 'Shipping Setting', 'usces' ); ?></h1> |
| 1096 |
<?php usces_admin_action_status(); ?> |
| 1097 |
<p><?php esc_html_e( '* It is necessary to perform the delivery setting before than the item registration.', 'usces' ); ?><br /> |
| 1098 |
<?php esc_html_e( '* When you performed the addition and deletion of the delivery method after item registration, please be careful because the update of all items is necessary.', 'usces' ); ?></p> |
| 1099 |
<div id="poststuff" class="metabox-holder"> |
| 1100 |
|
| 1101 |
<div class="postbox"> |
| 1102 |
<h3><?php esc_html_e( 'Shipping Setting', 'usces' ); ?></h3> |
| 1103 |
<div class="inside"> |
| 1104 |
<form action="" method="post" name="option_form" id="option_form"> |
| 1105 |
<table class="form_table"> |
| 1106 |
<tr style="height:40px;"> |
| 1107 |
<th><a style="cursor:pointer;" onclick="toggleVisibility('ex_shipping_setting01');"><?php esc_html_e( 'Deadline for Delivery', 'usces' ); ?></a></th> |
| 1108 |
<td> |
| 1109 |
<select name="delivery_time_limit[hour]"> |
| 1110 |
<?php |
| 1111 |
for ( $i = 0; $i < 24; $i++ ) { |
| 1112 |
$hour = sprintf( '%02d', $i ); |
| 1113 |
?> |
| 1114 |
<option value="<?php echo esc_attr( $hour ); ?>"<?php selected( $delivery_time_limit['hour'], $hour ); ?>><?php echo esc_attr( $hour ); ?></option> |
| 1115 |
<?php |
| 1116 |
} |
| 1117 |
?> |
| 1118 |
</select> |
| 1119 |
</td> |
| 1120 |
<td>: </td> |
| 1121 |
<td> |
| 1122 |
<select name="delivery_time_limit[min]"> |
| 1123 |
<?php |
| 1124 |
$i = 0; |
| 1125 |
while ( $i < 60 ) { |
| 1126 |
$min = sprintf( '%02d', $i ); |
| 1127 |
?> |
| 1128 |
<option value="<?php echo esc_attr( $min ); ?>"<?php selected( $delivery_time_limit['min'], $min ); ?>><?php echo esc_attr( $min ); ?></option> |
| 1129 |
<?php |
| 1130 |
$i += 10; |
| 1131 |
} |
| 1132 |
?> |
| 1133 |
</select> |
| 1134 |
</td> |
| 1135 |
<td><div id="ex_shipping_setting01" class="explanation"><?php esc_html_e( 'Set deadline for merchandise delivery. This number is used to calculate the earliest delivery date.', 'usces' ); ?></div></td> |
| 1136 |
</tr> |
| 1137 |
<tr style="height:40px;"> |
| 1138 |
<th><a style="cursor:pointer;" onclick="toggleVisibility('ex_shipping_setting02');"><?php esc_html_e( 'Morning Delivery Option', 'usces' ); ?></a></th> |
| 1139 |
<td colspan="3"> |
| 1140 |
<select name="shortest_delivery_time"> |
| 1141 |
<option value="0"<?php selected( $shortest_delivery_time, '0' ); ?>><?php esc_html_e( 'Do Not Apply', 'usces' ); ?></option> |
| 1142 |
<option value="1"<?php selected( $shortest_delivery_time, '1' ); ?>><?php esc_html_e( 'Morning Delivery', 'usces' ); ?></option> |
| 1143 |
<option value="2"<?php selected( $shortest_delivery_time, '2' ); ?>><?php esc_html_e( 'No Morning Delivery', 'usces' ); ?></option> |
| 1144 |
</select> |
| 1145 |
</td> |
| 1146 |
<td><div id="ex_shipping_setting02" class="explanation"><?php esc_html_e( 'Set if the merchandise can be delivered on the morning of earliest possible delivery date.', 'usces' ); ?></div></td> |
| 1147 |
</tr> |
| 1148 |
<tr style="height:40px;"> |
| 1149 |
<th><a style="cursor:pointer;" onclick="toggleVisibility('ex_shipping_setting03');"><?php esc_html_e( 'Set Delivery Dates', 'usces' ); ?></a></th> |
| 1150 |
<td colspan="3"> |
| 1151 |
<input name="delivery_after_days" type="text" class="charge_text" value="<?php echo esc_attr( $delivery_after_days ); ?>"> |
| 1152 |
</td> |
| 1153 |
<td><div id="ex_shipping_setting03" class="explanation"><?php esc_html_e( 'Set the choices of possible delivery dates for the customer.', 'usces' ); ?></div></td> |
| 1154 |
</tr> |
| 1155 |
<?php do_action( 'usces_action_admin_shipping_setting' ); ?> |
| 1156 |
<tr> |
| 1157 |
<th></th> |
| 1158 |
<td colspan="3"> |
| 1159 |
<input name="usces_option_update" type="submit" class="button button-primary" value="<?php esc_attr_e( 'change decision', 'usces' ); ?>" /> |
| 1160 |
</td> |
| 1161 |
</tr> |
| 1162 |
</table> |
| 1163 |
<?php wp_nonce_field( 'admin_delivery', 'wc_nonce' ); ?> |
| 1164 |
</form> |
| 1165 |
</div> |
| 1166 |
</div><!--postbox--> |
| 1167 |
|
| 1168 |
<div class="postbox"> |
| 1169 |
<h3><span><?php esc_html_e( 'shipping option', 'usces' ); ?></span><a style="cursor:pointer;" onclick="toggleVisibility('ex_delivery_method');"> (<?php esc_html_e( 'explanation', 'usces' ); ?>) </a></h3> |
| 1170 |
<div class="inside"> |
| 1171 |
<table class="form_table" style="width:290px; margin-left:10px; float:left;"> |
| 1172 |
<tr style="height:20px;"> |
| 1173 |
<th class="sec"> </th> |
| 1174 |
<td><a href="javascript:void(0);" id="new_delivery_method_action"><?php esc_html_e( 'New addition', 'usces' ); ?></a></td> |
| 1175 |
</tr> |
| 1176 |
<tr style="height:40px;"> |
| 1177 |
<th><?php esc_html_e( 'Shipping name', 'usces' ); ?></th> |
| 1178 |
<td width="150" height="30" id="delivery_method_name"></td> |
| 1179 |
</tr> |
| 1180 |
<tr style="height:30px;"> |
| 1181 |
<th class="sec"> </th> |
| 1182 |
<td id="delivery_method_name2"></td> |
| 1183 |
</tr> |
| 1184 |
<tr style="height:30px;"> |
| 1185 |
<th class="sec" id="delivery_method_loading"> </th> |
| 1186 |
<td id="delivery_method_button"></td> |
| 1187 |
</tr> |
| 1188 |
<tr style="height:20px;"> |
| 1189 |
<th class="sec"></th> |
| 1190 |
<td><a href="#" id="moveup_action"><?php esc_html_e( 'Raise the priority', 'usces' ); ?></a></td> |
| 1191 |
</tr> |
| 1192 |
<tr style="height:20px;"> |
| 1193 |
<th class="sec"></th> |
| 1194 |
<td><a href="#" id="movedown_action"><?php esc_html_e( 'Lower the priority', 'usces' ); ?></a></td> |
| 1195 |
</tr> |
| 1196 |
</table> |
| 1197 |
|
| 1198 |
<table class="form_table"> |
| 1199 |
<tr style="height:20px;"> |
| 1200 |
<th class="sec"></th> |
| 1201 |
<td></td> |
| 1202 |
</tr> |
| 1203 |
<tr style="height:40px;"> |
| 1204 |
<th class="sec"><a style="cursor:pointer;" onclick="toggleVisibility('ex_shipping_setting10');"><?php esc_html_e( 'Possible Delivery Area', 'usces' ); ?></a></th> |
| 1205 |
<td><div id="delivery_method_intl"></div></td> |
| 1206 |
<td><div id="ex_shipping_setting10" class="explanation"><?php esc_html_e( 'Choose possible delivery area for this shipment method.', 'usces' ); ?></div></td> |
| 1207 |
</tr> |
| 1208 |
<tr style="height:40px;"> |
| 1209 |
<th class="sec"><a style="cursor:pointer;" onclick="toggleVisibility('ex_shipping_setting12');"><?php esc_html_e( 'Deliverly time', 'usces' ); ?></a></th> |
| 1210 |
<td><textarea name="delivery_method_time" id="delivery_method_time" style="height:100px;"></textarea></td> |
| 1211 |
<td><div id="ex_shipping_setting12" class="explanation"><?php _e( "Input possible delivery hours. Leave it blank when the customer cannot choose delivery time. <br />example)<br />morning<br />12:00-14:00<br />14:00-16:00<br />16:00-18:00", 'usces' ); ?></div></td> |
| 1212 |
</tr> |
| 1213 |
<tr style="height:40px;"> |
| 1214 |
<th class="sec"><a style="cursor:pointer;" onclick="toggleVisibility('ex_shipping_setting13');"><?php esc_html_e( 'Postage fixation', 'usces' ); ?></a></th> |
| 1215 |
<td id="delivery_method_charge_td"></td> |
| 1216 |
<td><div id="ex_shipping_setting13" class="explanation"><?php esc_html_e( "It is fixed for above rate setting when I choose postage fixation. The postage set by an article is applied in the case of 'non-fixation'.", 'usces' ); ?></div></td> |
| 1217 |
</tr> |
| 1218 |
<tr style="height:40px;"> |
| 1219 |
<th class="sec"><a style="cursor:pointer;" onclick="toggleVisibility('ex_shipping_setting15');"><?php esc_html_e( 'Delivery Days', 'usces' ); ?></a></th> |
| 1220 |
<td id="delivery_method_days_td"></td> |
| 1221 |
<td><div id="ex_shipping_setting15" class="explanation"><?php esc_html_e( "Choose the Name of 'Delivery Days' registered in Delivery Days setting below. To be used to calculate the fastest delivery date. If you're not letting the customer set the delivery date, set to 'Delivery Date Not Specified'.", 'usces' ); ?></div></td> |
| 1222 |
</tr> |
| 1223 |
<tr style="height:40px;"> |
| 1224 |
<th class="sec"><a style="cursor:pointer;" onclick="toggleVisibility('ex_shipping_setting16');"><?php esc_html_e( 'No COD', 'usces' ); ?></a></th> |
| 1225 |
<td><div id="delivery_method_nocod"></div></td> |
| 1226 |
<td><div id="ex_shipping_setting16" class="explanation"><?php esc_html_e( 'Check for no COD.', 'usces' ); ?></div></td> |
| 1227 |
</tr> |
| 1228 |
<tr style="height:40px;"> |
| 1229 |
<th class="sec"><a style="cursor:pointer;" onclick="toggleVisibility('ex_shipping_setting17');"><?php esc_html_e( 'Cool Category', 'usces' ); ?></a></th> |
| 1230 |
<td><div id="delivery_cool_category_td"></div></td> |
| 1231 |
<td><div id="ex_shipping_setting17" class="explanation"><?php esc_html_e( 'Add cool category option to shipping method.', 'usces' ); ?></div></td> |
| 1232 |
</tr> |
| 1233 |
</table> |
| 1234 |
|
| 1235 |
<hr size="1" color="#CCCCCC" /> |
| 1236 |
<div id="ex_delivery_method" class="explanation"><?php esc_html_e( 'Please make entry of appointment time to a party by one.', 'usces' ); ?></div> |
| 1237 |
</div> |
| 1238 |
</div><!--postbox--> |
| 1239 |
|
| 1240 |
<?php do_action( 'usces_action_admin_deliveryform' ); ?> |
| 1241 |
|
| 1242 |
<div class="uscestabs" id="uscestabs_delivery"> |
| 1243 |
<ul> |
| 1244 |
<li><a href="#delivery_page_setting_1"><?php esc_html_e( 'Shipping', 'usces' ); ?></a></li> |
| 1245 |
<li><a href="#delivery_page_setting_2"><?php esc_html_e( 'Delivery Days', 'usces' ); ?></a></li> |
| 1246 |
</ul> |
| 1247 |
|
| 1248 |
<div id="delivery_page_setting_1"> |
| 1249 |
|
| 1250 |
<div class="postbox"> |
| 1251 |
<h3><span><?php esc_html_e( 'Shipping', 'usces' ); ?></span><a style="cursor:pointer;" onclick="toggleVisibility('ex_shipping_charge');"> (<?php esc_html_e( 'explanation', 'usces' ); ?>) </a></h3> |
| 1252 |
<div class="inside"> |
| 1253 |
<table class="form_table" style="width:290px; margin-left:10px; float:left;"> |
| 1254 |
<tr style="height:20px;"> |
| 1255 |
<th class="sec"> </th> |
| 1256 |
<td><a href="javascript:void(0);" id="new_shipping_charge_action"><?php esc_html_e( 'New addition', 'usces' ); ?></a></td> |
| 1257 |
</tr> |
| 1258 |
<tr style="height:30px;"> |
| 1259 |
<th class="sec"><?php esc_html_e( 'Shipping charge name', 'usces' ); ?></th> |
| 1260 |
<td width="150" height="30" id="shipping_charge_name"></td> |
| 1261 |
</tr> |
| 1262 |
<tr style="height:30px;"> |
| 1263 |
<th class="sec"> </th> |
| 1264 |
<td width="150" height="30" id="shipping_charge_name2"></td> |
| 1265 |
</tr> |
| 1266 |
<tr style="height:30px;"> |
| 1267 |
<th class="sec" id="shipping_charge_loading"> </th> |
| 1268 |
<td id="shipping_charge_button"></td> |
| 1269 |
</tr> |
| 1270 |
</table> |
| 1271 |
<table class="form_table"> |
| 1272 |
<tr style="height:20px;"> |
| 1273 |
<th class="sec"></th> |
| 1274 |
<td></td> |
| 1275 |
</tr> |
| 1276 |
<tr style="height:40px;"> |
| 1277 |
<th class="sec"><a style="cursor:pointer;" onclick="toggleVisibility('ex_shipping_setting20');"><?php esc_html_e( 'Country', 'usces' ); ?></a></th> |
| 1278 |
<td><label class="shipping_charge_label"></label><select name="shipping_charge_country" id="shipping_charge_country"> |
| 1279 |
<?php usces_shipping_country_option( '' ); ?> |
| 1280 |
</select></td> |
| 1281 |
<td><div id="ex_shipping_setting20" class="explanation"><?php esc_html_e( 'Choose countries to apply this shipment fee.', 'usces' ); ?></div></td> |
| 1282 |
</tr> |
| 1283 |
<tr style="height:40px;"> |
| 1284 |
<th class="sec"><?php esc_html_e( 'Shipping', 'usces' ); ?></th> |
| 1285 |
<td><label class="shipping_charge_label"><input name="allbutton" type="button" class="allbutton button" onclick="operation.allCharge();" value="<?php esc_attr_e( 'same as', 'usces' ); ?>" /></label><input name="allcharge" id="allcharge" type="text" class="charge_text" /><?php usces_crcode(); ?></td> |
| 1286 |
</tr> |
| 1287 |
<tr> |
| 1288 |
<th class="sec"></th> |
| 1289 |
<td><div id="shipping_charge_value"></div></td> |
| 1290 |
</tr> |
| 1291 |
</table> |
| 1292 |
<hr size="1" color="#CCCCCC" /> |
| 1293 |
<div id="ex_shipping_charge" class="explanation"><?php esc_html_e( 'You can choose the shipping every item.', 'usces' ); ?></div> |
| 1294 |
</div> |
| 1295 |
</div><!--postbox--> |
| 1296 |
|
| 1297 |
</div><!--delivery_page_setting_1--> |
| 1298 |
<div id="delivery_page_setting_2"> |
| 1299 |
<div class="postbox"> |
| 1300 |
<h3><span><?php esc_html_e( 'Delivery Days', 'usces' ); ?></span><a style="cursor:pointer;" onclick="toggleVisibility('ex_delivery_days');"> (<?php esc_html_e( 'explanation', 'usces' ); ?>) </a></h3> |
| 1301 |
<div class="inside"> |
| 1302 |
<table class="form_table" style="width:280px; margin-left:10px; float:left;"> |
| 1303 |
<tr style="height:20px;"> |
| 1304 |
<th class="sec"> </th> |
| 1305 |
<td><a href="javascript:void(0);" id="new_delivery_days_action"><?php esc_html_e( 'New addition', 'usces' ); ?></a></td> |
| 1306 |
</tr> |
| 1307 |
<tr style="height:30px;"> |
| 1308 |
<th class="sec"><?php esc_html_e( "Name of 'Delivery Days'", 'usces' ); ?></th> |
| 1309 |
<td width="150" height="30" id="delivery_days_name"></td> |
| 1310 |
</tr> |
| 1311 |
<tr style="height:30px;"> |
| 1312 |
<th class="sec"> </th> |
| 1313 |
<td width="150" height="30" id="delivery_days_name2"></td> |
| 1314 |
</tr> |
| 1315 |
<tr style="height:30px;"> |
| 1316 |
<th class="sec" id="delivery_days_loading"> </th> |
| 1317 |
<td id="delivery_days_button"></td> |
| 1318 |
</tr> |
| 1319 |
</table> |
| 1320 |
<table class="form_table"> |
| 1321 |
<tr style="height:20px;"> |
| 1322 |
<th class="sec"></th> |
| 1323 |
<td></td> |
| 1324 |
</tr> |
| 1325 |
<tr style="height:40px;"> |
| 1326 |
<th class="sec"><a style="cursor:pointer;" onclick="toggleVisibility('ex_delivery_days_setting20');"><?php esc_html_e( 'Country', 'usces' ); ?></a></th> |
| 1327 |
<td><label class="shipping_charge_label"></label><select name="delivery_days_country" id="delivery_days_country"> |
| 1328 |
<?php usces_shipping_country_option( '' ); ?> |
| 1329 |
</select></td> |
| 1330 |
<td><div id="ex_delivery_days_setting20" class="explanation"><?php esc_html_e( 'Choose countries to apply this Delivery Days.', 'usces' ); ?></div></td> |
| 1331 |
</tr> |
| 1332 |
<tr style="height:40px;"> |
| 1333 |
<th class="sec"><?php esc_html_e( 'Delivery Days', 'usces' ); ?></th> |
| 1334 |
<td><label class="delivery_days_label"><input name="allbutton_delivery_days" type="button" class="allbutton button" onclick="operation.allDeliveryDays();" value="<?php esc_attr_e( 'same as', 'usces' ); ?>" /></label><input name="all_delivery_days" id="all_delivery_days" type="text" class="days_text" /><?php esc_html_e( 'day', 'usces' ); ?></td> |
| 1335 |
</tr> |
| 1336 |
<tr> |
| 1337 |
<th class="sec"></th> |
| 1338 |
<td><div id="delivery_days_value"></div></td> |
| 1339 |
</tr> |
| 1340 |
</table> |
| 1341 |
<hr size="1" color="#CCCCCC" /> |
| 1342 |
<div id="ex_delivery_days" class="explanation"><?php esc_html_e( 'You can choose Delivery Days for each merchandise.', 'usces' ); ?></div> |
| 1343 |
</div> |
| 1344 |
</div><!--postbox--> |
| 1345 |
</div><!--delivery_page_setting_2--> |
| 1346 |
|
| 1347 |
</div><!--tabs--> |
| 1348 |
|
| 1349 |
</div><!--poststuff--> |
| 1350 |
|
| 1351 |
</div><!--usces_admin--> |
| 1352 |
</div><!--wrap--> |
| 1353 |
|