我目前的项目需要定制地显示一些额外的信息的基础上,已选定的日期计算。我已经编写了一个函数,但是我找不到预订系统根据有效日期返回数据和计算以触发函数的AJAX代码。我的函数很简单:
function calculate_date_duration() {
var year_1 = document.querySelector('.selection-start-date').getAttribute('data-year');
var month_1 = document.querySelector('.selection-start-date').getAttribute('data-month');
var date_1 = document.querySelector('.selection-start-date a').textContent;
var year_2 = document.querySelector('.selection-end-date').getAttribute('data-year');
var month_2 = document.querySelector('.selection-end-date').getAttribute('data-month');
var date_2 = document.querySelector('.selection-end-date a').textContent;
var day_1 = new Date(year_1, month_1, date_1);
var day_2 = new Date(year_2, month_2, date_2);
console.log(day_1);
console.log(day_2);
var day_selected = day_2.getTime() - day_1.getTime();
var date_duration = parseInt(day_selected / (1000 * 60 * 60 * 24)) +1;
console.log(date_duration);
var display_pane = document.querySelector('.wc-bookings-booking-cost');
display_pane.innerHTML = display_pane.innerHTML + '<br>Total booking cost:<strong><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>' + (date_duration*120) + '</bdi></span></strong>';}发布于 2021-04-15 12:36:32
日期选择持续时间ajax在wp-content/plugins/woocommerce-bookings/dist/frontend.js,搜索成功,此文件中的最后一个是验证所选持续时间后的代码。
https://stackoverflow.com/questions/67094629
复制相似问题