Hello.
Quick background as I dont wish to hog anyones time. I am a customer of a
PHP/SQL programmer. A website that I had the programmer build for me is
working great, with one exception.
I have limited programming experience, most of it Pascal/C++ and I haven't
programmed for many years now even then it was mediocre programming of small
this and thats.
Here is the code:
-----------------------------------------------------------------------
function check_deliver_p rice($product_i d, $product_quanti ty, $price_level,
$delivery_city_ address, $delivery_state _address, $delivery_zip,
$values_price_i nc)
{
global $db_prefix, $ups_dropOffCho ice, $ups_container, $ups_billToUPS,
$ups_currency, $ups_document, $ups_22_destCou ntry, $ups_origCity,
$ups_15_origPos tal, $ups_14_origCou ntry, $ups_13_product , $ups_10_action;
$result = 0;
@$result = mysql_query("se lect * from ".$db_prefix."_ products WHERE
id='$product_id '");
@$myrow = mysql_fetch_arr ay($result);
$value = $myrow['price_'.$price _level.'_level'] + $values_price_i nc;
if ($value < 100) {$value = 100;}
$html = implode ('', file
('http://wwwapps.ups.com/ctc/htmlTool?accept _UPS_license_ag reement=yes&des tR
esident=01&49_r esidential=1&10 _action='.$ups_ 10_action.'&13_ product='.$ups_ 1
3_product.'&14_ origCountry='.$ ups_14_origCoun try.'&origCity= '.$ups_origCity .
'&15_origPostal ='.$ups_15_orig Postal.'&22_des tCountry='.$ups _22_destCountry .
'&shipDate='.da te("Y-m-d").'&document= '.$ups_document .'¤cy='.$ ups_curr
ency.'&containe r='.$ups_contai ner.'&billToUPS ='.$ups_billToU PS.'&dropOffCho i
ce='.$ups_dropO ffChoice.'&20_d estCity='.$deli very_city_addre ss.'&19_destPos t
al='.$delivery_ zip.'&23_weight ='.$myrow['weight'].'&24_value='.$ value.'&25_l
ength='.$myrow['size_x'].'&26_width='.$ myrow['size_y'].'&27_height='. $myrow[
'size_z']));
if (strstr($html, 'UPS United States'))
{
if (strstr($html, 'Provide Package Information'))
{
$result = 0;
}
elseif (strstr($html, 'Provide Shipment Information'))
{
$result = -1;
}
elseif (strstr($html, 'Detailed Results'))
{
eregi('Shipment Total:</span><img alt="" height="1" src="/img/1.gif"
width="12">(.+) <img alt="" height="1" src="/img/1.gif" width="6"><span
class="bold">US D</span></div></td>', $html, $temp);
$result = $temp[1];
}
else
{
order_step_1('' , '', '', 'delivery_addre ss_incorrect');
break;
}
}
if ($result < 0) {order_step_1(' ', '', '', 'delivery_addre ss_incorrect'); }
if ($myrow['price_'.$price _level.'_shippi ng'] == 1) {$result = 0;}
$result = $result * $product_quanti ty;
return $result;
}
-----------------------------------------------------------------------
Basically, from what I can gather, its looking within the webpage result
from UPS to see if something exists, in essence to give the
"check_deliver_ price" function a result.
The use of "implode" in the above code (as in any PHP coding I would
imagine) is a concatenation function from what I can tell by my research.
However, it seems that the implode function call as used above is stripping
the space in between a customers City address (ie. Santa Fe, Los Angelos,
etc.) creating a situation where "Santa Fe" would be just "Santa" by the
time it is concatenated. Therefore, only "Santa" gets passed onto UPS by
use of the URL, which of course UPS returns an error.
Only customers with a space in the city name have this issue. Now, my
programmer while capable of resolving this issue, is absent and since she is
not even in the US, I cannot contact her.
I am asking the NG for any help in modifying the above code or any
suggestions as to what I can do. I dont mind keeping backups of her coding,
then modifying the original.. besides, I dont imagine I could make matters
much worse, since the "check_deliver_ price" function is called both for
address verfication upon customer sign up, but, to find out the delivery
charges of the products that they purchase.
The key portion of the code (I think) would be:
$html = implode ('', file
('http://wwwapps.ups.com/ctc/htmlTool?accept _UPS_license_ag reement=yes&des tR
esident=01&49_r esidential=1&10 _action='.$ups_ 10_action.'&13_ product='.$ups_ 1
3_product.'&14_ origCountry='.$ ups_14_origCoun try.'&origCity= '.$ups_origCity .
'&15_origPostal ='.$ups_15_orig Postal.'&22_des tCountry='.$ups _22_destCountry .
'&shipDate='.da te("Y-m-d").'&document= '.$ups_document .'¤cy='.$ ups_curr
ency.'&containe r='.$ups_contai ner.'&billToUPS ='.$ups_billToU PS.'&dropOffCho i
ce='.$ups_dropO ffChoice.'&20_d estCity='.$deli very_city_addre ss.'&19_destPos t
al='.$delivery_ zip.'&23_weight ='.$myrow['weight'].'&24_value='.$ value.'&25_l
ength='.$myrow['size_x'].'&26_width='.$ myrow['size_y'].'&27_height='. $myrow[
'size_z']));
What I seek is an overall resolution to the code sniplet, though, I think if
I can find out from anyone here on how to fill in any spaces that may exist
in the $delivery_city_ address variable with a %20, that would pretty much
resolve my issue?
Any guideance would be greatly appreciated, albeit, a modified code
resolving my issue would make it much easier and would be the most
appreciated assistance for this wannabe PHP programmer. :)
Jeff
Quick background as I dont wish to hog anyones time. I am a customer of a
PHP/SQL programmer. A website that I had the programmer build for me is
working great, with one exception.
I have limited programming experience, most of it Pascal/C++ and I haven't
programmed for many years now even then it was mediocre programming of small
this and thats.
Here is the code:
-----------------------------------------------------------------------
function check_deliver_p rice($product_i d, $product_quanti ty, $price_level,
$delivery_city_ address, $delivery_state _address, $delivery_zip,
$values_price_i nc)
{
global $db_prefix, $ups_dropOffCho ice, $ups_container, $ups_billToUPS,
$ups_currency, $ups_document, $ups_22_destCou ntry, $ups_origCity,
$ups_15_origPos tal, $ups_14_origCou ntry, $ups_13_product , $ups_10_action;
$result = 0;
@$result = mysql_query("se lect * from ".$db_prefix."_ products WHERE
id='$product_id '");
@$myrow = mysql_fetch_arr ay($result);
$value = $myrow['price_'.$price _level.'_level'] + $values_price_i nc;
if ($value < 100) {$value = 100;}
$html = implode ('', file
('http://wwwapps.ups.com/ctc/htmlTool?accept _UPS_license_ag reement=yes&des tR
esident=01&49_r esidential=1&10 _action='.$ups_ 10_action.'&13_ product='.$ups_ 1
3_product.'&14_ origCountry='.$ ups_14_origCoun try.'&origCity= '.$ups_origCity .
'&15_origPostal ='.$ups_15_orig Postal.'&22_des tCountry='.$ups _22_destCountry .
'&shipDate='.da te("Y-m-d").'&document= '.$ups_document .'¤cy='.$ ups_curr
ency.'&containe r='.$ups_contai ner.'&billToUPS ='.$ups_billToU PS.'&dropOffCho i
ce='.$ups_dropO ffChoice.'&20_d estCity='.$deli very_city_addre ss.'&19_destPos t
al='.$delivery_ zip.'&23_weight ='.$myrow['weight'].'&24_value='.$ value.'&25_l
ength='.$myrow['size_x'].'&26_width='.$ myrow['size_y'].'&27_height='. $myrow[
'size_z']));
if (strstr($html, 'UPS United States'))
{
if (strstr($html, 'Provide Package Information'))
{
$result = 0;
}
elseif (strstr($html, 'Provide Shipment Information'))
{
$result = -1;
}
elseif (strstr($html, 'Detailed Results'))
{
eregi('Shipment Total:</span><img alt="" height="1" src="/img/1.gif"
width="12">(.+) <img alt="" height="1" src="/img/1.gif" width="6"><span
class="bold">US D</span></div></td>', $html, $temp);
$result = $temp[1];
}
else
{
order_step_1('' , '', '', 'delivery_addre ss_incorrect');
break;
}
}
if ($result < 0) {order_step_1(' ', '', '', 'delivery_addre ss_incorrect'); }
if ($myrow['price_'.$price _level.'_shippi ng'] == 1) {$result = 0;}
$result = $result * $product_quanti ty;
return $result;
}
-----------------------------------------------------------------------
Basically, from what I can gather, its looking within the webpage result
from UPS to see if something exists, in essence to give the
"check_deliver_ price" function a result.
The use of "implode" in the above code (as in any PHP coding I would
imagine) is a concatenation function from what I can tell by my research.
However, it seems that the implode function call as used above is stripping
the space in between a customers City address (ie. Santa Fe, Los Angelos,
etc.) creating a situation where "Santa Fe" would be just "Santa" by the
time it is concatenated. Therefore, only "Santa" gets passed onto UPS by
use of the URL, which of course UPS returns an error.
Only customers with a space in the city name have this issue. Now, my
programmer while capable of resolving this issue, is absent and since she is
not even in the US, I cannot contact her.
I am asking the NG for any help in modifying the above code or any
suggestions as to what I can do. I dont mind keeping backups of her coding,
then modifying the original.. besides, I dont imagine I could make matters
much worse, since the "check_deliver_ price" function is called both for
address verfication upon customer sign up, but, to find out the delivery
charges of the products that they purchase.
The key portion of the code (I think) would be:
$html = implode ('', file
('http://wwwapps.ups.com/ctc/htmlTool?accept _UPS_license_ag reement=yes&des tR
esident=01&49_r esidential=1&10 _action='.$ups_ 10_action.'&13_ product='.$ups_ 1
3_product.'&14_ origCountry='.$ ups_14_origCoun try.'&origCity= '.$ups_origCity .
'&15_origPostal ='.$ups_15_orig Postal.'&22_des tCountry='.$ups _22_destCountry .
'&shipDate='.da te("Y-m-d").'&document= '.$ups_document .'¤cy='.$ ups_curr
ency.'&containe r='.$ups_contai ner.'&billToUPS ='.$ups_billToU PS.'&dropOffCho i
ce='.$ups_dropO ffChoice.'&20_d estCity='.$deli very_city_addre ss.'&19_destPos t
al='.$delivery_ zip.'&23_weight ='.$myrow['weight'].'&24_value='.$ value.'&25_l
ength='.$myrow['size_x'].'&26_width='.$ myrow['size_y'].'&27_height='. $myrow[
'size_z']));
What I seek is an overall resolution to the code sniplet, though, I think if
I can find out from anyone here on how to fill in any spaces that may exist
in the $delivery_city_ address variable with a %20, that would pretty much
resolve my issue?
Any guideance would be greatly appreciated, albeit, a modified code
resolving my issue would make it much easier and would be the most
appreciated assistance for this wannabe PHP programmer. :)
Jeff
Comment