Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This removes the title entirely to get rid of a duplicate sentence, resolving at the same time a <h2> problem...
<?php
/**
* Remove the WooCommerce Local Pickup Time plugin checkout page select field title.
*
* @see https://github.com/WC-Local-Pickup/woocommerce-local-pickup-time/issues/103
* @see https://github.com/WC-Local-Pickup/woocommerce-local-pickup-time/issues/104
*/
if ( class_exists( 'Local_Pickup_Time' ) ) {
// Remove the default local pickup time field from the checkout page.
remove_action( apply_filters( 'local_pickup_time_select_location', 'woocommerce_after_order_notes' ), array( Local_Pickup_Time::get_instance(), 'time_select') );
// And add this custom one.
add_action( apply_filters( 'local_pickup_time_select_location', 'woocommerce_after_order_notes' ), 'my_custom_time_select' );
/**
* Add the local pickup time field to the checkout page
*
* @param object $checkout The checkout object.
*/
function my_custom_time_select( $checkout ) {
echo '<div id="local-pickup-time-select">';
$lpt = Local_Pickup_Time::get_instance();
woocommerce_form_field(
'local_pickup_time_select',
array(
'type' => 'select',
'class' => array( 'local-pickup-time-select-field form-row-wide' ),
'label' => __( 'Pickup Time', 'woocommerce-local-pickup-time' ),
'required' => true,
'options' => $lpt->build_pickup_time_options(),
),
$checkout->get_value( 'local_pickup_time_select' )
);
echo '</div>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.