jarchee
01-21-2010, 02:19 PM
Hi,
I'm just a beginner and have no clue of what I'm writing here. anyways I need help with this small php program.
I want to make this work.
I have four (4) probable values that want to replace them with 4 other values if one occurs. everytime there is a chance of occurring for one of them:
Free Shipping - Free Shipping
FedEx - Priority Overnight
FedEx - Ground
Canada Post (Recommended for residential users) - Canada Post
I want to say:
if the value is "Free Shipping - Free Shipping" then replace(change) it with "FREE SHIPPING", but if the value is "FedEx - Priority Overnight" replace(change) it with "FEDEX-OVERNIGHT", but if the value is "FedEx - Ground" replace(change) it with "FEDEX-GROUND", but if the value is "Canada Post (Recommended for residential users) - Canada Post" replace(change) it with "CANADA POST".
what I have done is:
$original = $order->getData('shipping_description');
if ($original = "Free Shipping - Free Shipping") {
$sp1 = substr_replace($original, "FREE SHIPPING", 0);
$value = $sp1;
} elseif ($original = "FedEx - Priority Overnight") {
$sp2 = substr_replace($original, "FEDEX-OVERNIGHT", 0);
$value = $sp2;
} elseif ($original = "FedEx - Ground") {
$sp3 = substr_replace($original, "FEDEX-GROUND", 0);
$value = $sp3;
} elseif ($original = "Canada Post (Recommended for residential users) - Canada Post") {
$sp4 = substr_replace($original, "CANADA POST", 0);
$value = $sp4;
}
but it returns "FREE SHIPPING" every time.
Please advise
I'm just a beginner and have no clue of what I'm writing here. anyways I need help with this small php program.
I want to make this work.
I have four (4) probable values that want to replace them with 4 other values if one occurs. everytime there is a chance of occurring for one of them:
Free Shipping - Free Shipping
FedEx - Priority Overnight
FedEx - Ground
Canada Post (Recommended for residential users) - Canada Post
I want to say:
if the value is "Free Shipping - Free Shipping" then replace(change) it with "FREE SHIPPING", but if the value is "FedEx - Priority Overnight" replace(change) it with "FEDEX-OVERNIGHT", but if the value is "FedEx - Ground" replace(change) it with "FEDEX-GROUND", but if the value is "Canada Post (Recommended for residential users) - Canada Post" replace(change) it with "CANADA POST".
what I have done is:
$original = $order->getData('shipping_description');
if ($original = "Free Shipping - Free Shipping") {
$sp1 = substr_replace($original, "FREE SHIPPING", 0);
$value = $sp1;
} elseif ($original = "FedEx - Priority Overnight") {
$sp2 = substr_replace($original, "FEDEX-OVERNIGHT", 0);
$value = $sp2;
} elseif ($original = "FedEx - Ground") {
$sp3 = substr_replace($original, "FEDEX-GROUND", 0);
$value = $sp3;
} elseif ($original = "Canada Post (Recommended for residential users) - Canada Post") {
$sp4 = substr_replace($original, "CANADA POST", 0);
$value = $sp4;
}
but it returns "FREE SHIPPING" every time.
Please advise
