Note: Before you get started you should create a backup of "global.php"!
The following modification allows you limit products to the real-time shipping option of your chouice. This mod will only work if there is only one item in the cart and that item ID is found in a text file that will reside in your /admin/backup folder. It will only allow you to define one shipping option. It has only been tested in version 4.2.3 of SunShop but should work in most of the more recent releases.
1. Open a new file in Notepad (Or any text editor you like) and save it as "ship_exceptions.txt".
a) Add the shipping exceptions to the file in the following format ([PRODUCT_ID]=[[SHIPPER]] [SHIPPING_OPTION]):
98=[USPS] Priority Mail 99=[USPS] Priority Mail
IT MUST BE IN THIS EXACT FORMAT
b) Save & upload "ship_exceptions.txt" to the "/admin/backup" folder in SunShop via FTP.
2. Download "global.php" to your desktop and open using any text editor.
3. Replace the following lines of code (This will be in the get_shipping() function near line 1222 or so in version 4.2.3 of SunShop)....
foreach ($shipping[options] as $k => $v) { $mod = substr($k, 0, 7); if ($mod != '[LOCAL]') { $add = $cart->realtime_override(); $local_only = 0; } else { $add = 0; } $shipping[values] .= template('misc_option_select.html', array('option' => array('value' => $k.'-> '.p($v+$add, false), 'name' => '('.p($v+$add).') - '.$k))); }
With....
//// Modification //// $checkit['count'] = 0; $filedata = file_get_contents(ADMIN_DIR.'/backup/ship_exceptions.txt'); $xarray = explode("\n",urldecode(addslashes(strip_tags(trim($filedata))))); foreach($xarray as $k => $v) { $item = split("=", $v); $exceptions[$item[0]]['method'] = $item[1]; } foreach ($cart->items as $ii => $vv) { $checkprods[$cart->items[$ii]->id] = $cart->items[$ii]->id; if(isset($exceptions[$cart->items[$ii]->id])) { $found = 1; $checkit['method'] = $exceptions[$cart->items[$ii]->id]['method']; } $checkit['count'] = $checkit['count']+$cart->items[$ii]->quantity; } foreach ($shipping[options] as $k => $v) { $mod = substr($k, 0, 7); if ($mod != '[LOCAL]') { $add = $cart->realtime_override(); $local_only = 0; } else { $add = 0; } if($found != 1)$shipping[values] .= template('misc_option_select.html', array('option' => array('value' => $k.'-> '.p($v+$add, false), 'name' => '('.p($v+$add).') - '.$k))); else { if($checkit['count'] > 1) $shipping[values] .= template('misc_option_select.html', array('option' => array('value' => $k.'-> '.p($v+$add, false), 'name' => '('.p($v+$add).') - '.$k))); else $shipping[values] .= ($k == $checkit['method']) ? template('misc_option_select.html', array('option' => array('value' => $k.'-> '.p($v+$add, false), 'name' => '('.p($v+$add).') - '.$k))) : ''; } } //// End Modification ////
4. Save the file and reupload to your site.
That's it! If you followed the steps correctly, it should only be displaying the option you defined for your products.
This modification can be edited to fit your needs. There is no support available for this modification.