close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Cash On Delivery Option- Ecart

Thread began 6/21/2010 7:22 pm by Maplemac | Last modified 6/23/2010 9:35 am by Jason Byrnes | 1162 views | 9 replies |

Maplemac

Cash On Delivery Option- Ecart

Hi
I need to add an option for the buyer to pay cash on delivery rather than paying by PayPal. I also need to have the order info emailed for both options.

I have set this up using Universal Email for the PayPal part but am stuck with the COD option.
I have addedd a checkbox to the checkout page to indicate COD:
<input type="checkbox" name="cashondelivery" id="cashondelivery" value="1"/>

I have added a hidden input on the Checkout page
<input type="hidden" name="cashondelivery" id="cashondelivery" value="<?php echo((isset($_POST["cashondelivery"]))?$_POST["cashondelivery"]:"") ?>"/>

What I need now is when Checkout is clicked it to go to a confirm page and then send me an email to give the orfer details.
What code do I need to add to the checkout page and where do I need to add it and which page do I put the Universal Email on.
Thanks

order-indoor.php

Sign in to reply to this post

Jason ByrnesWebAssist

if you are using Paypal Payments pro as the payment gateway, locate the Local Checkout code on the confirm page, it will look similar to:

php:
<?php

if (($_SERVER["REQUEST_METHOD"] == "POST") && (isset($_SERVER["HTTP_REFERER"]) && strpos(urldecode($_SERVER["HTTP_REFERER"]), urldecode($_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"])) > 0) && isset($_POST))  {
  
$PP_DirectPayment_required = array();
  
$PP_DirectPayment_required[0] = array();
  
$PP_DirectPayment_required[1] = array();
  
$PP_DirectPayment_itemized = array();
  
$PP_DirectPayment_itemized[0] = array();
  
$PP_DirectPayment_itemized[1] = array();
  
$PP_DirectPayment_optional = array();
  
$PP_DirectPayment_optional[0] = array();
  
$PP_DirectPayment_optional[1] = array();
  
$cartIndex 0;
  
$nextIndex 0;
  
$nextIndex count($PP_DirectPayment_required[0]);
  
$PP_DirectPayment_required[0][$nextIndex] = "Username";
  
$PP_DirectPayment_required[1][$nextIndex] = "".$WAGLOBAL_Paypal_User  ."";
  
$nextIndex count($PP_DirectPayment_required[0]);
  
$PP_DirectPayment_required[0][$nextIndex] = "Password";
  
$PP_DirectPayment_required[1][$nextIndex] = "".$WAGLOBAL_Paypal_Password  ."";
  
$nextIndex count($PP_DirectPayment_required[0]);
  
$PP_DirectPayment_required[0][$nextIndex] = "Signature";
  
$PP_DirectPayment_required[1][$nextIndex] = "".$WAGLOBAL_Paypal_Signature  ."";
  
$nextIndex count($PP_DirectPayment_required[0]);
  
$PP_DirectPayment_required[0][$nextIndex] = "PaymentAction";
  
$PP_DirectPayment_required[1][$nextIndex] = "Sale";
  
$nextIndex count($PP_DirectPayment_required[0]);
  
$PP_DirectPayment_required[0][$nextIndex] = "Currency";
  
$PP_DirectPayment_required[1][$nextIndex] = "USD";
  
$nextIndex count($PP_DirectPayment_required[0]);
  
$PP_DirectPayment_required[0][$nextIndex] = "IPAddress";
  
$PP_DirectPayment_required[1][$nextIndex] = "".$_SERVER["REMOTE_ADDR"]  ."";
  
$nextIndex count($PP_DirectPayment_required[0]);
  
$PP_DirectPayment_required[0][$nextIndex] = "CreditCardType";
  
$PP_DirectPayment_required[1][$nextIndex] = "".((isset($_POST["cc_type"]))?$_POST["cc_type"]:"")  ."";
  
$nextIndex count($PP_DirectPayment_required[0]);
  
$PP_DirectPayment_required[0][$nextIndex] = "CreditCardNumber";
  
$PP_DirectPayment_required[1][$nextIndex] = "".((isset($_POST["cc_number"]))?$_POST["cc_number"]:"")  ."";
  
$nextIndex count($PP_DirectPayment_required[0]);
  
$PP_DirectPayment_required[0][$nextIndex] = "ExpMonth";
  
$PP_DirectPayment_required[1][$nextIndex] = "".((isset($_POST["exp_month"]))?$_POST["exp_month"]:"")  ."";
  
$nextIndex count($PP_DirectPayment_required[0]);
  
$PP_DirectPayment_required[0][$nextIndex] = "ExpYear";
  
$PP_DirectPayment_required[1][$nextIndex] = "".((isset($_POST["exp_year"]))?$_POST["exp_year"]:"")  ."";
  
$nextIndex count($PP_DirectPayment_required[0]);
  
$PP_DirectPayment_required[0][$nextIndex] = "FirstName";
  
$PP_DirectPayment_required[1][$nextIndex] = "".((isset($_POST["firstname"]))?$_POST["firstname"]:"")  ."";
  
$nextIndex count($PP_DirectPayment_required[0]);
  
$PP_DirectPayment_required[0][$nextIndex] = "LastName";
  
$PP_DirectPayment_required[1][$nextIndex] = "".((isset($_POST["lastname"]))?$_POST["lastname"]:"")  ."";
  
$nextIndex count($PP_DirectPayment_required[0]);
  
$PP_DirectPayment_required[0][$nextIndex] = "Street1";
  
$PP_DirectPayment_required[1][$nextIndex] = "".((isset($_POST["street1"]))?$_POST["street1"]:"")  ."";
  
$nextIndex count($PP_DirectPayment_required[0]);
  
$PP_DirectPayment_required[0][$nextIndex] = "CityName";
  
$PP_DirectPayment_required[1][$nextIndex] = "".((isset($_POST["city"]))?$_POST["city"]:"")  ."";
  
$nextIndex count($PP_DirectPayment_required[0]);
  
$PP_DirectPayment_required[0][$nextIndex] = "StateOrProvince";
  
$PP_DirectPayment_required[1][$nextIndex] = "".((isset($_POST["state_province"]))?$_POST["state_province"]:"")  ."";
  
$nextIndex count($PP_DirectPayment_required[0]);
  
$PP_DirectPayment_required[0][$nextIndex] = "PostalCode";
  
$PP_DirectPayment_required[1][$nextIndex] = "".((isset($_POST["postcode"]))?$_POST["postcode"]:"")  ."";
  
$nextIndex count($PP_DirectPayment_required[0]);
  
$PP_DirectPayment_required[0][$nextIndex] = "Country";
  
$PP_DirectPayment_required[1][$nextIndex] = "".((isset($_POST["country"]))?$_POST["country"]:"")  ."";
  
$nextIndex count($PP_DirectPayment_required[0]);
  
$PP_DirectPayment_required[0][$nextIndex] = "UseSandbox";
  
$PP_DirectPayment_required[1][$nextIndex] = "".($WAGLOBAL_Paypal_Sandbox == 1)?"true":"false"  ."";

  
$PP_DirectPayment_itemized[0][0] = "OrderTotal";
  
$PP_DirectPayment_itemized[1][0] = "".$WA_Store_Cart->GrandTotal()  ."";
  
$PP_DirectPayment_itemized[0][1] = "OrderDescription";
  
$PP_DirectPayment_itemized[1][1] = "";
  while ( !
$WA_Store_Cart->EOF() )      {
  
$nextIndex count($PP_DirectPayment_itemized[0]);
  
$PP_DirectPayment_itemized[0][$nextIndex] = "Amount" strval($cartIndex+1) . "";
  
$PP_DirectPayment_itemized[1][$nextIndex] = "".$WA_Store_Cart->DisplayInfo("Price")  ."";
  
$nextIndex count($PP_DirectPayment_itemized[0]);
  
$PP_DirectPayment_itemized[0][$nextIndex] = "Name" strval($cartIndex+1) . "";
  
$PP_DirectPayment_itemized[1][$nextIndex] = "".$WA_Store_Cart->DisplayInfo("Name")  ."";
  
$nextIndex count($PP_DirectPayment_itemized[0]);
  
$PP_DirectPayment_itemized[0][$nextIndex] = "Number" strval($cartIndex+1) . "";
  
$PP_DirectPayment_itemized[1][$nextIndex] = "".$WA_Store_Cart->DisplayInfo("ID")  ."";
  
$nextIndex count($PP_DirectPayment_itemized[0]);
  
$PP_DirectPayment_itemized[0][$nextIndex] = "Quantity" strval($cartIndex+1) . "";
  
$PP_DirectPayment_itemized[1][$nextIndex] = "".$WA_Store_Cart->DisplayInfo("Quantity")  ."";

    
$WA_Store_Cart->MoveNext();
    
$cartIndex ++;
  }
  
$WA_Store_Cart->MoveFirst();
  
$nextIndex count($PP_DirectPayment_optional[0]);
  
$PP_DirectPayment_optional[0][$nextIndex] = "MerchantSessionID";
  
$PP_DirectPayment_optional[1][$nextIndex] = "".session_id()  ."";
  
$nextIndex count($PP_DirectPayment_optional[0]);
  
$PP_DirectPayment_optional[0][$nextIndex] = "Payer";
  
$PP_DirectPayment_optional[1][$nextIndex] = "".((isset($_POST["email"]))?$_POST["email"]:"")  ."";
  
$nextIndex count($PP_DirectPayment_optional[0]);
  
$PP_DirectPayment_optional[0][$nextIndex] = "Street2";
  
$PP_DirectPayment_optional[1][$nextIndex] = "".((isset($_POST["street2"]))?$_POST["street2"]:"")  ."";
  
$nextIndex count($PP_DirectPayment_optional[0]);
  
$PP_DirectPayment_optional[0][$nextIndex] = "Phone";
  
$PP_DirectPayment_optional[1][$nextIndex] = "".((isset($_POST["phone"]))?$_POST["phone"]:"")  ."";
  
$nextIndex count($PP_DirectPayment_optional[0]);
  
$PP_DirectPayment_optional[0][$nextIndex] = "CVV2";
  
$PP_DirectPayment_optional[1][$nextIndex] = "".((isset($_POST["cvv"]))?$_POST["cvv"]:"")  ."";
  
$nextIndex count($PP_DirectPayment_optional[0]);
  
$PP_DirectPayment_optional[0][$nextIndex] = "ItemTotal";
  
$PP_DirectPayment_optional[1][$nextIndex] = "".$WA_Store_Cart->TotalColumn("TotalPrice")  ."";
  
$nextIndex count($PP_DirectPayment_optional[0]);
  
$PP_DirectPayment_optional[0][$nextIndex] = "ShippingTotal";
  
$PP_DirectPayment_optional[1][$nextIndex] = "".$WA_Store_Cart->GetShipping()  ."";
  
$nextIndex count($PP_DirectPayment_optional[0]);
  
$PP_DirectPayment_optional[0][$nextIndex] = "HandlingTotal";
  
$PP_DirectPayment_optional[1][$nextIndex] = "".$WA_Store_Cart->GetCharges() - $WA_Store_Cart->GetDiscounts()  ."";
  
$nextIndex count($PP_DirectPayment_optional[0]);
  
$PP_DirectPayment_optional[0][$nextIndex] = "TaxTotal";
  
$PP_DirectPayment_optional[1][$nextIndex] = "".$WA_Store_Cart->GetTax()  ."";
  
$nextIndex count($PP_DirectPayment_optional[0]);
  
$PP_DirectPayment_optional[0][$nextIndex] = "SH_Name";
    
$PP_DirectPayment_optional[1][$nextIndex] = "".((isset($_POST["shipping_firstname"]))?$_POST["shipping_firstname"]:"") ." ".((isset($_POST["shipping_lastname"]))?$_POST["shipping_lastname"]:"") ."";
  
$nextIndex count($PP_DirectPayment_optional[0]);
  
$PP_DirectPayment_optional[0][$nextIndex] = "SH_Street1";
  
$PP_DirectPayment_optional[1][$nextIndex] = "".((isset($_POST["shipping_street1"]))?$_POST["shipping_street1"]:"")  ."";
  
$nextIndex count($PP_DirectPayment_optional[0]);
  
$PP_DirectPayment_optional[0][$nextIndex] = "SH_Street2";
  
$PP_DirectPayment_optional[1][$nextIndex] = "".((isset($_POST["shipping_street2"]))?$_POST["shipping_street2"]:"")  ."";
  
$nextIndex count($PP_DirectPayment_optional[0]);
  
$PP_DirectPayment_optional[0][$nextIndex] = "SH_CityName";
  
$PP_DirectPayment_optional[1][$nextIndex] = "".((isset($_POST["shipping_city"]))?$_POST["shipping_city"]:"")  ."";
  
$nextIndex count($PP_DirectPayment_optional[0]);
  
$PP_DirectPayment_optional[0][$nextIndex] = "SH_StateOrProvince";
  
$PP_DirectPayment_optional[1][$nextIndex] = "".((isset($_POST["shipping_state_province"]))?$_POST["shipping_state_province"]:"")  ."";
  
$nextIndex count($PP_DirectPayment_optional[0]);
  
  
$WAGatewayResponse PP_DirectPayment_Post($PP_DirectPayment_required,$PP_DirectPayment_itemized,$PP_DirectPayment_optional);
  if (
$WAGatewayResponse)  {
    
$WA_Store_Cart->redirStr "checkout_success.php";
  }
  else if (
"checkout_failured.php" != "") {
    
header("Location: ""checkout_failure.php");
    exit();
  }
}
?>




and place an if statement around it so the transaction will only be sent to the gateway if the COD option is not selected:

php:
<?php if(isset($_POST["cashondelivery"]) && $_POST["cashondelivery"] != "1") { ?>

< Local Checkout code block>
<?php } else { $WA_Store_Cart->redirStr "checkout_success.php"; } ?>




in the last line of the code above, replace WA_Store_Cart with the name of your eCart object.

Sign in to reply to this post

Maplemac

Not using PayPal Pro

Hi Jason
I'm not using PayPal Pro but PayPal Standard in Canada so I don't have that code.
I've attached my confirm.php

Where should I place the code?
Thanks

Attached Files
confirm.zip
Sign in to reply to this post

Jason ByrnesWebAssist

with paypal standard, the forms action posts directly to the paypal servers. The if statement will go around the form tag:

php:
<?php if(isset($_POST["cashondelivery"]) && $_POST["cashondelivery"] != "1") { ?> 
<form name="checkout_PP_LI_Hid"  action="checkout_success.php" method="post">
<?php } else { ?>
<form name="checkout_PP_LI_Hid"  action="https://www.PayPal.com/cgi-bin/webscr" method="post">
<?php ?>
Sign in to reply to this post

Maplemac

Confirm page just hangs

Hi Jason
When I make this change and add the code to the confirm.php page when I enter the checkout info on the checkout page and click checkout the confirm page just hangs (white screen)
Is there something else I need to do?
Thanks

Sign in to reply to this post

Jason ByrnesWebAssist

sorry, the original code had a slight synatx error, it should be:

php:
<?php if(isset($_POST["cashondelivery"]) && $_POST["cashondelivery"] != "1") { ?> 

<form name="checkout_PP_LI_Hid"  action="checkout_success.php" method="post">
<?php } else { ?>
<form name="checkout_PP_LI_Hid"  action="https://www.PayPal.com/cgi-bin/webscr" method="post">
<?php ?>
Sign in to reply to this post

Maplemac

Still not working

Hi Jason
Thanks that now gets the confirm.php page to show but when I click on the checkout button on the confirm page (with the cash on delivery box checked on the checkout page) it still takes me to the PayPal site.
Is there anything else I need to add?
Thanks

Sign in to reply to this post

Jason ByrnesWebAssist

try changing the if statement to:
<?php if(isset($_POST["cashondelivery"]) && $_POST["cashondelivery"] == "1") { ?>

Sign in to reply to this post

Maplemac

Not reporting info

Hi Jason
That did the trick. I have now added Universal Email to the checkout_success.php
It sends by email all the information apart from the Billing and Shipping info.
For some reason it sends Billing Info: Town & Billing Info: Country but nothing else.

So close to finishing this prpject if you could help with this :)
Thanks
I've attached the WAUE file

Attached Files
waue_checkout_success_1.zip
Sign in to reply to this post

Jason ByrnesWebAssist

on your confirm page, there are hidden form elements to capture the shipping info that was entered on the chedckout page:
<input type="hidden" name="first_name" id="first_name" value="<?php echo((isset($_POST["shipping_firstname"]))?$_POST["shipping_firstname"]:"") ?>" />
<input type="hidden" name="last_name" id="last_name" value="<?php echo((isset($_POST["shipping_lastname"]))?$_POST["shipping_lastname"]:"") ?>" />
<input type="hidden" name="address1" id="address1" value="<?php echo((isset($_POST["shipping_street1"]))?$_POST["shipping_street1"]:"") ?>" />
<input type="hidden" name="address2" id="address2" value="<?php echo((isset($_POST["shipping_street2"]))?$_POST["shipping_street2"]:"") ?>" />
<input type="hidden" name="city" id="city" value="<?php echo((isset($_POST["shipping_city"]))?$_POST["shipping_city"]:"") ?>" />
<input type="hidden" name="state" id="state" value="<?php echo((isset($_POST["shipping_state_province"]))?$_POST["shipping_state_province"]:"") ?>" />
<input type="hidden" name="zip" id="zip" value="<?php echo((isset($_POST["shipping_postcode"]))?$_POST["shipping_postcode"]:"") ?>" />
<input type="hidden" name="country" id="country" value="<?php echo((isset($_POST["country"]))?$_POST["country"]:"") ?>" />


but there are no hidden form elements to capture the billing info that was entered.

the email can only use form elements that exist on the confirm page.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...