in the smarty php file - shipping array, membershipid and shippingid are parameters. So it can go like this
PHP Code:
global $login, $smarty;
// get userid by login - there is a function for this already in func.user.php
// get user_membershipid by either login or userid from above by quering the customers info table(s)
// you can skip this is you pass $userinfo as parameter in the template but this is not available on all pages
// so better to just get it here
foreach ($shipping as $k => $v) {
if (
$v['shippingid'] == $shippingid
&& $user_membershipid == $membershipid
) {
unset($shipping[$k]);
break;
);
}
// you need to check what is used as keys the $shipping array before running this as it will renumber them; if keys are the actual shippingids then don't run it
$shipping = array_values($shipping);
if ('assign parameter is passed use below line to reassign the $shipping array') {
$smarty->asiign('shipping', $shipping);
$shipping = '';
}
return $shipping;
You can also pass to this function multiple shipping ids and redo the foreach to match any; it can also be used for payment methods.
As for the shipping being used in multiple templates - not a problem - use the function call in home.tpl just after the <body> tag to reassign $shipping - that way there is no need to track down all templates this is being used in
{if $shipping}
function call here
{/if}