Beispiel #1
0
 /**
  * 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, $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;
    }
Beispiel #3
0
/**
 * wpsc_change_tax function, used through ajax and in normal page loading.
 * No parameters, returns nothing
 */
function wpsc_change_tax()
{
    global $wpdb, $wpsc_cart;
    $form_id = absint($_POST['form_id']);
    $wpsc_selected_country = $wpsc_cart->selected_country;
    $wpsc_selected_region = $wpsc_cart->selected_region;
    $wpsc_delivery_country = $wpsc_cart->delivery_country;
    $wpsc_delivery_region = $wpsc_cart->delivery_region;
    $previous_country = wpsc_get_customer_meta('billingcountry');
    global $wpdb, $user_ID, $wpsc_customer_checkout_details;
    if (isset($_POST['billing_country'])) {
        $wpsc_selected_country = $_POST['billing_country'];
        wpsc_update_customer_meta('billingcountry', $wpsc_selected_country);
    }
    if (isset($_POST['billing_region'])) {
        $wpsc_selected_region = absint($_POST['billing_region']);
        wpsc_update_customer_meta('billingregion', $wpsc_selected_region);
    }
    $check_country_code = WPSC_Countries::country_id(wpsc_get_customer_meta('billing_region'));
    if (wpsc_get_customer_meta('billingcountry') != $check_country_code) {
        $wpsc_selected_region = null;
    }
    if (isset($_POST['shipping_country'])) {
        $wpsc_delivery_country = $_POST['shipping_country'];
        wpsc_update_customer_meta('shippingcountry', $wpsc_delivery_country);
    }
    if (isset($_POST['shipping_region'])) {
        $wpsc_delivery_region = absint($_POST['shipping_region']);
        wpsc_update_customer_meta('shippingregion', $wpsc_delivery_region);
    }
    $check_country_code = WPSC_Countries::country_id($wpsc_delivery_region);
    if ($wpsc_delivery_country != $check_country_code) {
        $wpsc_delivery_region = null;
    }
    $wpsc_cart->update_location();
    $wpsc_cart->get_shipping_method();
    $wpsc_cart->get_shipping_option();
    if ($wpsc_cart->selected_shipping_method != '') {
        $wpsc_cart->update_shipping($wpsc_cart->selected_shipping_method, $wpsc_cart->selected_shipping_option);
    }
    $tax = $wpsc_cart->calculate_total_tax();
    $total = wpsc_cart_total();
    $total_input = wpsc_cart_total(false);
    if ($wpsc_cart->coupons_amount >= $total_input && !empty($wpsc_cart->coupons_amount)) {
        $total = 0;
    }
    if ($wpsc_cart->total_price < 0) {
        $wpsc_cart->coupons_amount += $wpsc_cart->total_price;
        $wpsc_cart->total_price = null;
        $wpsc_cart->calculate_total_price();
    }
    $delivery_country = wpsc_get_customer_meta('shipping_country');
    $output = _wpsc_ajax_get_cart(false);
    $output = $output['widget_output'];
    $json_response = array();
    global $wpsc_checkout;
    if (empty($wpsc_checkout)) {
        $wpsc_checkout = new wpsc_checkout();
    }
    $json_response['delivery_country'] = esc_js($delivery_country);
    $json_response['billing_country'] = esc_js($wpsc_selected_country);
    $json_response['widget_output'] = $output;
    $json_response['shipping_keys'] = array();
    $json_response['cart_shipping'] = wpsc_cart_shipping();
    $json_response['form_id'] = $form_id;
    $json_response['tax'] = $tax;
    $json_response['display_tax'] = wpsc_cart_tax();
    $json_response['total'] = $total;
    $json_response['total_input'] = $total_input;
    $json_response['lock_tax'] = get_option('lock_tax');
    $json_response['country_name'] = wpsc_get_country($delivery_country);
    if ('US' == $delivery_country || 'CA' == $delivery_country) {
        $output = wpsc_shipping_region_list($delivery_country, wpsc_get_customer_meta('shipping_region'));
        $output = str_replace(array("\n", "\r"), '', $output);
        $json_response['shipping_region_list'] = $output;
    }
    foreach ($wpsc_cart->cart_items as $key => $cart_item) {
        $json_response['shipping_keys'][$key] = wpsc_currency_display($cart_item->shipping);
    }
    $form_selected_country = null;
    $form_selected_region = null;
    $onchange_function = null;
    if (!empty($_POST['billing_country']) && $_POST['billing_country'] != 'undefined' && !isset($_POST['shipping_country'])) {
        $form_selected_country = $wpsc_selected_country;
        $form_selected_region = $wpsc_selected_region;
        $onchange_function = 'set_billing_country';
    } else {
        if (!empty($_POST['shipping_country']) && $_POST['shipping_country'] != 'undefined' && !isset($_POST['billing_country'])) {
            $form_selected_country = $wpsc_delivery_country;
            $form_selected_region = $wpsc_delivery_region;
            $onchange_function = 'set_shipping_country';
        }
    }
    if ($form_selected_country != null && $onchange_function != null) {
        $checkoutfields = 'set_shipping_country' == $onchange_function;
        $region_list = wpsc_country_region_list($form_id, false, $form_selected_country, $form_selected_region, $form_id, $checkoutfields);
        if ($region_list != null) {
            $json_response['region_list'] = str_replace(array("\n", "\r"), '', $region_list);
        }
    }
    echo json_encode($json_response);
    exit;
}
 /**
  * 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;
 }
Beispiel #5
0
 /**
  * form_field method, returns the form html
  * @access public
  */
 function form_field()
 {
     global $wpdb, $user_ID;
     if (count($_SESSION['wpsc_checkout_saved_values']) <= 0 && $user_ID > 0) {
         $_SESSION['wpsc_checkout_saved_values'] = get_usermeta($user_ID, 'wpshpcrt_usr_profile');
     }
     $saved_form_data = htmlentities(stripslashes($_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id]), ENT_QUOTES);
     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}]' rows='3' cols='40' >" . $saved_form_data . "</textarea>";
             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'] . "' size='4' /><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 "text":
         case "city":
         case "delivery_city":
         case "email":
         case "coupon":
         default:
             $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}]' />";
             break;
     }
     return $output;
 }
