Jump to content

Php If Statements


Guest benlogan

Recommended Posts

Guest benlogan

Hi,

I am currently working on an AusPost mod. It is all working great, except this. I have added options to Enable/Disable certain shipping methods. Now, I need it to do this.

$module = fetchDbConfig("Aus_Post");





//Start Parcel Post//

if($module[p_status]==1){       //checks to see if Parcel post is enabled.

function getPostCharge1($posturl)

{

$all = file_get_contents($posturl);

$bits = preg_match('/charge=(\\d*\\.?\\d*)/',$all,$out);

return $out[1];

}



$sum = getPostCharge1("http://drc.edeliver.com.au/ratecalc.asp?Pickup_Postcode=$frompcode&Destination_Postcode=$topcode&Country=$dest_country&Weight=$sweight&Service_Type=STANDARD&Height=$sheight&Width=$swidth&Length=$slength&Quantity=1");

$sum = $sum + $nathand;



function getPostDays1($posturl)

{

$all = file_get_contents($posturl);

$bits = preg_match('/days=(\\d*\\.?\\d*)/',$all,$out);

return $out[1];

}



$days = getPostDays1("http://drc.edeliver.com.au/ratecalc.asp?Pickup_Postcode=$frompcode&Destination_Postcode=$topcode&Country=$dest_country&Weight=$sweight&Service_Type=STANDARD&Height=$sheight&Width=$swidth&Length=$slength&Quantity=1");





if($taxVal>0){



	$val = ($taxVal / 100) * $sum;

	$sum = $sum + $val;

}



$shippingPrice .= "<option value='".$shipKey."'";



if($shipKey ==$basket['shipKey']){

	$shippingPrice .= " selected='selected'";

	$basket = $cart->setVar($Parcel,"shipMethod");

	$basket = $cart->setVar($sum,"shipCost");

}





$shippingPrice .= ">".priceFormat($sum)." - ".$Parcel." (".$days." Days)</option>\r\n";   //changed code to display set variable

$shipKey++;

unset($module, $taxVal, $sum, $days);



//End Parcel Post

}

I want to so that if p_status = 1 then add the option, if not

dont add the option and continue to the next one. Thanks.

Link to comment
Share on other sites

Guest benlogan

ok, I have this, but it gets to the first one, and doesnt add the rest.

<?php

/*

+--------------------------------------------------------------------------

|   CubeCart v3.0.3

|   ========================================

|   by Alistair Brookbanks

|	CubeCart is a Trade Mark of Devellion Limited

|   (c) 2005 Devellion Limited

|   Devellion Limited,

|   Westfield Lodge,

|   Westland Green,

|   Little Hadham,

|   Nr Ware, HERTS.

|   SG11 2AL

|   UNITED KINGDOM

|   http://www.devellion.com

|	UK Private Limited Company No. 5323904

|   ========================================

|   Web: http://www.cubecart.com

|   Date: Thursday, 22 September 2005

|   Email: info (at) cubecart (dot) com

|	License Type: CubeCart is NOT Open Source Software and Limitations Apply 

|   Licence Info: http://www.cubecart.com/site/faq/license.php

+--------------------------------------------------------------------------

|	calc.php

|   ========================================

|	Calculates shipping based on a flat rate	

+--------------------------------------------------------------------------

*/

// flat rate







$Parcel= "AusPost Parcel";

$Express = "AusPost Express";

$Air = "AusPost International AirMail";

$AirE = "AusPost International AirMail Economy";

$Sea = "AusPost International SeaMail";





$module = fetchDbConfig("Aus_Post");

