Skip to content

Instantly share code, notes, and snippets.

@pmeissner
Created September 23, 2011 01:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmeissner/1236561 to your computer and use it in GitHub Desktop.
Save pmeissner/1236561 to your computer and use it in GitHub Desktop.
Moving from billing to pay in 1 step.
<?
function download_only_on_process_billing_address_place_order_and_pay($controller, $page, $params)
{
if (post('ship_to_billing_address'))
{
Shop_CheckoutData::copy_billing_to_shipping();
$controller->action();
}
Shop_CheckoutData::set_payment_method(Shop_PaymentMethod::find_by_api_code('default')->id);
// Call the default action handler
$controller->action();
// Pretend that we are on the Review checkout step
// to force LemonStand to place the order
$_POST['checkout_step'] = 'review';
$controller->action();
}
?>
<div class="copyBillingToShipping">
<input type="checkbox" name="ship_to_billing_address" value="1" checked />
<label for="Ship to the billing address">Ship to the billing address</label>
</div>
<? if (!$shipping_required): ?>
<style type="text/css">.copyBillingToShipping { visibility: hidden;}</style>
<button class="button" onclick="return $(this).getForm().sendRequest('download_only_on_process_billing_address_place_order_and_pay', {update:{'checkout_page': 'checkout_partial'}})">Next</button>
<? else: ?>
<button class="button" onclick="return $(this).getForm().sendRequest('on_process_billing_address', {update:{'checkout_page': 'checkout_partial'}})">Next</button>
<? endif ?>
<div class="copyBillingToShipping">
<input type="checkbox" name="ship_to_billing_address" value="1" checked />
<label for="Ship to the billing address">Ship to the billing address</label>
</div>
<? if (!$shipping_required): ?>
<style type="text/css">.copyBillingToShipping { visibility: hidden;}</style>
<button class="button" onclick="return $(this).getForm().sendRequest('download_only_on_process_billing_address_place_order_and_pay', {update:{'checkout_page': 'checkout_partial'}})">Next</button>
<? else: ?>
<button class="button" onclick="return $(this).getForm().sendRequest('on_process_billing_address', {update:{'checkout_page': 'checkout_partial'}})">Next</button>
<? endif ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment