Call us Toll-Free:
1-800-218-1525
Live ChatEmail us

 Sponsors

How to: Implement One Click to Order

Dawn Rossi, 08-27-2008
One click to order is a feature that allows your customers to place an order on your website, without having to retype their credit card information every single time.

Amazon.com was one of the first websites to implement One Click Shopping and they filed a patent for this process back on September 1999.

These days all major shopping carts support a variation of Amazon's One Click to Order, making it easier for customers to place repeat orders.

As part of this post, I will describe the process of implementing One Click to Order (also known as: "Background checkout") with the SoftwareProjects Shopping cart.

Step 1: Integrate spicart.php

Login to your SoftwareProjects account, click on the Product Manager and then select the Integrate menu item.

Complete all fields and generate your custom spicart.php file

Save spicart.php on your website and include it on all pages.

For example, on your index.php file:


// Specify product codename offered on this page
// (If applicable)
$product_codename = "my_first_product"; // Replace with your codename

// Include shopping cart
require_once($DOCUMENT_ROOT."/spicart.php");

// Your HTML code here
// ...

// Track everything
track();
 

Step 2: Capture customer payment information

Before you can offer One Click to Order, you have to capture your customer's payment information (credit card) at least once.

The customer payment information will then be saved in your SoftwareProjects database so that any upsell products can be offered with One click to Order.

In addition to upsells, customers who return to your website and login (with their email address and password) are also going to be able to take advantadge of the One Click to Order feature.

To capture customer payment information, you need to add a single checkout form to the first page of your checkout process:


// If submitted order for processing
if (Strcasecmp($_POST['action'],'checkout')==0)
{
   
// Populate input variables
   
$input = array();
   
$input['store_id'] = 2; // Replace with your store id
   
$input['product_codename'] = $product_codename;

   
// Charge customer
    // If failed - error code will be set into $ResultStr
   
if (do_checkout($input, &$output, &$ResultStr))
    {       
       
// If successful, redirect
       
Header("Location: upsell.php"); // Replace with your upsell page
       
return;
    }
}

// Your HTML code here
// ...

// Populate input variables
$input = array();
$input['product_codename'] = $product_codename;
$input['emailaddress'] = $emailaddress;
$input['ResultStr'] = $ResultStr;

// Print checkout form           
print_checkoutform($input);
 

Step 3: One Click to Order

Now that you've captured the customer's payment information, implementing One Click to Order is as easy as calling a single function.

The customer's payment information will be stored as part of the session variables.

To implement One click to Order, display product information on your HTML page, inviting customer to take advantadge of any upsell offers. The target url will handle placing an order in the background without requiring any customer input (also known as: "Background checkout")

For example:

Code for upsell.php page:


Thank you
for ordering our product!
<
BR><BR>
To add XYZ to your order, for a low $9.95,
<
a href="upsell_doit.php">click here</a>
 

Code for upsell_doit.php page:


// Populate input variables
$input = array();
$input['product_codename'] = $product_codename;
$input['store_id'] = 2; // Replace with store ID

// Background checkout
if (do_backgroundcheckout($input, &$output, &$ResultStr))
{
   
Header("Location: thanks_upsell.php"); // Replace with upsell thank you page
}
 

-

All set. You now know how to offer your customers a One Click to Order interface, using the SoftwareProjects Shopping cart.

Before I wrap this post, I would like to leave you with another example -

In this scenario we will be incorporating the upsell offer into the main checkout screen, so that the customer can opt-in to the upsell as part of placing the first order:



To implement this process-flow, we will use a similar script, however in this case we are going to incorporate the background checkout as part of the main index.php file:


// If submitted order for processing
if (Strcasecmp($_POST['action'],'checkout')==0)
{
   
// Populate input variables
     
$input = array();
   
$input['store_id'] = 2; // Replace with your store id
   
$input['product_codename'] = $product_codename;
 
   
// Charge customer
    // If failed - error code will be set into $ResultStr
     
if (do_checkout($input, &$output, &$ResultStr))
    {       
       
// If customer opted-in for the upsell
       
if (isset($_POST['upsell']))
        {
         
// Populate input variables
         
$input = array();
         
$input['store_id'] = 2; // Replace with store id
         
$input['product_codename'] = "upsell_product"; // Replace with upsell codename
       
$input['force_shipping'] = 1; // Populate default shipping address
        // Background checkout
       
if (!do_backgroundcheckout($input, &$output, &$ResultStr))
        {
        }
 
        }
                 
       
// If successful, redirect
       
Header("Location: thanks.php"); // Replace with thankyou page
       
return;
    }
}

// Your HTML code here
// ...

// Populate input variables
$input = array();
$input['product_codename'] = $product_codename;
$input['emailaddress'] = $emailaddress;
$input['ResultStr'] = $ResultStr;
$input['screen'] = "checkout_upsell"; // Replace with name of your checkout screen

// Print checkout form           
print_checkoutform($input);
 

Notice I am passing a new screen (checkout_upsell) to the print checkout form function. The new checkout screen includes the upsell checkbox:


<input type='checkbox' name='upsell'/>
               
<
U><span class='checkbox3'>Check this box</span></U> if you would like to add a private membership to ...

 

-

Any questions? Please comment below or contact us directly.

peter matarazzo, 07-20-2013
PO # 53358 and 53361 dated 7/20/13
PLEASE CANCEL AT ONCE.
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

 Comments
Post your comments












Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.



About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions