/** * Output a list of variation attributes for use in the cart forms. * * @param array $args * @since 2.4.0 */ function pedal_dropdown_variation_attribute_options($args = array()) { $args = wp_parse_args($args, array('options' => false, 'attribute' => false, 'product' => false, 'selected' => false, 'name' => '', 'id' => '', 'class' => '', 'show_option_none' => __('Choose an option', 'woocommerce'))); $options = $args['options']; $product = $args['product']; $attribute = $args['attribute']; $name = $args['name'] ? $args['name'] : 'attribute_' . sanitize_title($attribute); $id = $args['id'] ? $args['id'] : sanitize_title($attribute); $class = $args['class']; if (empty($options) && !empty($product) && !empty($attribute)) { $attributes = $product->get_variation_attributes(); $options = $attributes[$attribute]; } echo '<select id="' . esc_attr($id) . '" class="' . esc_attr($class) . '" name="' . esc_attr($name) . '" data-attribute_name="attribute_' . esc_attr(sanitize_title($attribute)) . '">'; if ($args['show_option_none']) { echo '<option value="">' . esc_html($args['show_option_none']) . '</option>'; } if (!empty($options)) { if ($product && taxonomy_exists($attribute)) { // Get terms if this is a taxonomy - ordered. We need the names too. $terms = wc_get_product_terms($product->id, $attribute, array('fields' => 'all')); foreach ($terms as $term) { if (in_array($term->slug, $options)) { echo '<option value="' . esc_attr($term->slug) . '" ' . selected(sanitize_title($args['selected']), $term->slug, false) . '>' . apply_filters('woocommerce_variation_option_name', $term->name) . '</option>'; } } } else { foreach ($options as $option) { ///PEDAL MODIFICATION if ($product->id == 218) { $pedal_append = pedal_function_test_bookings_in_term(esc_attr($option)); $class = 'available'; if (!$pedal_append) { $disabled = 'disabled'; $pedal_append = 'FULLY BOOKED'; $class = 'booked'; } } // This handles < 2.4.0 bw compatibility where text attributes were not sanitized. $selected = sanitize_title($args['selected']) === $args['selected'] ? selected($args['selected'], sanitize_title($option), false) : selected($args['selected'], $option, false); echo '<option class="' . $class . '" value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html(apply_filters('woocommerce_variation_option_name', $option)) . ' ' . $pedal_append . '</option>'; } } } echo '</select>'; }
global $wpdb; $resources = array(); $posts = $wpdb->get_results($wpdb->prepare("\n\t\t\tSELECT posts.ID, posts.post_title\n\t\t\tFROM {$wpdb->prefix}wc_booking_relationships AS relationships\n\t\t\t\tLEFT JOIN {$wpdb->posts} AS posts\n\t\t\t\tON posts.ID = relationships.resource_id\n\t\t\tWHERE relationships.product_id = %d\n\t\t\tORDER BY sort_order ASC\n\t\t", $product_id)); $found = false; foreach ($posts as $resource) { if ($resource->ID == $resource_id) { $found = $resource; $found = new WC_Product_Booking_Resource($found, $product_id); } } //return $found; return count($posts); } //print_r(pedal_booking_get_product_resources( 326, 379 )); // testing if I can use funciton here pedal_function_test_bookings_in_term('Beginner'); echo '<br />'; //echo strtotime('+7 day', 1442620800); // testing order id generation etc. $term_order = new WC_Order(561); $term_items = $term_order->get_items(); while (list($var, $val) = each($term_items)) { // print "$var is";echo $val['product_id']; print"\n"; if ($val['product_id'] != 330) { $order_item_id = $var; } } //foreach($term_items as $term_items_key => $value) { // this so the order item isn't assigned to the race day foreach ($term_items as $term_item) { $sh_product_id = $term_item['product_id'];