Skip to content

Instantly share code, notes, and snippets.

@EHLOVader
Forked from GreatPotato/gist:3225912
Last active October 7, 2015 21:18
Show Gist options
  • Save EHLOVader/3227100 to your computer and use it in GitHub Desktop.
Save EHLOVader/3227100 to your computer and use it in GitHub Desktop.
Set shipping method automatically in LemonStand
<?php
/**
* Default shipping during checkout
* This snippet when added to the pre_action will allow you to default shipping selection.
*
* This is mostly useful when there is only one shipping option, this allows you to skip
* the shipping step of checkout entirely, simplifying things for your customers.
*
* This has been updated to use a dynamic method of pulling the first available shipping
* option from your list of available shipping options.
*
*/
//Check to make sure we are on the shipping_info step.
//Shipping info is required for assignment of the shipping option.
if(post('checkout_step') == 'shipping_info')
{
$available_options = Shop_CheckoutData::list_available_shipping_options(Cms_Controller::get_customer());
if($available_options)
{
$indexes = array_keys($available_options);
Shop_CheckoutData::set_shipping_method($available_options[$indexes[0]]->sub_options[0]->id);
} else {
// Shop_CheckoutData::reset_shipping_method();
}
}
/* End of file pre_action.php */
/* Location: /store_checkout/pre_action.php */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment