Skip to content

Instantly share code, notes, and snippets.

@JustinSainton
Last active August 29, 2015 14:27
Show Gist options
  • Save JustinSainton/4d4098ff7828a686d8c1 to your computer and use it in GitHub Desktop.
Save JustinSainton/4d4098ff7828a686d8c1 to your computer and use it in GitHub Desktop.
Remove Shipping Fields on a Cart with no Shippable Items
<?php
function wpsc_hide_shipping_fields_if_no_shipping( $fields ) {
if ( wpsc_uses_shipping() || is_admin() ) {
return $fields;
}
foreach ( $fields as $index => $field ) {
if ( false !== strpos( $field->unique_name, 'shipping' ) || 'delivertoafriend' == $field->unique_name ) {
unset( $fields[ $index ] );
}
}
return array_values( $fields );
}
add_filter( 'wpsc_checkout_fields', 'wpsc_hide_shipping_fields_if_no_shipping' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment