On the checkout form, add a Cosh On Delivery Check box and set the checked value to 1:
<input type="checkbox" name="cashoncollect" id="cashoncollect" value="1"/>
On the confirm page, create a hidden form element with the same name, and set the value to be captured from the one on the checkout page:
<input type="hidden" name="cashoncollect" id="cashoncollect" value="<?php echo((isset($_POST["cashoncollect"]))?$_POST["cashoncollect"]:"") ?>"/>
Around the paypal local checkout code, add the following if statement:
<?php if(isset($_POST["cashoncollect"]) && $_POST["cashoncollect"] == "1") { ?>
<local checkout code>
<?php
} else {
$<eCart Object Name>->redirStr = "checkout_success.php";
}
?>
where <eCart Object Name> is the name of the eCart object.