删除复选框php


Remove checkbox php

我真的是PHP的新手,我现在正在做一个小网店(本地)来尝试我的技能。

我有一些代码,如果你是丹麦公民,那里有一个复选框,但我希望删除复选框,然后运行通常只有在无论如何都被选中的情况下才会运行的代码。

你们能给我一个提示或指示吗?

function my_pmpro_tax($tax, $values, $order) {      
    $tax = round((float)$values[price]*0.8 * 0.25, 2);      
    return $tax;  
}
function my_pmpro_level_cost_text($cost, $level)
{
    //only applicable for levels > 1
    $cost .= "Inkl. moms";
    return $cost;
}
add_filter("pmpro_level_cost_text", "my_pmpro_level_cost_text", 10, 2);
//add Danish checkbox to the checkout page
function my_pmpro_checkout_boxes()
{
?>
<table id="pmpro_pricing_fields" class="pmpro_checkout" width="100%" cellpadding="0" cellspacing="0" border="0">
<thead>
    <tr>
        <th>
            Do you live in Denmark?
        </th>                       
    </tr>
</thead>
<tbody>                
    <tr>    
        <td>
            <div>               
                <input id="danish" name="danish" type="checkbox" value="1" <?php if(!empty($_REQUEST['danish']) || !empty($_SESSION['danish'])) {?>checked="checked"<?php } ?> /> Check this box if your billing address is in Denmark.
            </div>              
        </td>
    </tr>
</tbody>
</table>
<?php
}
add_action("pmpro_checkout_boxes", "my_pmpro_checkout_boxes");
//update tax calculation if buyer is danish
function my_danish_tax_check()
{
    //check request and session
    if(isset($_REQUEST['danish']))
    {
        //update the session var
        $_SESSION['danish'] = $_REQUEST['danish'];  
        //not empty? setup the tax function
        if(!empty($_REQUEST['danish']))
            add_filter("pmpro_tax", "my_pmpro_tax", 10, 3);
    }
    elseif(!empty($_SESSION['danish']))
    {
        //add the filter
        add_filter("pmpro_tax", "my_pmpro_tax", 10, 3);
    }
}
add_action("init", "my_danish_tax_check");
//remove the danish session var on checkout
function my_pmpro_after_checkout()
{
    if(isset($_SESSION['danish']))
        unset($_SESSION['danish']);
}
add_action("pmpro_after_checkout", "my_pmpro_after_checkout");

修改function my_danish_tax_check(),使其看起来像这样:

function my_danish_tax_check()
{
        //update the session var
        $_SESSION['danish'] = 1;  
        add_filter("pmpro_tax", "my_pmpro_tax", 10, 3);
}

首先,这看起来很奇怪:

<?php if(!empty($_REQUEST['danish']) || !empty($_SESSION['danish'])) {?>checked="checked"<?php } ?>

更准确地说:

<?php if(!empty($_REQUEST['danish']) || !empty($_SESSION['danish'])) { echo "checked="checked"" } ?>

对于您的问题,我们现在需要在该页面之后的目标页面的服务器端代码。你应该和我们分享这些信息。

如果你正在谈论传递这个页面,只需重定向:

function Redirect()
{
    window.location="http://www.newlocation.com";
}

只需删除if(非丹麦公民)部分的代码!