problem with setting dates | WordPress.org

[ad_1]

Hello @monika999,

In this case, you must walk the days from checking to checkout and summing the corresponding amounts.

For example, assuming you have two date fields for the checking and checkout. I’ll call the fieldname1 and fieldname2, and you want to sum their corresponding prices, including the first and last days.

You can insert a calculate field in the form and enter the equation:

(function(){
var prices_list = {
1:80,
2:60,
3:70,
4:50,
5:50,
6:60,
7:40
},
d1 = DATEOBJ(MIN(fieldname1,fieldname2)), 
d2 = DATEOBJ(MAX(fieldname1,fieldname2)), 
result = 0;

while(d1<=d2){
result += prices_list(WEEKDAY(d1));
d1.setDate(d1.getDate()+1);
}

return PREC(result,2);
})()

And that’s all.

Best regards.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer