Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

hiding a shipping option based on user

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #11  
Old 03-04-2015, 01:57 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,078
 

Default Re: hiding a shipping option based on user

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}
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote

The following 3 users thank cflsystems for this useful post:
cherie (03-09-2015), kevfromwiganinlancashire (03-21-2015), totaltec (03-04-2015)
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 04:31 PM.

   

 
X-Cart forums © 2001-2020