You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.
Pages: 1
Hello,
We are using a custom shipping script for USPS and UPS and would like to figure out what is needed for return shipping cost results that reside in certain states that we can program a shipping discount by percentage to help the customer out on far away extensive shipping costs. we figured this might be easiest determined by state rather than zip code if this is possible. Please advise...
<?php $info = $this->globals('ecom.customship'); $custom = array(); $usps_weight_cutoff = 51; $shipmethod = 'USPS, UPSTOOLS'; if ($info['weight'] >= $usps_weight_cutoff) {$shipmethod = 'UPSTOOLS';} // // Static Ship Price Lookup // $DB =& $this->quick_object('CORE_DB','core','CORE_DB_1'); if (!(empty($info['delitems']))) { $sql = 'SELECT id, shiponename, shiponeprice, shiptwoname, shiptwoprice, shipthreename, shipthreeprice FROM ecom_prod WHERE '; foreach ($info['delitems'] as $diid => $diquan) {$sql .= 'id=' . $DB->quote($diid) . ' OR ';} $sql = preg_replace('/ OR $/','',$sql); $res = $DB->sql_do(array('table' => 'ecom_prod', 'sql' => $sql, 'order' => array('id' => 'ASC'))); if ((!($this->isError($res))) && (!(empty($res)))) { foreach ($res as $num => $data) { // ShipOnePrice if ((!(empty($data['shiponename']))) && ($data['shiponeprice'] > 0) && (!(empty($info['delitems'][$data['id']])))) { if (!(isset($custom[$data['shiponename']]))) {$custom[$data['shiponename']] = 0;} $custom[$data['shiponename']] += ($data['shiponeprice'] * $info['delitems'][$data['id']]); } // End of if statement. // ShipTwoPrice if ((!(empty($data['shiptwoname']))) && ($data['shiptwoprice'] > 0) && (!(empty($info['delitems'][$data['id']])))) { if (!(isset($custom[$data['shiptwoname']]))) {$custom[$data['shiptwoname']] = 0;} $custom[$data['shiptwoname']] += ($data['shiptwoprice'] * $info['delitems'][$data['id']]); } // End of if statement. // ShipThreePrice if ((!(empty($data['shipthreename']))) && ($data['shipthreeprice'] > 0) && (!(empty($info['delitems'][$data['id']])))) { if (!(isset($custom[$data['shipthreename']]))) {$custom[$data['shipthreename']] = 0;} $custom[$data['shipthreename']] += ($data['shipthreeprice'] * $info['delitems'][$data['id']]); } // End of if statement. } // End of foreach statement. } // End of fif statement. } // End of if statement. // // Realtime Rates // $delinfo = array('stateprov' => $info['stateprov'], 'country' => $info['country'], 'postalcode' => $info['postalcode'], 'rescom' => $info['rescom'], 'shipstateprov' => $info['shipstateprov'], 'shipcountry' => $info['shipcountry'], 'shipzip' => $info['shipzip'], 'shipmethods' => $shipmethod, 'shiptype' => 'R'); $result = $this->include_namespace('ecom','shiprealtime',array('delinfo' => $delinfo, 'packages' => $info['packages'])); foreach ($result as $num => $service) { if (preg_match('/UPS/',$service['name'])) { $custom[$service['name']] = $service['amount'] + ($service['amount'] * 0.00); } else { $custom[$service['name']] = $service['amount'] + ($service['amount'] * 0.00); } // End of if statement. } // End of if statement. $this->globals('ecom.customship_response',$custom); ?>
Offline
Sure, you can do that. Looks like you're doing a product table lookup and adding all the positive shipone/shiptwo/shipthree methods as well as doing a realtime call to either UPS and USPS or UPS only.
Offline
Pages: 1