我有一个使用WooCommerce和租订制度插件的出租网站。
我想不包括小时价格在这个网站。因此,我尝试谷歌,并检查没有选择禁用每小时价格的租赁产品。
我已经检查了插件代码,如果我能做什么的话,并看到了以下内容:
if(isset($rental_data['rental_days_and_costs'])){
if($rental_data['rental_days_and_costs']['days'] > 0){
$custom_data[] = array(
'name' => 'Total Days',
'value' => $rental_data['rental_days_and_costs']['days'],
'display' => ''
);
} else {
$custom_data[] = array(
'name' => 'Total Hours',
'value' => $rental_data['rental_days_and_costs']['hours'],
'display' => ''
;
}
}在预订和租赁系统插件的includes\class-redq-product-cart.php.源代码
我想知道以前是否有人做过这件事,或者任何定制都是可能的。我试过了,但似乎没有什么效果,我的意思是,它没有禁用该功能。
我的场景:
在网站中,当客户选择日期时,比如从2017年11月20日到2017年11月20日,如果预订或租用日最少为1天(),则按给定插件(在仪表板中准确地)计算每小时价格。但是,当日期范围是这样的,从2017年11月20日到2017年11月22日,一般的价格都很好。所以我只想给出按日期计算的租金。
发布于 2017-11-21 20:26:04
最后,我能够解决这个问题,这花了一段时间,因为我以前习惯于使用'PHP‘。下面是我用来禁用小时价格功能的步骤:
首先,让我写一下,我几乎不可能从WordPress仪表板中禁用这个特性。如果有人可以的话,告诉我。因此,我开始定制插件代码,下面是插件- WooCommerce租赁和预订插件的链接。
首先打开class-redq-product-cart.php文件,该文件位于wp内容文件夹中,下面是文件路径- wp-content\plugins\booking-and-rental-system-woocommerce\includes.我在第98行(我使用Dev )的函数redq_rental_get_item_data()中修改了一些代码,如下所示:
if(isset($rental_data['rental_days_and_costs'])){
if($rental_data['rental_days_and_costs']['days'] > 0) {
$custom_data[] = array(
'name' => 'Total Days',
'value' => $rental_data['rental_days_and_costs']['days'],
'display' => ''
);
} else {
$custom_data[] = array( //Initially you'll have hourly rent details here - Just replace with this for per day rental
'name' => 'Total Days',
'value' => 1,
'display' => ''
);
}在同一文件中,在第175号行中有另一个名为redq_rental_order_item_meta()的方法,请小心,在本节中,计算天数和小时数。为了强制不计算每小时的价格,我将前面的代码替换为以下代码:
if($hours < 24) {
$days = 1; //Initially this would be $days = 0 and replace it
$total_hours = ceil($days);
} 以上工作是针对后端部分使用PHP完成的,现在使用jQuery进行前端操作。在前端,您必须立即反映每日租金的价格,例如:

为此,您必须打开一个名为cost-handle.js的文件,文件路径是wp-content\plugins\booking-and-rental-system-woocommerce\assets\js.。只需在第55行替换以下代码,并记住这是一个wp-content\plugins\booking-and-rental-system-woocommerce\redq-rental-and-bookings.php):文件(如果希望在PHP文件中看到定义的文件名,请参见第234 - JavaScript行)。
if(hours < 24) {
days = 1; //make the day 1 and initailly it's defined 0
total_hours = Math.ceil(hours);
$('.additional_person_info').trigger("chosen:updated");
$('.show_person_cost_if_day').hide();
$('.show_person_cost_if_time').show();
//$('.show_if_day').children('.amount').css({'visibility': 'hidden'});
$('.show_if_day').children('span').hide();
$('.show_if_time').show();
$('.rnb_single_add_to_cart_button').removeAttr('disabled','disabled');
}我希望,这将有助于其他人解决问题,并尽我最大的努力来解决和理解。
的场景,它的工作-我是再次写,这是可行的,当你有任何出租在同一日期范围内。假设从2017年11月22日到2017年11月22日。这是好的,如果是每小时的价格和相同的日期写。默认情况下,在仪表板中,对于这个日期范围,WooCommerce计算每小时的价格,要强制禁用它,您必须通过代码隐藏。
https://stackoverflow.com/questions/47411881
复制相似问题