if($module['status']==1){

$countryISO = countryIso($basket['delInf']['country']);



$taxVal = taxRate($module['tax']);

$config = fetchDbConfig("config");

$site_iso = countryIso($config['siteCountry']);

$nathand = $module['nat_handling']; 

$inthand = $module['int_handling']; 





// cUSTOM sTUFF //



      $frompcode = $module['postcode'];

      $topcode = $basket['delInf']['postcode'];

      $dest_country = countryIso($basket['delInf']['country']);

      $sweight = $totalWeight*1000;

      $swidth = $module['width'];

      $sheight = $module['height'];

      $slength = $module['length'];

   

   // END CUSTOM STUFF//

   

   if($countryISO == $site_iso){



//Start Parcel Post//

if($module['p_status']==1){          //check to see if shipping option is enabled.

function getPostCharge1($posturl)

{

$all = file_get_contents($posturl);

$bits = preg_match('/charge=(\\d*\\.?\\d*)/',$all,$out);

return $out[1];

}



$sum = getPostCharge1("http://drc.edeliver.com.au/ratecalc.asp?Pickup_Postcode=$frompcode&Destination_Postcode=$topcode&Country=$dest_country&Weight=$sweight&Service_Type=STANDARD&Height=$sheight&Width=$swidth&Length=$slength&Quantity=1");

$sum = $sum + $nathand;



function getPostDays1($posturl)

{

$all = file_get_contents($posturl);

$bits = preg_match('/days=(\\d*\\.?\\d*)/',$all,$out);

return $out[1];

}



$days = getPostDays1("http://drc.edeliver.com.au/ratecalc.asp?Pickup_Postcode=$frompcode&Destination_Postcode=$topcode&Country=$dest_country&Weight=$sweight&Service_Type=STANDARD&Height=$sheight&Width=$swidth&Length=$slength&Quantity=1");





if($taxVal>0){



	$val = ($taxVal / 100) * $sum;

	$sum = $sum + $val;

}



$shippingPrice .= "<option value='".$shipKey."'";



if($shipKey ==$basket['shipKey']){

	$shippingPrice .= " selected='selected'";

	$basket = $cart->setVar($Parcel,"shipMethod");

	$basket = $cart->setVar($sum,"shipCost");

}





$shippingPrice .= ">".priceFormat($sum)." - ".$Parcel." (".$days." Days)</option>\r\n";   //changed code to display set variable

$shipKey++;



unset($module, $taxVal, $sum, $days);

}

//End Parcel Post



//Start Express Post/

if($module['e_status']==1){        //check to see if shipping option is enabled.

function getPostCharge2($posturl)

{

$all = file_get_contents($posturl);

$bits = preg_match('/charge=(\\d*\\.?\\d*)/',$all,$out);

return $out[1];

}

$sum = getPostCharge2("http://drc.edeliver.com.au/ratecalc.asp?Pickup_Postcode=$frompcode&Destination_Postcode=$topcode&Country=$dest_country&Weight=$sweight&Service_Type=EXPRESS&Height=$sheight&Width=$swidth&Length=$slength&Quantity=1");

$sum = $sum + $nathand;

function getPostDays2($posturl)

{

$all = file_get_contents($posturl);

$bits = preg_match('/days=(\\d*\\.?\\d*)/',$all,$out);

return $out[1];

}



$days = getPostDays2("http://drc.edeliver.com.au/ratecalc.asp?Pickup_Postcode=$frompcode&Destination_Postcode=$topcode&Country=$dest_country&Weight=$sweight&Service_Type=EXPRESS&Height=$sheight&Width=$swidth&Length=$slength&Quantity=1");





if($taxVal>0){



	$val = ($taxVal / 100) * $sum;

	$sum = $sum + $val;

}



$shippingPrice .= "<option value='".$shipKey."'";



if($shipKey ==$basket['shipKey']){

	$shippingPrice .= " selected='selected'";

	$basket = $cart->setVar($Express,"shipMethod");

	$basket = $cart->setVar($sum,"shipCost");

}





$shippingPrice .= ">".priceFormat($sum)." - ".$Express." (".$days." Days)</option>\r\n";   //changed code to display set variable

$shipKey++;



unset($module, $taxVal, $sum, $days);

}

//End Express Post//





} //end bracket for coutnry check

else{

//Start International Air//

if($module['a_status']==1){        //check to see if shipping option is enabled.

function getPostCharge3($posturl)

{

$all = file_get_contents($posturl);

$bits = preg_match('/charge=(\\d*\\.?\\d*)/',$all,$out);

return $out[1];

}





$sum = getPostCharge3("http://drc.edeliver.com.au/ratecalc.asp?Pickup_Postcode=$frompcode&Destination_Postcode=$topcode&Country=$dest_country&Weight=$sweight&Service_Type=AIR&Height=$sheight&Width=$swidth&Length=$slength&Quantity=1");

$sum = $sum + $inthand;



function getPostDays3($posturl)

{

$all = file_get_contents($posturl);

$bits = preg_match('/days=(\\d*\\.?\\d*)/',$all,$out);

return $out[1];

}



$days = getPostDays3("http://drc.edeliver.com.au/ratecalc.asp?Pickup_Postcode=$frompcode&Destination_Postcode=$topcode&Country=$dest_country&Weight=$sweight&Service_Type=AIR&Height=$sheight&Width=$swidth&Length=$slength&Quantity=1");



$taxVal = taxRate($module['tax']);



if($taxVal>0){



	$val = ($taxVal / 100) * $sum;

	$sum = $sum + $val;

}



$shippingPrice .= "<option value='".$shipKey."'";



if($shipKey ==$basket['shipKey']){

	$shippingPrice .= " selected='selected'";

	$basket = $cart->setVar($Air,"shipMethod");

	$basket = $cart->setVar($sum,"shipCost");

}



$shippingPrice .= ">".priceFormat($sum)." - ".$Air." (".$days." Days)</option>\r\n";   //changed code to display set variable

$shipKey++;

unset($module, $taxVal, $sum, $days);

}



// End Interntional Air//



//Start Air Economy //

if($module['ae_status']==1){        //check to see if shipping option is enabled.

function getPostCharge4($posturl)

{

$all = file_get_contents($posturl);

$bits = preg_match('/charge=(\\d*\\.?\\d*)/',$all,$out);

return $out[1];

}

$sum = getPostCharge4("http://drc.edeliver.com.au/ratecalc.asp?Pickup_Postcode=$frompcode&Destination_Postcode=$topcode&Country=$dest_country&Weight=$sweight&Service_Type=ECONOMY&Height=$sheight&Width=$swidth&Length=$slength&Quantity=1");

$sum = $sum + $inthand;

function getPostDays4($posturl)

{

$all = file_get_contents($posturl);

$bits = preg_match('/days=(\\d*\\.?\\d*)/',$all,$out);

return $out[1];

}

$days = getPostDays4("http://drc.edeliver.com.au/ratecalc.asp?Pickup_Postcode=$frompcode&Destination_Postcode=$topcode&Country=$dest_country&Weight=$sweight&Service_Type=ECONOMY&Height=$sheight&Width=$swidth&Length=$slength&Quantity=1");



$taxVal = taxRate($module['tax']);



if($taxVal>0){



	$val = ($taxVal / 100) * $sum;

	$sum = $sum + $val;

}



$shippingPrice .= "<option value='".$shipKey."'";



if($shipKey ==$basket['shipKey']){

	$shippingPrice .= " selected='selected'";

	$basket = $cart->setVar($AirE,"shipMethod");

	$basket = $cart->setVar($sum,"shipCost");

}



$shippingPrice .= ">".priceFormat($sum)." - ".$AirE." (".$days." Days)</option>\r\n";   //changed code to display set variable

$shipKey++;

unset($module, $taxVal, $sum, $days);

}

//end Air Eonomoy //



//Start Sea//

if($module['s_status']==1){        //check to see if shipping option is enabled.

function getPostCharge5($posturl)

{

$all = file_get_contents($posturl);

$bits = preg_match('/charge=(\\d*\\.?\\d*)/',$all,$out);

return $out[1];

}

$sum = getPostCharge5("http://drc.edeliver.com.au/ratecalc.asp?Pickup_Postcode=$frompcode&Destination_Postcode=$topcode&Country=$dest_country&Weight=$sweight&Service_Type=SEA&Height=$sheight&Width=$swidth&Length=$slength&Quantity=1");

$sum = $sum + $inthand;

function getPostDays5($posturl)

{

$all = file_get_contents($posturl);

$bits = preg_match('/days=(\\d*\\.?\\d*)/',$all,$out);

return $out[1];

}

$days = getPostDays5("http://drc.edeliver.com.au/ratecalc.asp?Pickup_Postcode=$frompcode&Destination_Postcode=$topcode&Country=$dest_country&Weight=$sweight&Service_Type=SEA&Height=$sheight&Width=$swidth&Length=$slength&Quantity=1");



$taxVal = taxRate($module['tax']);



if($taxVal>0){



	$val = ($taxVal / 100) * $sum;

	$sum = $sum + $val;

}



$shippingPrice .= "<option value='".$shipKey."'";



if($shipKey ==$basket['shipKey']){

	$shippingPrice .= " selected='selected'";

	$basket = $cart->setVar($Sea,"shipMethod");

	$basket = $cart->setVar($sum,"shipCost");

}



$shippingPrice .= ">".priceFormat($sum)." - ".$Sea." (".$days." Days)</option>\r\n";   //changed code to display set variable

$shipKey++;

unset($module, $taxVal, $sum, $days);

}

//end Sea//



}





}

?>

any php guru out there got any ideas, cause im stuck. thank.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...