Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
preselects the same as billing checkbox for WP ecommerce
/**
* Defaults customer meta for shipping same as billing.
*
* Means that by default we say that billing and shipping match so just hide the stuff
* about shipping unless the user unselects the box.
*
* @author SFNdesign, Curtis McHale
* @link sfndesign.ca
*
* @param null $value A null flag.
* @param string $key The meta key being passed to the customer meta API.
* @param int $id The current user/customer/visitor ID.
* @return string|null The meta value, or null, if unmodified.
*/
function elite_default_same_billing( $value, $key = '', $id = '' ) {
remove_filter( 'wpsc_get_visitor_meta_shippingSameBilling', __FUNCTION__, 15 );
$current_value = wpsc_get_customer_meta( 'shippingSameBilling' );
add_filter( 'wpsc_get_visitor_meta_shippingSameBilling', __FUNCTION__, 15 );
// the checkout check makes sure that as someone actually makes a purchase we don't override
// any settings changes they just made during the purchase.
if ( wpsc_is_checkout() ){
if ( '' !== $current_value ){
} else {
$value = 'on';
}
}
}
add_filter( 'wpsc_get_visitor_meta_shippingSameBilling', 'elite_default_same_billing', 15, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment