hadas921
06-05-2007, 04:48 PM
Hi,
I have been trying to write a custom php script for shipping based on the template that is provided in the soholaunch help-section. I am trying to make add a base shipping price (4.95 domestic, 13.95 international) in addition to 1.00 per sku. I have finally gotten the shipping prices to be correct, but I cannot complete the checkout process in my program. The problem that I am having is that I cannot move from step 3 in the program (shipping options) to step 4 (verify order details) at checkout. I don't Have programming knowledge, but unfortunately I cannot afford to pay for a site developer. If I can just figure out how to get the shipping/checkout I would be glad to invest in the full version of soholaunch. Otherwise, my trial period is running out in a few days. The following is my PHP script if you can spot the problem...
Thank you so much!!!
Please note : I do not need to provide an overnight option so i tried to remove that from the script.
<?
$tmp_prikey = split(";", $CART_KEYID); // Place cart PRIKEYs into array
$tmp_cnt = count($tmp_prikey); // How many line items are in cart?
$tmp_qty = split(";", $CART_QTY); // What is the qty ordered for each sku
$SHIPPING_TOTAL = ""; // Reset Shipping Total for the Moment
// -------------------------------------------------------------
// MOD STEP 1: Determine which ship field to extract data from
// In the “cart_products” table, we use SHIPA to hold the U.S.// Shipping Charge per sku and SHIPB to hold International
// Ship charge per sku
// -------------------------------------------------------------
if ($SCOUNTRY == "UNITED STATES - US") {
$TMP_DAT = "PROD_SHIPA";
} else {
$TMP_DAT = "PROD_SHIPB";
}
// -------------------------------------------------------------
for ($sc=0;$sc<=$tmp_cnt;$sc++) {
$ship_price = ""; // Reset match calc vars. Even though they are temporary
$new_add = ""; // anything can happen to the math in a loop like this.
// Pull first line item's "SHIP PRICE (A/B)" value from products table
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
$result = mysql_query("SELECT $TMP_DAT FROM cart_products WHERE
PRIKEY = '$tmp_prikey[$sc]'");
$TVAL = mysql_fetch_array($result);
// NOTICE THE MOD VAR IN PLACE OF "PROD_SHIPA“ ON NEXT LINE
$ship_price = $TVAL[$TMP_DAT]; // Multiply Individual shipping price by current sku qty
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
$new_add = $ship_price*$tmp_qty[$sc];
// Add calculation to shipping total
$SHIPPING_TOTAL = $SHIPPING_TOTAL + $new_add;
} // End $sc Loop
// At this point, this is your Current total straight from the sku calculation
$SHIPPING_TOTAL = $SHIPPING_TOTAL;
// ---------------------------------------------------------
// Step 3: If this is a US order; add a 4.95 base rate
// ---------------------------------------------------------
if ($SCOUNTRY == "UNITED STATES - US") { $SHIPPING_TOTAL = $SHIPPING_TOTAL + 4.95; }
// ------------------------------------------------------------
// Step 4: If this is NOT US order; add a 13.95 base rate
// -------------------------------------------------------------
if ($SCOUNTRY != "UNITED STATES - US") { $SHIPPING_TOTAL = $SHIPPING_TOTAL + 13.95; }
// --------------------------------------------------------------------
// At this point the Shipping Total has the base prices added to it...
// --------------------------------------------------------------------
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~
// In case user decides to "back up" and change selection, unregister the
// shipping variables currently in this session. Once the user commits,
// these vars will be re-registered, don't worry.
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~
if (session_is_registered("SHIPPING_TOTAL")) {
session_unregister("SHIPPING_TOTAL");
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~
// ----------------------------------------------------------
// DISPLAY CHECKOUT ROUTINE STEPS FOR REFERENCE BY CUSTOMER
// To display output and stop on shipping step, we want to
// fill the $THIS_DISPLAY variable with HTML data. This will// indicate to the “builder” program that we need to display
// HTML options here and stop.
// ----------------------------------------------------------
$THIS_DISPLAY .= "<TABLE BORDER=0 CELLPADDING=4 CELLSPACING=0 WIDTH=100%
CLASS=text STYLE='border: 1px inset black;'>\n";
$THIS_DISPLAY .= "<TR>\n";
$THIS_DISPLAY .= "<TD ALIGN=LEFT VALIGN=TOP CLASS=smtext BGCOLOR=WHITE>
<FONT COLOR=#CCCCCC>\n";
$THIS_DISPLAY .= "Step 1:<BR>Customer Sign-in\n";
$THIS_DISPLAY .= "</TD>\n";
$THIS_DISPLAY .= "<TD ALIGN=LEFT VALIGN=TOP CLASS=smtext BGCOLOR=WHITE>
<FONT COLOR=#CCCCCC>\n";
$THIS_DISPLAY .= "Step 2:<BR>Billing & Shipping<BR>Information\n";
$THIS_DISPLAY .= "</TD>\n";
$THIS_DISPLAY .= "<TD ALIGN=LEFT VALIGN=TOP CLASS=smtext BGCOLOR=WHITE>
<FONT COLOR=BLACK>\n";
$THIS_DISPLAY .= "<B>Step 3:<BR>Shipping Options</B>\n";
$THIS_DISPLAY .= "</TD>\n";
$THIS_DISPLAY .= "<TD ALIGN=LEFT VALIGN=TOP CLASS=smtext BGCOLOR=WHITE>
<FONT COLOR=#CCCCCC>\n";
$THIS_DISPLAY .= "Step 4:<BR>Verify Order<BR>Details\n";
$THIS_DISPLAY .= "</TD>\n";
$THIS_DISPLAY .= "<TD ALIGN=LEFT VALIGN=TOP CLASS=smtext BGCOLOR=WHITE>
<FONT COLOR=#CCCCCC>\n";
$THIS_DISPLAY .= "Step 5:<BR>Make Payment\n";
$THIS_DISPLAY .= "</TD>\n";
$THIS_DISPLAY .= "<TD ALIGN=LEFT VALIGN=TOP CLASS=smtext BGCOLOR=WHITE>
<FONT COLOR=#CCCCCC>\n";
$THIS_DISPLAY .= "Step 6:<BR>Print Final<BR>Invoice\n";
$THIS_DISPLAY .= "</TD>\n";
$THIS_DISPLAY .= "</TR></TABLE><BR>\n";
// ----------------------------------------------------------
// Post our form to “pgm-checkout.php” because this is the
// program module executing this include right now!
// ----------------------------------------------------------
$THIS_DISPLAY .= "<FORM METHOD=POST ACTION=\"pgm-checkout.php\">\n";
// These hidden vars MUST be in here for proper operation
$THIS_DISPLAY .= "<INPUT TYPE=HIDDEN NAME=STEP VALUE=\"3\">\n";
$THIS_DISPLAY .= "<INPUT TYPE=HIDDEN NAME=customer_active VALUE=\"Y\">\n";
$THIS_DISPLAY .= "<INPUT TYPE=HIDDEN
NAME=customernumber VALUE=\"$customernumber\">\n";
$THIS_DISPLAY .= "<P ALIGN=CENTER CLASS=text><B>Your Current Shipping Charges:
$SHIPPING_TOTAL.<BR><BR></B>
Please select your delivery preference: \n";
$THIS_DISPLAY .= "<BR><BR><INPUT TYPE=IMAGE SRC=\"cont_checkout.gif\" WIDTH=106
HEIGHT=25 STYLE='CURSOR: HAND;'>\n";
$THIS_DISPLAY .= "</P></FORM>\n";
// END United States Check
// Do NOT use exit; on these includes because it will bomb the processing
?>
I have been trying to write a custom php script for shipping based on the template that is provided in the soholaunch help-section. I am trying to make add a base shipping price (4.95 domestic, 13.95 international) in addition to 1.00 per sku. I have finally gotten the shipping prices to be correct, but I cannot complete the checkout process in my program. The problem that I am having is that I cannot move from step 3 in the program (shipping options) to step 4 (verify order details) at checkout. I don't Have programming knowledge, but unfortunately I cannot afford to pay for a site developer. If I can just figure out how to get the shipping/checkout I would be glad to invest in the full version of soholaunch. Otherwise, my trial period is running out in a few days. The following is my PHP script if you can spot the problem...
Thank you so much!!!
Please note : I do not need to provide an overnight option so i tried to remove that from the script.
<?
$tmp_prikey = split(";", $CART_KEYID); // Place cart PRIKEYs into array
$tmp_cnt = count($tmp_prikey); // How many line items are in cart?
$tmp_qty = split(";", $CART_QTY); // What is the qty ordered for each sku
$SHIPPING_TOTAL = ""; // Reset Shipping Total for the Moment
// -------------------------------------------------------------
// MOD STEP 1: Determine which ship field to extract data from
// In the “cart_products” table, we use SHIPA to hold the U.S.// Shipping Charge per sku and SHIPB to hold International
// Ship charge per sku
// -------------------------------------------------------------
if ($SCOUNTRY == "UNITED STATES - US") {
$TMP_DAT = "PROD_SHIPA";
} else {
$TMP_DAT = "PROD_SHIPB";
}
// -------------------------------------------------------------
for ($sc=0;$sc<=$tmp_cnt;$sc++) {
$ship_price = ""; // Reset match calc vars. Even though they are temporary
$new_add = ""; // anything can happen to the math in a loop like this.
// Pull first line item's "SHIP PRICE (A/B)" value from products table
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
$result = mysql_query("SELECT $TMP_DAT FROM cart_products WHERE
PRIKEY = '$tmp_prikey[$sc]'");
$TVAL = mysql_fetch_array($result);
// NOTICE THE MOD VAR IN PLACE OF "PROD_SHIPA“ ON NEXT LINE
$ship_price = $TVAL[$TMP_DAT]; // Multiply Individual shipping price by current sku qty
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
$new_add = $ship_price*$tmp_qty[$sc];
// Add calculation to shipping total
$SHIPPING_TOTAL = $SHIPPING_TOTAL + $new_add;
} // End $sc Loop
// At this point, this is your Current total straight from the sku calculation
$SHIPPING_TOTAL = $SHIPPING_TOTAL;
// ---------------------------------------------------------
// Step 3: If this is a US order; add a 4.95 base rate
// ---------------------------------------------------------
if ($SCOUNTRY == "UNITED STATES - US") { $SHIPPING_TOTAL = $SHIPPING_TOTAL + 4.95; }
// ------------------------------------------------------------
// Step 4: If this is NOT US order; add a 13.95 base rate
// -------------------------------------------------------------
if ($SCOUNTRY != "UNITED STATES - US") { $SHIPPING_TOTAL = $SHIPPING_TOTAL + 13.95; }
// --------------------------------------------------------------------
// At this point the Shipping Total has the base prices added to it...
// --------------------------------------------------------------------
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~
// In case user decides to "back up" and change selection, unregister the
// shipping variables currently in this session. Once the user commits,
// these vars will be re-registered, don't worry.
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~
if (session_is_registered("SHIPPING_TOTAL")) {
session_unregister("SHIPPING_TOTAL");
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~
// ----------------------------------------------------------
// DISPLAY CHECKOUT ROUTINE STEPS FOR REFERENCE BY CUSTOMER
// To display output and stop on shipping step, we want to
// fill the $THIS_DISPLAY variable with HTML data. This will// indicate to the “builder” program that we need to display
// HTML options here and stop.
// ----------------------------------------------------------
$THIS_DISPLAY .= "<TABLE BORDER=0 CELLPADDING=4 CELLSPACING=0 WIDTH=100%
CLASS=text STYLE='border: 1px inset black;'>\n";
$THIS_DISPLAY .= "<TR>\n";
$THIS_DISPLAY .= "<TD ALIGN=LEFT VALIGN=TOP CLASS=smtext BGCOLOR=WHITE>
<FONT COLOR=#CCCCCC>\n";
$THIS_DISPLAY .= "Step 1:<BR>Customer Sign-in\n";
$THIS_DISPLAY .= "</TD>\n";
$THIS_DISPLAY .= "<TD ALIGN=LEFT VALIGN=TOP CLASS=smtext BGCOLOR=WHITE>
<FONT COLOR=#CCCCCC>\n";
$THIS_DISPLAY .= "Step 2:<BR>Billing & Shipping<BR>Information\n";
$THIS_DISPLAY .= "</TD>\n";
$THIS_DISPLAY .= "<TD ALIGN=LEFT VALIGN=TOP CLASS=smtext BGCOLOR=WHITE>
<FONT COLOR=BLACK>\n";
$THIS_DISPLAY .= "<B>Step 3:<BR>Shipping Options</B>\n";
$THIS_DISPLAY .= "</TD>\n";
$THIS_DISPLAY .= "<TD ALIGN=LEFT VALIGN=TOP CLASS=smtext BGCOLOR=WHITE>
<FONT COLOR=#CCCCCC>\n";
$THIS_DISPLAY .= "Step 4:<BR>Verify Order<BR>Details\n";
$THIS_DISPLAY .= "</TD>\n";
$THIS_DISPLAY .= "<TD ALIGN=LEFT VALIGN=TOP CLASS=smtext BGCOLOR=WHITE>
<FONT COLOR=#CCCCCC>\n";
$THIS_DISPLAY .= "Step 5:<BR>Make Payment\n";
$THIS_DISPLAY .= "</TD>\n";
$THIS_DISPLAY .= "<TD ALIGN=LEFT VALIGN=TOP CLASS=smtext BGCOLOR=WHITE>
<FONT COLOR=#CCCCCC>\n";
$THIS_DISPLAY .= "Step 6:<BR>Print Final<BR>Invoice\n";
$THIS_DISPLAY .= "</TD>\n";
$THIS_DISPLAY .= "</TR></TABLE><BR>\n";
// ----------------------------------------------------------
// Post our form to “pgm-checkout.php” because this is the
// program module executing this include right now!
// ----------------------------------------------------------
$THIS_DISPLAY .= "<FORM METHOD=POST ACTION=\"pgm-checkout.php\">\n";
// These hidden vars MUST be in here for proper operation
$THIS_DISPLAY .= "<INPUT TYPE=HIDDEN NAME=STEP VALUE=\"3\">\n";
$THIS_DISPLAY .= "<INPUT TYPE=HIDDEN NAME=customer_active VALUE=\"Y\">\n";
$THIS_DISPLAY .= "<INPUT TYPE=HIDDEN
NAME=customernumber VALUE=\"$customernumber\">\n";
$THIS_DISPLAY .= "<P ALIGN=CENTER CLASS=text><B>Your Current Shipping Charges:
$SHIPPING_TOTAL.<BR><BR></B>
Please select your delivery preference: \n";
$THIS_DISPLAY .= "<BR><BR><INPUT TYPE=IMAGE SRC=\"cont_checkout.gif\" WIDTH=106
HEIGHT=25 STYLE='CURSOR: HAND;'>\n";
$THIS_DISPLAY .= "</P></FORM>\n";
// END United States Check
// Do NOT use exit; on these includes because it will bomb the processing
?>