Php 使用预订和租赁系统插件禁用WooCommerce中的小时价格

Php 使用预订和租赁系统插件禁用WooCommerce中的小时价格,php,wordpress,woocommerce,product,price,Php,Wordpress,Woocommerce,Product,Price,我有一个使用WooCommerce和插件的租赁网站 我想不包括在这个网站每小时的价格。所以我试着在谷歌上搜索,并检查是否没有禁用租赁产品每小时价格的选项 我已经检查了插件代码,如果我能做什么,我看到了以下内容: if(isset($rental_data['rental_days_and_costs'])){ if($rental_data['rental_days_and_costs']['days'] > 0){ $custom_data[] = array(

我有一个使用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' => ''
        ;
    }
}
在预订和租赁系统插件源代码中,
包含\class redq product cart.php

我想知道是否有人曾经处理过这个问题,或者是否可以进行任何定制。我试过了,但似乎没有任何效果,我的意思是它没有禁用该功能

我的场景

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月20日到2017年11月20日,则按插件中给出的小时价格计算(准确地说是在仪表板中)如果预订或租赁天数至少为1天,则小时价格将适用。但如果日期范围为2017年11月20日至2017年11月22日,则适用于一般价格。所以我只想启用日期相关的租赁价格

最后我终于解决了这个问题,因为我以前习惯于使用“PHP”,所以花了一段时间。下面是我用来禁用小时价格功能的步骤:

首先,让我来写一下,我几乎不可能从
WordPress
仪表板禁用该功能。如果有人可以,请告诉我。所以我开始定制插件代码,这里是插件的链接-

首先打开wp content文件夹中的class redq product cart.php文件,下面是文件路径-wp content\plugins\booking and rental system woocommerce\includes。我在第98行的函数redq\u rental\u get\u item\u data()中更改了一些代码(我使用Dev PHP),如下所示:

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' => ''
        );
    }
if($hours < 24) {
    $days = 1; //Initially this would be $days = 0 and replace it
    $total_hours = ceil($days);
} 
在同一个文件中,第175行有另一个名为redq\u rental\u order\u item\u meta()的方法,请注意,在本节中,计算天数和小时数。为了强制不计算每小时的价格,我将前面的代码替换为以下代码:

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' => ''
        );
    }
if($hours < 24) {
    $days = 1; //Initially this would be $days = 0 and replace it
    $total_hours = ceil($days);
} 
我希望,这将有助于其他人解决这个问题,并尽我所能去解决和理解


它起作用的场景-我再写一次,当您在同一日期范围内有任何东西需要出租时,这种方法就起作用了。假设从2017年11月22日到2017年11月22日。这是罚款,如果它是为每小时的价格和同一日期写。默认情况下,在仪表板中,对于此日期范围,
WooCommerce
计算小时价格,若要强制禁用此功能,必须执行代码隐藏

我的客户要求不要在网站中包含每小时的价格
,所以我只想启用按日期计算的租赁价格。
看起来你问了两个不同的问题,而不是@Masivuye Cokile。对不起,有什么误会。我只想启用日期智能租赁。如果日期在2017年11月20日至2017年11月20日之间,那么它应该包括一天的租金,而不是每小时租金。我已经在LoicTheAztec成功了。花了一段时间,浏览了大量的
PHP
文件。谢谢。@AT-2017你应该在问题的末尾添加一个编辑,告诉人们你是如何解决的……谢谢这在某种程度上非常有用……但是覆盖插件核心文件不是一个好办法。无论如何,康格斯!谢谢@LoicTheAztec的建议,是的,即使我真的很害怕,如果我错过了任何一行。绝对不推荐。