Beispiel #6
0
             echo "<textarea name='collected_data[" . $form_field['id'] . "]'>" . $_SESSION['collected_data'][$form_field['id']] . "</textarea>";
             break;
             /*
             case "region":
             case "delivery_region":
             echo "<select name='collected_data[".$form_field['id']."]'>".nzshpcrt_region_list($_SESSION['collected_data'][$form_field['id']])."</select>";
             break;
             */
         /*
         case "region":
         case "delivery_region":
         echo "<select name='collected_data[".$form_field['id']."]'>".nzshpcrt_region_list($_SESSION['collected_data'][$form_field['id']])."</select>";
         break;
         */
         case "country":
             echo wpsc_country_region_list($form_field['id'], false, $_SESSION['selected_country'], $_SESSION['selected_region']);
             break;
         case "delivery_country":
             $country_name = $wpdb->get_var("SELECT `country` FROM `" . $wpdb->prefix . "currency_list` WHERE `isocode`='" . $_SESSION['delivery_country'] . "' LIMIT 1");
             echo "<input type='hidden' name='collected_data[" . $form_field['id'] . "]' value='" . $_SESSION['delivery_country'] . "'>" . $country_name . " ";
             break;
         case "email":
             echo "<input type='text' value='" . $_SESSION['collected_data'][$form_field['id']] . "' name='collected_data[" . $form_field['id'] . "]' />";
             break;
         default:
             echo "<input type='text' value='" . $_SESSION['collected_data'][$form_field['id']] . "' name='collected_data[" . $form_field['id'] . "]' />";
             break;
     }
     echo "\t</td>\n\r";
     echo "</tr>\n\r";
 }