/** * form_field method, returns the form html * @access public */ function form_field() { global $wpdb, $user_ID, $wpsc_customer_checkout_details; $saved_form_data = empty($wpsc_customer_checkout_details[$this->checkout_item->id]) ? null : $wpsc_customer_checkout_details[$this->checkout_item->id]; $an_array = ''; if (function_exists('wpsc_get_ticket_checkout_set')) { if ($this->checkout_item->checkout_set == wpsc_get_ticket_checkout_set()) { $an_array = '[]'; } } $output = ''; $delivery_country = wpsc_get_customer_meta('shippingcountry'); $billing_country = wpsc_get_customer_meta('billingcountry'); $delivery_region = wpsc_get_customer_meta('shippingregion'); $billing_region = wpsc_get_customer_meta('billingregion'); $meta_key = !empty($this->checkout_item->unique_name) ? $this->checkout_item->unique_name : sanitize_title($this->checkout_item->name) . '_' . $this->checkout_item->id; switch ($this->checkout_item->type) { case "address": case "delivery_address": case "textarea": $placeholder = apply_filters('wpsc_checkout_field_placeholder', apply_filters('wpsc_checkout_field_name', $this->checkout_item->name), $this->checkout_item); $output .= '<textarea data-wpsc-meta-key="' . $meta_key . '" title="' . $this->checkout_item->unique_name . '" class="text wpsc-visitor-meta" id="' . $this->form_element_id() . '" name="collected_data[' . $this->checkout_item->id . ']' . $an_array . '" placeholder="' . esc_attr($placeholder) . '" rows="3" cols="40" >' . esc_textarea((string) $saved_form_data) . '</textarea>'; break; case "checkbox": $options = $this->get_checkout_options($this->checkout_item->id); if ($options != '') { $i = mt_rand(); foreach ($options as $label => $value) { ?> <label> <input class="wpsc-visitor-meta" data-wpsc-meta-key="<?php echo $meta_key; ?> " <?php checked(in_array($value, (array) $saved_form_data)); ?> type="checkbox" name="collected_data[<?php echo esc_attr($this->checkout_item->id); ?> ]<?php echo $an_array; ?> []" value="<?php echo esc_attr($value); ?> " /> <?php echo esc_html($label); ?> </label> <?php } } break; case "country": $output = wpsc_country_list($this->checkout_item->id, null, $billing_country, $billing_region, $this->form_element_id()); break; case "delivery_country": $checkoutfields = true; $output = wpsc_country_list($this->checkout_item->id, null, $delivery_country, $delivery_region, $this->form_element_id(), $checkoutfields); break; case "select": $options = $this->get_checkout_options($this->checkout_item->id); if ($options != '') { $output = '<select class="wpsc-visitor-meta" data-wpsc-meta-key="' . $meta_key . '" name="collected_data[' . $this->checkout_item->id . ']"' . $an_array . '">'; $output .= "<option value='-1'>" . _x('Select an Option', 'Dropdown default when called within checkout class', 'wp-e-commerce') . "</option>"; foreach ((array) $options as $label => $value) { $value = esc_attr(str_replace(' ', '', $value)); $output .= "<option " . selected($value, $saved_form_data, false) . " value='" . esc_attr($value) . "'>" . esc_html($label) . "</option>\n\r"; } $output .= "</select>"; } break; case "radio": $options = $this->get_checkout_options($this->checkout_item->id); if ($options != '') { foreach ((array) $options as $label => $value) { ?> <label> <input class="wpsc-visitor-meta" data-wpsc-meta-key="<?php echo $meta_key; ?> " type="radio" <?php checked($value, $saved_form_data); ?> name="collected_data[<?php echo esc_attr($this->checkout_item->id); ?> ]<?php echo $an_array; ?> " value="<?php echo esc_attr($value); ?> " /> <?php echo esc_html($label); ?> </label> <?php } } break; case "text": case "city": case "delivery_city": case "email": case "coupon": default: if ($this->checkout_item->unique_name == 'shippingstate') { $output .= wpsc_checkout_shipping_state_and_region($this); } elseif ($this->checkout_item->unique_name == 'billingstate') { $output .= wpsc_checkout_billing_state_and_region($this); } else { $placeholder = apply_filters('wpsc_checkout_field_placeholder', apply_filters('wpsc_checkout_field_name', $this->checkout_item->name), $this->checkout_item); $output = '<input data-wpsc-meta-key="' . $meta_key . '" title="' . $meta_key . '" type="text" id="' . $this->form_element_id() . '" class="text wpsc-visitor-meta" placeholder="' . esc_attr($placeholder) . '" value="' . esc_attr($saved_form_data) . '" name="collected_data[' . $this->checkout_item->id . ']' . $an_array . '" />'; } break; } return $output; }
/** * form_field method, returns the form html * @access public */ function form_field() { global $wpdb, $user_ID, $wpsc_customer_checkout_details; if ($user_ID > 0) { $delivery_country_id = wpsc_get_country_form_id_by_type('delivery_country'); $billing_country_id = wpsc_get_country_form_id_by_type('country'); } $saved_form_data = empty($wpsc_customer_checkout_details[$this->checkout_item->id]) ? null : $wpsc_customer_checkout_details[$this->checkout_item->id]; $an_array = ''; if (function_exists('wpsc_get_ticket_checkout_set')) { if ($this->checkout_item->checkout_set == wpsc_get_ticket_checkout_set()) { $an_array = '[]'; } } $output = ''; $delivery_country = wpsc_get_customer_meta('shipping_country'); $billing_country = wpsc_get_customer_meta('billing_country'); $delivery_region = wpsc_get_customer_meta('shipping_region'); $billing_region = wpsc_get_customer_meta('billing_region'); switch ($this->checkout_item->type) { case "address": case "delivery_address": case "textarea": $output .= "<textarea title='" . $this->checkout_item->unique_name . "' class='text' id='" . $this->form_element_id() . "' name='collected_data[{$this->checkout_item->id}]" . $an_array . "' rows='3' cols='40' >" . esc_html((string) $saved_form_data) . "</textarea>"; break; case "checkbox": $options = $this->get_checkout_options($this->checkout_item->id); if ($options != '') { $i = mt_rand(); foreach ($options as $label => $value) { ?> <label> <input <?php checked(in_array($value, (array) $saved_form_data)); ?> type="checkbox" name="collected_data[<?php echo esc_attr($this->checkout_item->id); ?> ]<?php echo $an_array; ?> []" value="<?php echo esc_attr($value); ?> " /> <?php echo esc_html($label); ?> </label> <?php } } break; case "country": $output = wpsc_country_region_list($this->checkout_item->id, false, $billing_country, $billing_region, $this->form_element_id()); break; case "delivery_country": if (wpsc_uses_shipping()) { $country_name = $wpdb->get_var($wpdb->prepare("SELECT `country` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `isocode`= %s LIMIT 1", $delivery_country)); $output = "<input title='" . $this->checkout_item->unique_name . "' type='hidden' id='" . $this->form_element_id() . "' class='shipping_country' name='collected_data[{$this->checkout_item->id}]' value='" . esc_attr($delivery_country) . "' size='4' /><span class='shipping_country_name'>" . $country_name . "</span> "; } else { $checkoutfields = true; $output = wpsc_country_region_list($this->checkout_item->id, false, $delivery_country, $delivery_region, $this->form_element_id(), $checkoutfields); } break; case "select": $options = $this->get_checkout_options($this->checkout_item->id); if ($options != '') { $output = "<select name='collected_data[{$this->checkout_item->id}]" . $an_array . "'>"; $output .= "<option value='-1'>" . _x('Select an Option', 'Dropdown default when called within checkout class', 'wpsc') . "</option>"; foreach ((array) $options as $label => $value) { $value = esc_attr(str_replace(' ', '', $value)); $output .= "<option " . selected($value, $saved_form_data, false) . " value='" . esc_attr($value) . "'>" . esc_html($label) . "</option>\n\r"; } $output .= "</select>"; } break; case "radio": $options = $this->get_checkout_options($this->checkout_item->id); if ($options != '') { foreach ((array) $options as $label => $value) { ?> <label> <input type="radio" <?php checked($value, $saved_form_data); ?> name="collected_data[<?php echo esc_attr($this->checkout_item->id); ?> ]<?php echo $an_array; ?> " value="<?php echo esc_attr($value); ?> " /> <?php echo esc_html($label); ?> </label> <?php } } break; case "text": case "city": case "delivery_city": case "email": case "coupon": default: if ($this->checkout_item->unique_name == 'shippingstate') { if (wpsc_uses_shipping() && wpsc_has_regions($delivery_country)) { $region_name = $wpdb->get_var($wpdb->prepare("SELECT `name` FROM `" . WPSC_TABLE_REGION_TAX . "` WHERE `id`= %d LIMIT 1", $delivery_region)); $output = "<input title='" . $this->checkout_item->unique_name . "' type='hidden' id='" . $this->form_element_id() . "' class='shipping_region' name='collected_data[{$this->checkout_item->id}]' value='" . esc_attr($delivery_region) . "' size='4' /><span class='shipping_region_name'>" . esc_html($region_name) . "</span> "; } else { $disabled = ''; if (wpsc_disregard_shipping_state_fields()) { $disabled = 'disabled = "disabled"'; } $output = "<input class='shipping_region text' title='" . $this->checkout_item->unique_name . "' type='text' id='" . $this->form_element_id() . "' value='" . esc_attr($saved_form_data) . "' name='collected_data[{$this->checkout_item->id}]" . $an_array . "' " . $disabled . " />"; } } elseif ($this->checkout_item->unique_name == 'billingstate') { $disabled = ''; if (wpsc_disregard_billing_state_fields()) { $disabled = 'disabled = "disabled"'; } $output = "<input class='billing_region text' title='" . $this->checkout_item->unique_name . "' type='text' id='" . $this->form_element_id() . "' value='" . esc_attr($saved_form_data) . "' name='collected_data[{$this->checkout_item->id}]" . $an_array . "' " . $disabled . " />"; } else { $output = "<input title='" . $this->checkout_item->unique_name . "' type='text' id='" . $this->form_element_id() . "' class='text' value='" . esc_attr($saved_form_data) . "' name='collected_data[{$this->checkout_item->id}]" . $an_array . "' />"; } break; } return $output; }
/** * form_field method, returns the form html * @access public */ function form_field() { global $wpdb, $user_ID; if ($user_ID > 0) { if (!isset($_SESSION['wpsc_checkout_saved_values'])) { $_SESSION['wpsc_checkout_saved_values'] = get_user_meta($user_ID, 'wpshpcrt_usr_profile', 1); } $delivery_country_id = wpsc_get_country_form_id_by_type('delivery_country'); $billing_country_id = wpsc_get_country_form_id_by_type('country'); } $saved_form_data = @htmlentities(stripslashes((string) $_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id]), ENT_QUOTES, 'UTF-8'); $an_array = ''; if (function_exists('wpsc_get_ticket_checkout_set')) { if ($this->checkout_item->checkout_set == wpsc_get_ticket_checkout_set()) { $an_array = '[]'; } } switch ($this->checkout_item->type) { case "address": case "delivery_address": case "textarea": $output = "<textarea title='" . $this->checkout_item->unique_name . "' class='text' id='" . $this->form_element_id() . "' name='collected_data[{$this->checkout_item->id}]" . $an_array . "' rows='3' cols='40' >" . $saved_form_data . "</textarea>"; break; case "checkbox": $options = $this->get_checkout_options($this->checkout_item->id); if ($options != '') { $i = mt_rand(); foreach ($options as $label => $value) { $output .= "<input type='hidden' title='" . $this->checkout_item->unique_name . "' id='" . $this->form_element_id() . "' value='-1' name='collected_data[{$this->checkout_item->id}][" . $i . "]'/><input type='checkbox' title='" . $this->checkout_item->unique_name . "' id='" . $this->form_element_id() . "' value='" . esc_attr($value) . "' name='collected_data[{$this->checkout_item->id}][" . $i . "]'/> "; $output .= "<label for='" . $this->form_element_id() . "'>" . $label . "</label>"; } } break; case "country": $output = wpsc_country_region_list($this->checkout_item->id, false, $_SESSION['wpsc_selected_country'], $_SESSION['wpsc_selected_region'], $this->form_element_id()); break; case "delivery_country": if (wpsc_uses_shipping()) { $country_name = $wpdb->get_var("SELECT `country` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `isocode`='" . $_SESSION['wpsc_delivery_country'] . "' LIMIT 1"); $output = "<input title='" . $this->checkout_item->unique_name . "' type='hidden' id='" . $this->form_element_id() . "' class='shipping_country' name='collected_data[{$this->checkout_item->id}]' value='" . esc_attr($_SESSION['wpsc_delivery_country']) . "' size='4' /><span class='shipping_country_name'>" . $country_name . "</span> "; } else { $checkoutfields = true; $output = wpsc_country_region_list($this->checkout_item->id, false, $_SESSION['wpsc_delivery_country'], $_SESSION['wpsc_delivery_region'], $this->form_element_id(), $checkoutfields); } break; case "select": $options = $this->get_checkout_options($this->checkout_item->id); if ($options != '') { $output = "<select name='collected_data[{$this->checkout_item->id}]" . $an_array . "'>"; $output .= "<option value='-1'>Select an Option</option>"; foreach ((array) $options as $label => $value) { $value = esc_attr(str_replace(' ', '', $value)); $output .= "<option value='" . esc_attr($value) . "'>" . esc_html($label) . "</option>\n\r"; } $output .= "</select>"; } break; case "radio": $options = $this->get_checkout_options($this->checkout_item->id); if ($options != '') { $i = mt_rand(); foreach ((array) $options as $label => $value) { $output .= "<input type='radio' title='" . $this->checkout_item->unique_name . "' id='" . $this->form_element_id() . "'value='" . esc_attr($value) . "' name='collected_data[{$this->checkout_item->id}][" . $i . "]'/> "; $output .= "<label for='" . $this->form_element_id() . "'>" . $label . "</label>"; } } break; case "text": case "city": case "delivery_city": case "email": case "coupon": default: if ($this->checkout_item->unique_name == 'shippingstate') { if (wpsc_uses_shipping() && wpsc_has_regions($_SESSION['wpsc_delivery_country'])) { $region_name = $wpdb->get_var("SELECT `name` FROM `" . WPSC_TABLE_REGION_TAX . "` WHERE `id`='" . $_SESSION['wpsc_delivery_region'] . "' LIMIT 1"); $output = "<input title='" . $this->checkout_item->unique_name . "' type='hidden' id='" . $this->form_element_id() . "' class='shipping_region' name='collected_data[{$this->checkout_item->id}]' value='" . $_SESSION['wpsc_delivery_region'] . "' size='4' /><span class='shipping_region_name'>" . $region_name . "</span> "; } else { $disabled = ''; if (wpsc_disregard_shipping_state_fields()) { $disabled = 'disabled = "disabled"'; } $output = "<input class='shipping_region text' title='" . $this->checkout_item->unique_name . "' type='text' id='" . $this->form_element_id() . "' value='" . $saved_form_data . "' name='collected_data[{$this->checkout_item->id}]" . $an_array . "' " . $disabled . " />"; } } elseif ($this->checkout_item->unique_name == 'billingstate') { if (wpsc_uses_shipping() && wpsc_has_regions($_SESSION['wpsc_selected_country'])) { $output = ''; } else { $disabled = ''; if (wpsc_disregard_billing_state_fields()) { $disabled = 'disabled = "disabled"'; } $output = "<input class='billing_region text' title='" . $this->checkout_item->unique_name . "' type='text' id='" . $this->form_element_id() . "' value='" . $saved_form_data . "' name='collected_data[{$this->checkout_item->id}]" . $an_array . "' " . $disabled . " />"; } } else { $output = "<input title='" . $this->checkout_item->unique_name . "' type='text' id='" . $this->form_element_id() . "' class='text' value='" . $saved_form_data . "' name='collected_data[{$this->checkout_item->id}]" . $an_array . "' />"; } break; } return $output; }
/** * form_field method, returns the form html * @access public */ function form_field() { global $wpdb, $user_ID; // exit('<pre>'.print_r($_SESSION['wpsc_checkout_saved_values'], true).'</pre>'); if (count($_SESSION['wpsc_checkout_saved_values']) <= 0 && $user_ID > 0) { //$_SESSION['wpsc_checkout_saved_values'] = get_usermeta($user_ID, 'wpshpcrt_usr_profile'); } if (is_array($_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id])) { if (function_exists('wpsc_get_ticket_checkout_set')) { if ($this->checkout_item->checkout_set == wpsc_get_ticket_checkout_set()) { if (!isset($_SESSION['wpsc_tickets_saved_values_count'])) { $_SESSION['wpsc_tickets_saved_values_count'] = 0; $count = $_SESSION['wpsc_tickets_saved_values_count']; } else { $count = $_SESSION['wpsc_tickets_saved_values_count'] - 1; } $saved_form_data = htmlentities(stripslashes($_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id][$count]), ENT_QUOTES, 'UTF-8'); } } } else { $saved_form_data = htmlentities(stripslashes($_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id]), ENT_QUOTES, 'UTF-8'); } //make sure tickets are arrays for multiple ticket holders $an_array = ''; if (function_exists('wpsc_get_ticket_checkout_set')) { if ($this->checkout_item->checkout_set == wpsc_get_ticket_checkout_set()) { $an_array = '[]'; } } switch ($this->checkout_item->type) { case "address": case "delivery_address": case "textarea": $output = "<textarea title='" . $this->checkout_item->unique_name . "' class='text' id='" . $this->form_element_id() . "' name='collected_data[{$this->checkout_item->id}]" . $an_array . "' rows='3' cols='40' >" . $saved_form_data . "</textarea>"; break; case "checkbox": $options = $this->get_checkout_options($this->checkout_item->id); if ($options != '') { $i = mt_rand(); $j = 0; foreach ($options as $label => $value) { $output .= "<input type='hidden' title='" . $this->checkout_item->unique_name . "' id='" . $this->form_element_id() . $j . "' value='-1' name='collected_data[{$this->checkout_item->id}][" . $i . "][" . $j . "]'/><input type='checkbox' title='" . $this->checkout_item->unique_name . "' id='" . $this->form_element_id() . "' value='" . $value . "' name='collected_data[{$this->checkout_item->id}][" . $i . "][" . $j . "]'/> "; $output .= "<label for='" . $this->form_element_id() . $j . "'>" . $label . "</label><br />"; $j++; } } break; case "country": $output = wpsc_country_region_list($this->checkout_item->id, false, $_SESSION['wpsc_selected_country'], $_SESSION['wpsc_selected_region'], $this->form_element_id()); break; case "delivery_country": if (wpsc_uses_shipping()) { $country_name = $wpdb->get_var("SELECT `country` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `isocode`='" . $_SESSION['wpsc_delivery_country'] . "' LIMIT 1"); $output = "<input title='" . $this->checkout_item->unique_name . "' type='hidden' id='" . $this->form_element_id() . "' class='shipping_country' name='collected_data[{$this->checkout_item->id}]' value='" . $_SESSION['wpsc_delivery_country'] . "' /><span class='shipping_country_name'>" . $country_name . "</span> "; } else { $checkoutfields = true; //$output = wpsc_shipping_country_list($checkoutfields); $output = wpsc_country_region_list($this->checkout_item->id, false, $_SESSION['wpsc_selected_country'], $_SESSION['wpsc_selected_region'], $this->form_element_id(), $checkoutfields); } break; case "select": $options = $this->get_checkout_options($this->checkout_item->id); if ($options != '') { $output = "<select name='collected_data[{$this->checkout_item->id}]" . $an_array . "'>"; $output .= "<option value='-1'>Select an Option</option>"; foreach ((array) $options as $label => $value) { $value = str_replace(' ', '', $value); if ($saved_form_data == $value) { $selected = 'selected="selected"'; } else { $selected = ''; } $output .= "<option " . $selected . " value='" . $value . "'>" . $label . "</option>\n\r"; } $output .= "</select>"; } break; case "radio": $options = $this->get_checkout_options($this->checkout_item->id); if ($options != '') { $i = mt_rand(); foreach ((array) $options as $label => $value) { $output .= "<input type='radio' title='" . $this->checkout_item->unique_name . "' id='" . $this->form_element_id() . "'value='" . $value . "' name='collected_data[{$this->checkout_item->id}][" . $i . "]'/> "; $output .= "<label for='" . $this->form_element_id() . "'>" . $label . "</label>"; } } break; case "text": case "city": case "delivery_city": case "email": case "coupon": default: $country_data = $wpdb->get_row("SELECT * FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `isocode` IN('" . $_SESSION['wpsc_delivery_country'] . "') LIMIT 1", ARRAY_A); if ($this->checkout_item->unique_name == 'shippingstate') { if (wpsc_uses_shipping() && $country_data['has_regions'] == 1) { $region_name = $wpdb->get_var("SELECT `name` FROM `" . WPSC_TABLE_REGION_TAX . "` WHERE `id`='" . $_SESSION['wpsc_delivery_region'] . "' LIMIT 1"); $output = "<input title='" . $this->checkout_item->unique_name . "' type='hidden' id='" . $this->form_element_id() . "' class='shipping_region' name='collected_data[{$this->checkout_item->id}]' value='" . $_SESSION['wpsc_delivery_region'] . "' size='4' /><span class='shipping_region_name'>" . $region_name . "</span> "; } else { $output = "<input class='shipping_region' title='" . $this->checkout_item->unique_name . "' type='text' id='" . $this->form_element_id() . "' class='text' value='" . $saved_form_data . "' name='collected_data[{$this->checkout_item->id}]" . $an_array . "' />"; } } else { $output = "<input title='" . $this->checkout_item->unique_name . "' type='text' id='" . $this->form_element_id() . "' class='text' value='" . $saved_form_data . "' name='collected_data[{$this->checkout_item->id}]" . $an_array . "' />"; } break; } return $output; }