<?php
add_action('wp_ajax_bluemail_save_keys', 'bluemail_save_keys', 1);
add_action('wp_ajax_nopriv_bluemail_save_keys', 'bluemail_save_keys', 1);
add_action('woocommerce_checkout_update_order_meta', 'order_sucursal_main_update_order_meta_bluemail', 10);
add_action('add_meta_boxes', 'woocommerce_bluemail_box_add_box');
add_action('wp_ajax_bluemail_get_etiqueta', 'bluemail_get_etiqueta', 1);
add_action('wp_ajax_nopriv_bluemail_get_etiqueta', 'bluemail_get_etiqueta', 1);
add_action('wp_ajax_bluemail_imponer', 'bluemail_imponer', 1);
add_action('wp_ajax_nopriv_bluemail_imponer', 'bluemail_imponer', 1);
add_action('wp_ajax_bluemail_get_rate', 'bluemail_get_rate', 1);
add_action('wp_ajax_nopriv_bluemail_get_rate', 'bluemail_get_rate', 1);
add_action('woocommerce_api_bluemailreturn', 'callback_handler_bluemail' );
add_action('wp_ajax_bluemail_get_map', 'bluemail_get_map', 1);
add_action('wp_ajax_nopriv_bluemail_get_map', 'bluemail_get_map', 1);
add_action('wp_ajax_check_sucursales', 'check_bluemail_sucursales', 1);
add_action('wp_ajax_nopriv_check_sucursales', 'check_bluemail_sucursales', 1);
function check_bluemail_sucursales() {
global $wp_session;
if (isset($_POST['post_code'])) {
$delivery_zones = WC_Shipping_Zones::get_zones();
foreach($delivery_zones as $zones){
foreach($zones['shipping_methods'] as $methods){
if($methods->id =='bluemail_wanderlust'){
if($methods->enabled == 'yes'){
$api_key = $methods->instance_settings['api_key'];
$secret_key = $methods->instance_settings['secret_key'];
$client_key = $methods->instance_settings['client_key'];
$store_key = $methods->instance_settings['store_key'];
}
}
}
}
$params = array(
"method" => array(
"get_puntos" => array(
'apikey' => $api_key,
'token' => $secret_key,
'customerId' => $client_key,
'destZip' => $_POST['post_code'],
)
)
);
$ch = curl_init();
curl_setopt_array($ch,
array(
CURLOPT_TIMEOUT => 30,
CURLOPT_POST => TRUE,
CURLOPT_POSTFIELDS => http_build_query($params),
CURLOPT_URL => 'https://wanderlust.codes/bluemail/index.php',
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_FOLLOWLbluemailTION => TRUE
)
);
$bluemail_response = curl_exec ($ch);
$bluemail_response = json_decode($bluemail_response);
echo '<select id="pv_centro_bluemail_estandar" name="pv_centro_bluemail_estandar">';
$listado_bluemail = array();
foreach($bluemail_response as $sucursales){
$idCentroImposicion = $sucursales->id;
$sucursales_finales = $sucursales->name;
$listado_bluemail[] = $sucursales->sucursales;
echo '<option value="'. $idCentroImposicion.'">'. $sucursales_finales . ' - ' . $sucursales->town . ' - ' . $sucursales->departmentName . ' - CP ' . $sucursales->zip . '</option>';
}
echo '</select>';
$wp_session['listado_bluemail'] = $listado_bluemail;
die();
}
}
add_action( 'wp_footer', 'only_numbers_bluemails');
function only_numbers_bluemails(){
if ( is_checkout() ) { ?>
<script type="text/javascript">
jQuery(document).ready(function () {
jQuery('#order_sucursal_main').insertAfter( jQuery( '.woocommerce-checkout-review-order-table' ) );
jQuery('#calc_shipping_postcode').attr({ maxLength : 4 });
jQuery('#billing_postcode').attr({ maxLength : 4 });
jQuery('#shipping_postcode').attr({ maxLength : 4 });
jQuery("#calc_shipping_postcode").keypress(function (e) {
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
return false;
}
});
jQuery("#billing_postcode").keypress(function (e) {
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
return false;
}
});
jQuery("#shipping_postcode").keypress(function (e) {
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
return false;
}
});
jQuery('#billing_address_1').keypress(function(e) {
var tval = jQuery('#billing_address_1').val(),
tlength = tval.length,
set = 30,
remain = parseInt(set - tlength);
if (remain <= 0 && e.which !== 0 && e.charCode !== 0) {
jQuery('#billing_address_1').val((tval).substring(0, tlength - 1));
return false;
}
});
jQuery('#billing_address_1').focusout(function (e) {
var tval = jQuery('#billing_address_1').val(),
tlength = tval.length,
set = 30,
remain = parseInt(set - tlength);
if(remain <= 0){
jQuery('#billing_address_1').val('');
alert('El campo no puede ser mayor a 30 caracteres.');
}
if (remain <= 0 && e.which !== 0 && e.charCode !== 0) {
jQuery('#billing_address_1').val((tval).substring(0, tlength - 1));
return false;
}
});
jQuery('#billing_postcode').focusout(function () {
if (jQuery('#ship-to-different-address-checkbox').is(':checked')) {
var state = jQuery('#shipping_state').val();
var post_code = jQuery('#shipping_postcode').val();
} else {
var state = jQuery('#billing_postcode').val();
var post_code = jQuery('#billing_postcode').val();
}
var selectedMethod = jQuery('input:checked', '#shipping_method').attr('id');
var selectedMethodb = jQuery( "#order_review .shipping .shipping_method option:selected" ).val();
if (selectedMethod == null) {
if(selectedMethodb != null){
selectedMethod = selectedMethodb;
} else {
return false;
}
}
var order_sucursal = 'ok';
if (selectedMethod.indexOf("-pick") >= 0 ) {
console.log(selectedMethod);
jQuery("#order_sucursal_main_result").fadeOut(100);
jQuery("#order_sucursal_main_result_cargando").fadeIn(100);
jQuery.ajax({
type: 'POST',
cache: false,
url: wc_checkout_params.ajax_url,
data: {
action: 'check_sucursales',
post_code: post_code,
order_sucursal: order_sucursal,
},
success: function(data, textStatus, XMLHttpRequest){
jQuery("#order_sucursal_main_result").fadeIn(100);
jQuery("#order_sucursal_main_result_cargando").fadeOut(100);
jQuery("#order_sucursal_main_result").html('');
jQuery("#order_sucursal_main_result").append(data);
var selectList = jQuery('#pv_centro_bluemail_estandar option');
var arr = selectList.map(function(_, o) { return { t: jQuery(o).text(), v: o.value }; }).get();
arr.sort(function(o1, o2) { return o1.t > o2.t ? 1 : o1.t < o2.t ? -1 : 0; });
selectList.each(function(i, o) {
o.value = arr[i].v;
jQuery(o).text(arr[i].t);
});
jQuery('#pv_centro_bluemail_estandar')
没有合适的资源?快使用搜索试试~ 我知道了~
【WordPress插件】2022年最新版完整功能demo+插件v0.1.zip
共9个文件
php:6个
png:2个
css:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 97 浏览量
2022-04-18
17:39:29
上传
评论
收藏 28KB ZIP 举报
温馨提示
"【WordPress插件】2022年最新版完整功能demo+插件v0.1 Wanderlust WooCommerce Bluemail Wanderlust Woocommerce Bluemail." ---------- 泰森云每天更新发布最新WordPress主题、HTML主题、WordPress插件、shopify主题、opencart主题、PHP项目源码、安卓项目源码、ios项目源码,更有超10000个资源可供选择,如有需要请站内联系。
资源推荐
资源详情
资源评论
收起资源包目录
【WordPress插件】2022年最新版完整功能demo+插件v0.1.zip (9个子文件)
wanderlust-bluemail
wanderlust-bluemail.php 2KB
includes
functions.php 25KB
img
bluemail-logo-png.png 5KB
data
data-settings.php 3KB
services.php 9KB
assets
css
admin.css 469B
img
bluemail-logo-png.png 5KB
class-wc-shipping-bluemail.php 9KB
shipment-tracking.php 13KB
共 9 条
- 1
资源评论
Lee达森
- 粉丝: 968
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功