Your account is limited to posting only in the Pre-Sales Questions forum.
Support forum access is limited to members with a purchase history.

If you are working on behalf of another member, please contact us with the name of the license holder and we will upgrade your account.
   
 
One Page Checkout
Posted: 25 February 2010 03:16 PM   [ Ignore ]
Administrator
Avatar
RankRankRank
Total Posts:  3369
Joined  2009-05-29

Let’s do a one page checkout. On the checkout page there will be a table of the items currently in the cart. The customer will be able to to change quantities and remove items from the cart. Below the table of items, there will be a checkout form, where the customer can enter their billing/shipping and payment info. We’re going to assume here that you already have a products weblog and you have set up a way for customers to add items to their carts.

Template: cart/checkout

<h1>One Page Checkout</h1>
{embed=cart/.nav}
<br />

{!-- One Page Checkout
This template adds a one page checkout
http
://cartthrob.com/docs/plugins/cartthrob/checkout_form/
The checkout form gathers values for payment processing and initiates processing payments.
There are lots of parameters availableA few of the key parameters are
cart_empty_redirect 
- If the cart is empty, this is where the user will be redirected
return - This is where the user will be redirected after the form submits.
allow_user_price - if you want to hard code items their prices in their formyou will need to set this to "yes" as a security measures

Example uses.
1. You can hard code products on this page, or put in a weblog:entries tag to output entries to this page to make a single page checkout form
2. Add products to the customers cart elsewhere, and use this template to solely take information and process orders
--}

<h2>Your Shopping Cart</h2>
{exp:cartthrob:view_cart}
{if no_results}
    There is nothing in your cart
{
/if}
{if first_row}
<form action="{path=cart/change_quantity}" method="post">
    <
table>
        <
thead>
            <
tr>
                <
td>Item</td>
                <
td colspan="2">Quantity</td>
            </
tr>
        </
thead>
        <
tbody>
{/if}
            
<tr>
                <
td>{title}</td>
                <
td>
                        <
input type="text" name="entry_ids[{entry_id}]" size="2" value="{quantity}" />
                </
td>
                <
td>
                    <
a href="{path=cart/delete_from_cart/{entry_id}}">Delete</a>
                </
td>
            </
tr>
{if last_row}
            
<tr>
                <
td colspan="2">&nbsp;</td>
                <
td>
                    
Subtotal{cart_subtotal}<br />
                    
Shipping{cart_shipping}<br />
                    
Tax{cart_tax}<br />
                    <
strong>Total{cart_total}</strong>
                </
td>
            </
tr>
        </
tbody>
    </
table>
    <
input type="submit" value="Update Quantities" />
</
form>
{/if}
{
/exp:cartthrob:view_cart}



{exp
:cartthrob:checkout_form return="cart/order_complete"}

{
!-- Use the gateway fields template variable to output fields required by your 
currently selected gateway
. If no fields are showingselect a gateway in the extension settings. --}
{gateway_fields}

<p>If no fields are showingthe testing gateway is probably selectedSubmitting with the testing gateway selected will save your order.</p>

<
input type="submit" value="Checkout" />

{/exp:cartthrob:checkout_form} 

You’ll also need to create a new template to change the quantities:

Template: cart/change_quantity

{exp:cartthrob:change_quantity redirect="cart/one_page_checkout"

You probably also want an order confirmation page:

Template: cart/order_complete

<h1>Your Order is complete</h1>

{embed=cart/.nav}

{exp
:cartthrob:order_info}
    {if authorized}
        Your payment is a success
!
        
Transaction ID{transaction_id}
        Your total
{cart_total}
        Your order ID
{order_id}
    {if
:elseif declined}
        Your credit card was declined
{error_message}
    {if
:elseif failed}
        Your payment failed
{error_message}
    {
/if}
{
/exp:cartthrob:order_info} 
[ Edited: 25 February 2010 03:20 PM by Rob Sanchez ]
Profile
 
 
Posted: 25 May 2010 06:35 AM   [ Ignore ]   [ # 1 ]
Is a Really Great Dancer
RankRank
Total Posts:  73
Joined  2010-05-07

Hi Rob -

I know I’m missing something obvious here, but I’ve been at it for a bit and can’t see it. I have my product weblog in place & the cart functionality working fine.

I’m trying to start working with the test gateway, using the sample code provided in the one page checkout template. I have selected Developer Payment Gateway Sample in Cartthrob. I created a template with the required sample fields and selected that for the {gateway_fields} template. I had also tried dynamically selecting the gateway in my checkout form.

At no point have I managed to render the checkout form… using the code from your example above, with the testing gateway selected, shouldn’t I get the submit button for testing purposes?

Any help appreciated,
thanks
Kevin

Profile
 
 
Posted: 25 May 2010 08:27 AM   [ Ignore ]   [ # 2 ]
Administrator
Avatar
RankRankRank
Total Posts:  3369
Joined  2009-05-29

If you look at your HTML source of the page, can you see whether or not the <form> is rendering at all? If not, that’s usually an indication that you’re logged out, at least on the front end. There is an instance in EE where you can be logged in to the CP and still appear logged out to the front end: if you’re logged in to the CP at http://domain.com and you visit your front end at http://www.domain.com you’l,l appear logged out. You can fix that by going to your Cookie Settings in EE and changing your cookie domain to .domain.com, which will trigger site-wide cookies. Or, you can set the User Must Be Logged In? setting in the CartThrob CP to No.

Profile
 
 
Posted: 25 May 2010 08:35 AM   [ Ignore ]   [ # 3 ]
Is a Really Great Dancer
RankRank
Total Posts:  73
Joined  2010-05-07

Thanks Rob - I knew I was missing something simple. Appreciate the help….

Kevin

Profile
 
 
Posted: 22 November 2010 11:46 AM   [ Ignore ]   [ # 4 ]
Is a Really Great Dancer
Avatar
RankRank
Total Posts:  83
Joined  2010-08-14

I’ve been working on a one page checkout for our current website. Take a look at: http://www.postbeeld.com/

Profile