true, 'has_archive' => false, 'label' => 'Updates', 'show_ui' => true, 'supports' => array('title', 'editor', 'thumbnail') ); register_post_type( 'isl_updates', $args ); $args = array( 'public' => true, 'has_archive' => false, 'label' => 'Testimonials', 'show_ui' => true, 'supports' => array('title', 'editor', 'thumbnail') ); register_post_type( 'isl_testimonials', $args ); } add_action( 'init', 'isl_init' ); function get_post_thumbnail_url($id, $size = 'large') { $thumb_url = false; if( has_post_thumbnail($id) ) { $thumb_id = get_post_thumbnail_id($id); $thumb_url_array = wp_get_attachment_image_src($thumb_id, $size, true); $thumb_url = $thumb_url_array[0]; } return $thumb_url; } function new_excerpt_more($more) { return '...'; } add_filter('excerpt_more', 'new_excerpt_more'); function pr($d) { echo '
';
  var_dump($d);
  echo '
'; } add_filter('embed_oembed_html','isl_oembed', 10, 2); function isl_oembed($return, $data) { return '
' . $return . '
'; } function isl_excerpt_length( $length ) { return 60; } add_filter( 'excerpt_length', 'isl_excerpt_length', 999 ); add_filter( 'woocommerce_square_sync_from_square_description', '__return_true' ); add_action( 'woocommerce_square_inventory_poll', function(){ $square = new WC_Square_Sync_From_Square(); $square->sync_all_inventory(); } ); add_filter( 'woocommerce_billing_fields' , 'isl_override_default_billing_fields' ); // Our hooked in function - $address_fields is passed via the filter! function isl_override_default_billing_fields( $fields ) { unset($fields['billing_address_1']); unset($fields['billing_address_2']); unset($fields['billing_company']); unset($fields['billing_city']); //unset($fields['billing_postcode']); unset($fields['billing_state']); return $fields; } add_filter( 'woocommerce_checkout_fields' , 'isl_override_checkout_fields' ); // Our hooked in function - $fields is passed via the filter! function isl_override_checkout_fields( $fields ) { $fields['order']['pickup_date'] = [ 'label' => __('Pickup Date', 'woocommerce'), 'placeholder' => _x('Select a Date', 'placeholder', 'woocommerce'), 'required' => true, 'class' => ['form-row-wide datepicker'], 'autocomplete' => 'off', 'clear' => true ]; $fields['order']['pickup_time'] = [ 'type' => 'select', 'options' => [ '' => '- Select Time -', '700' => '7:00am - 8:00am', '800' => '8:00am - 9:00am', '900' => '9:00am - 10:00am', '1000' => '10:00am - 11:00am', '1100' => '11:00am - 12:00pm', '1200' => '12:00pm - 1:00pm', '1300' => '1:00pm - 2:00pm', '1400' => '2:00pm - 3:00pm', '1500' => '3:00pm - 4:00pm', '1600' => '4:00pm - 5:00pm', '1700' => '5:00pm - 6:00pm' ], 'label' => __('Pickup Time', 'woocommerce'), 'required' => true, 'class' => ['form-row-wide'], 'autocomplete' => 'off', 'clear' => true ]; $comments = $fields['order']['order_comments']; unset($fields['order']['order_comments']); $comments['placeholder'] = 'Special notes about your order'; $fields['order']['order_comments'] = $comments; return $fields; } add_action( 'woocommerce_admin_order_data_after_shipping_address', 'isl_custom_checkout_field_display_admin_order_meta', 10, 1 ); function isl_custom_checkout_field_display_admin_order_meta($order){ $pickup_time = isl_value_to_time(get_post_meta( $order->get_id(), '_pickup_time', true )); echo '

'.__('Pickup Date').': ' . get_post_meta( $order->get_id(), '_pickup_date', true ) . '

'; echo '

'.__('Pickup Time').': ' . $pickup_time . '

'; } function social_content($content) { $content = nl2br(linkify($content)); return $content; } function linkify($value, $protocols = array('http', 'mail'), array $attributes = array('target' => '_blank')) { // Link attributes $attr = ''; foreach ($attributes as $key => $val) { $attr = ' ' . $key . '="' . htmlentities($val) . '"'; } $links = array(); // Extract existing links and tags $value = preg_replace_callback('~(.*?|<.*?>)~i', function ($match) use (&$links) { return '<' . array_push($links, $match[1]) . '>'; }, $value); // Extract text links for each protocol foreach ((array)$protocols as $protocol) { switch ($protocol) { case 'http': case 'https': $value = preg_replace_callback('~(?:(https?)://([^\s<]+)|(www\.[^\s<]+?\.[^\s<]+))(?$link") . '>'; }, $value); break; case 'mail': $value = preg_replace_callback('~([^\s<]+?@[^\s<]+?\.[^\s<]+)(?{$match[1]}") . '>'; }, $value); break; case 'twitter': $value = preg_replace_callback('~(?{$match[0]}") . '>'; }, $value); break; default: $value = preg_replace_callback('~' . preg_quote($protocol, '~') . '://([^\s<]+?)(?{$match[1]}") . '>'; }, $value); break; } } // Insert all link return preg_replace_callback('/<(\d+)>/', function ($match) use (&$links) { return $links[$match[1] - 1]; }, $value); } require_once('functions/ajax.php'); require_once('functions/admin.php'); remove_action('woocommerce_proceed_to_checkout','woocommerce_button_proceed_to_checkout', 20); add_action( 'woocommerce_proceed_to_checkout', 'isl_button_proceed_to_checkout', 10 ); function isl_button_proceed_to_checkout() { $cart_total = WC()->cart->subtotal; echo '
'; if( $cart_total >= 15 ) { echo 'Proceed to checkout'; } else { echo '

Minimum order of $15 to order online.

'; } echo '
'; } add_action( 'woocommerce_checkout_create_order', function( $order, $data ) { $custom_fields = array( 'pickup_date', 'pickup_time' ); foreach ( $custom_fields as $field_name ) { if ( isset( $data[ $field_name ] ) ) { $meta_key = '_' . $field_name; $field_value = $data[ $field_name ]; // WC will handle sanitation $order->update_meta_data( $meta_key, $field_value ); } } }, 10, 2 ); function action_woocommerce_email_order_details( $order, $sent_to_admin, $plain_text, $email ) { $pickup_date = get_post_meta( $order->id, '_pickup_date', true ); $pickup_time = isl_value_to_time(get_post_meta( $order->get_id(), '_pickup_time', true )); echo '

Pickup Date: ' . $pickup_date . '

'; echo '

Pickup Time: ' . $pickup_time . '

'; }; // add the action add_action( 'woocommerce_email_order_details', 'action_woocommerce_email_order_details', 10, 4 ); function isl_value_to_time($value) { $time_slots = [ '700' => '7:00am - 8:00am', '800' => '8:00am - 9:00am', '900' => '9:00am - 10:00am', '1000' => '10:00am - 11:00am', '1100' => '11:00am - 12:00pm', '1200' => '12:00pm - 1:00pm', '1300' => '1:00pm - 2:00pm', '1400' => '2:00pm - 3:00pm', '1500' => '3:00pm - 4:00pm', '1600' => '4:00pm - 5:00pm', '1700' => '5:00pm - 6:00pm' ]; return $time_slots[$value]; } ?>
cart->subtotal < 15 ): ?>

Order minimum is $15.

Click here to stuff your bag with more deliciousness.