Пример #1
0
/**
 * Get Shop States
 *
 * @since 1.0
 *
 * @param null $country
 *
 * @return mixed|void  A list of states for the shop's base country
 */
function give_get_states($country = null)
{
    global $give_options;
    if (empty($country)) {
        $country = give_get_country();
    }
    switch ($country) {
        case 'US':
            $states = give_get_states_list();
            break;
        case 'CA':
            $states = give_get_provinces_list();
            break;
        case 'AU':
            $states = give_get_australian_states_list();
            break;
        case 'BR':
            $states = give_get_brazil_states_list();
            break;
        case 'CN':
            $states = give_get_chinese_states_list();
            break;
        case 'HK':
            $states = give_get_hong_kong_states_list();
            break;
        case 'HU':
            $states = give_get_hungary_states_list();
            break;
        case 'ID':
            $states = give_get_indonesian_states_list();
            break;
        case 'IN':
            $states = give_get_indian_states_list();
            break;
        case 'MY':
            $states = give_get_malaysian_states_list();
            break;
        case 'NZ':
            $states = give_get_new_zealand_states_list();
            break;
        case 'TH':
            $states = give_get_thailand_states_list();
            break;
        case 'ZA':
            $states = give_get_south_african_states_list();
            break;
        case 'ES':
            $states = give_get_spain_states_list();
            break;
        default:
            $states = array();
            break;
    }
    return apply_filters('give_give_states', $states);
}
Пример #2
0
/**
 * Outputs the default credit card address fields
 *
 * @since 1.0
 * @return void
 */
function give_default_cc_address_fields()
{
    $logged_in = is_user_logged_in();
    if ($logged_in) {
        $user_address = get_user_meta(get_current_user_id(), '_give_user_address', true);
    }
    $line1 = $logged_in && !empty($user_address['line1']) ? $user_address['line1'] : '';
    $line2 = $logged_in && !empty($user_address['line2']) ? $user_address['line2'] : '';
    $city = $logged_in && !empty($user_address['city']) ? $user_address['city'] : '';
    $zip = $logged_in && !empty($user_address['zip']) ? $user_address['zip'] : '';
    ob_start();
    ?>
	<fieldset id="give_cc_address" class="cc-address">
		<legend><?php 
    _e('Adora art cards Receiving Details', 'give');
    ?>
</legend>
		<?php 
    do_action('give_cc_billing_top');
    ?>
		<p id="give-card-address-wrap" class="form-row form-row-two-thirds">
			<label for="card_address" class="give-label">
				<?php 
    _e('Address', 'give');
    ?>
				<?php 
    if (give_field_is_required('card_address')) {
        ?>
					<span class="give-required-indicator">*</span>
				<?php 
    }
    ?>

			</label>

			<input type="text" id="card_address" name="card_address" class="card-address give-input<?php 
    if (give_field_is_required('card_address')) {
        echo ' required';
    }
    ?>
" placeholder="<?php 
    _e('Address line 1', 'give');
    ?>
" value="<?php 
    echo $line1;
    ?>
" />
		</p>

		<p id="give-card-address-2-wrap" class="form-row form-row-one-third">
			<label for="card_address_2" class="give-label">
				<?php 
    _e('Address Line 2', 'give');
    ?>
				<?php 
    if (give_field_is_required('card_address_2')) {
        ?>
					<span class="give-required-indicator">*</span>
				<?php 
    }
    ?>

			</label>

			<input type="text" id="card_address_2" name="card_address_2" class="card-address-2 give-input<?php 
    if (give_field_is_required('card_address_2')) {
        echo ' required';
    }
    ?>
" placeholder="<?php 
    _e('Address line 2', 'give');
    ?>
" value="<?php 
    echo $line2;
    ?>
" />
		</p>

		<p id="give-card-city-wrap" class="form-row form-row-two-thirds">
			<label for="card_city" class="give-label">
				<?php 
    _e('City', 'give');
    ?>
				<?php 
    if (give_field_is_required('card_city')) {
        ?>
					<span class="give-required-indicator">*</span>
				<?php 
    }
    ?>

			</label>
			<input type="text" id="card_city" name="card_city" class="card-city give-input<?php 
    if (give_field_is_required('card_city')) {
        echo ' required';
    }
    ?>
" placeholder="<?php 
    _e('City', 'give');
    ?>
" value="<?php 
    echo $city;
    ?>
" />
		</p>

		<p id="give-card-zip-wrap" class="form-row form-row-one-third">
			<label for="card_zip" class="give-label">
				<?php 
    _e('Zip / Postal Code', 'give');
    ?>
				<?php 
    if (give_field_is_required('card_zip')) {
        ?>
					<span class="give-required-indicator">*</span>
				<?php 
    }
    ?>

			</label>

			<input type="text" size="4" name="card_zip" class="card-zip give-input<?php 
    if (give_field_is_required('card_zip')) {
        echo ' required';
    }
    ?>
" placeholder="<?php 
    _e('Zip / Postal code', 'give');
    ?>
" value="<?php 
    echo $zip;
    ?>
" />
		</p>

		<p id="give-card-country-wrap" class="form-row form-row-first">
			<label for="billing_country" class="give-label">
				<?php 
    _e('Country', 'give');
    ?>
				<?php 
    if (give_field_is_required('billing_country')) {
        ?>
					<span class="give-required-indicator">*</span>
				<?php 
    }
    ?>
			</label>

			<select name="billing_country" id="billing_country" class="billing-country billing_country give-select<?php 
    if (give_field_is_required('billing_country')) {
        echo ' required';
    }
    ?>
">
				<?php 
    $selected_country = give_get_country();
    if ($logged_in && !empty($user_address['country']) && '*' !== $user_address['country']) {
        $selected_country = $user_address['country'];
    }
    $countries = give_get_country_list();
    foreach ($countries as $country_code => $country) {
        echo '<option value="' . esc_attr($country_code) . '"' . selected($country_code, $selected_country, false) . '>' . $country . '</option>';
    }
    ?>
			</select>
		</p>

		<p id="give-card-state-wrap" class="form-row form-row-last">
			<label for="card_state" class="give-label">
				<?php 
    _e('State / Province', 'give');
    ?>
				<?php 
    if (give_field_is_required('card_state')) {
        ?>
					<span class="give-required-indicator">*</span>
				<?php 
    }
    ?>
			</label>

			<?php 
    $selected_state = give_get_state();
    $states = give_get_states($selected_country);
    if ($logged_in && !empty($user_address['state'])) {
        $selected_state = $user_address['state'];
    }
    if (!empty($states)) {
        ?>
				<select name="card_state" id="card_state" class="card_state give-select<?php 
        if (give_field_is_required('card_state')) {
            echo ' required';
        }
        ?>
">
					<?php 
        foreach ($states as $state_code => $state) {
            echo '<option value="' . $state_code . '"' . selected($state_code, $selected_state, false) . '>' . $state . '</option>';
        }
        ?>
				</select>
			<?php 
    } else {
        ?>
				<input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" placeholder="<?php 
        _e('State / Province', 'give');
        ?>
" />
			<?php 
    }
    ?>
		</p>
		<?php 
    do_action('give_cc_billing_bottom');
    ?>
	</fieldset>
	<?php 
    echo ob_get_clean();
}
Пример #3
0
/**
 * Retrieve a states drop down
 *
 * @since 1.0
 * @return void
 */
function give_ajax_get_states_field()
{
    if (empty($_POST['country'])) {
        $_POST['country'] = give_get_country();
    }
    $states = give_get_states($_POST['country']);
    if (!empty($states)) {
        $args = array('name' => $_POST['field_name'], 'id' => $_POST['field_name'], 'class' => $_POST['field_name'] . '  give-select', 'options' => give_get_states($_POST['country']), 'show_option_all' => false, 'show_option_none' => false);
        $response = Give()->html->select($args);
    } else {
        $response = 'nostates';
    }
    echo $response;
    give_die();
}
Пример #4
0
/**
 * Outputs the default credit card address fields
 *
 * @since  1.0
 *
 * @param  int $form_id
 *
 * @return void
 */
function give_default_cc_address_fields($form_id)
{
    $logged_in = is_user_logged_in();
    if ($logged_in) {
        $user_address = get_user_meta(get_current_user_id(), '_give_user_address', true);
    }
    $line1 = $logged_in && !empty($user_address['line1']) ? $user_address['line1'] : '';
    $line2 = $logged_in && !empty($user_address['line2']) ? $user_address['line2'] : '';
    $city = $logged_in && !empty($user_address['city']) ? $user_address['city'] : '';
    $zip = $logged_in && !empty($user_address['zip']) ? $user_address['zip'] : '';
    ob_start();
    ?>
	<fieldset id="give_cc_address" class="cc-address">
		<legend><?php 
    echo apply_filters('give_billing_details_fieldset_heading', esc_html__('Billing Details', 'give'));
    ?>
</legend>
		<?php 
    do_action('give_cc_billing_top');
    ?>
		<p id="give-card-address-wrap" class="form-row form-row-two-thirds">
			<label for="card_address" class="give-label">
				<?php 
    esc_html_e('Address', 'give');
    ?>
				<?php 
    if (give_field_is_required('card_address', $form_id)) {
        ?>
					<span class="give-required-indicator">*</span>
				<?php 
    }
    ?>
				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php 
    esc_html_e('The primary billing address for your credit card.', 'give');
    ?>
"></span>
			</label>

			<input type="text" id="card_address" name="card_address" class="card-address give-input<?php 
    if (give_field_is_required('card_address', $form_id)) {
        echo ' required';
    }
    ?>
" placeholder="<?php 
    esc_html_e('Address line 1', 'give');
    ?>
" value="<?php 
    echo $line1;
    ?>
"<?php 
    if (give_field_is_required('card_address', $form_id)) {
        echo '  required ';
    }
    ?>
/>
		</p>

		<p id="give-card-address-2-wrap" class="form-row form-row-one-third">
			<label for="card_address_2" class="give-label">
				<?php 
    esc_html_e('Address Line 2', 'give');
    ?>
				<?php 
    if (give_field_is_required('card_address_2', $form_id)) {
        ?>
					<span class="give-required-indicator">*</span>
				<?php 
    }
    ?>
				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php 
    esc_html_e('(optional) The suite, apt no, PO box, etc, associated with your billing address.', 'give');
    ?>
"></span>
			</label>

			<input type="text" id="card_address_2" name="card_address_2" class="card-address-2 give-input<?php 
    if (give_field_is_required('card_address_2', $form_id)) {
        echo ' required';
    }
    ?>
" placeholder="<?php 
    esc_html_e('Address line 2', 'give');
    ?>
" value="<?php 
    echo $line2;
    ?>
"<?php 
    if (give_field_is_required('card_address_2', $form_id)) {
        echo ' required ';
    }
    ?>
/>
		</p>

		<p id="give-card-city-wrap" class="form-row form-row-two-thirds">
			<label for="card_city" class="give-label">
				<?php 
    esc_html_e('City', 'give');
    ?>
				<?php 
    if (give_field_is_required('card_city', $form_id)) {
        ?>
					<span class="give-required-indicator">*</span>
				<?php 
    }
    ?>
				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php 
    esc_html_e('The city for your billing address.', 'give');
    ?>
"></span>
			</label>
			<input type="text" id="card_city" name="card_city" class="card-city give-input<?php 
    if (give_field_is_required('card_city', $form_id)) {
        echo ' required';
    }
    ?>
" placeholder="<?php 
    esc_html_e('City', 'give');
    ?>
" value="<?php 
    echo $city;
    ?>
"<?php 
    if (give_field_is_required('card_city', $form_id)) {
        echo ' required ';
    }
    ?>
/>
		</p>

		<p id="give-card-zip-wrap" class="form-row form-row-one-third">
			<label for="card_zip" class="give-label">
				<?php 
    esc_html_e('Zip / Postal Code', 'give');
    ?>
				<?php 
    if (give_field_is_required('card_zip', $form_id)) {
        ?>
					<span class="give-required-indicator">*</span>
				<?php 
    }
    ?>
				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php 
    esc_html_e('The zip or postal code for your billing address.', 'give');
    ?>
"></span>
			</label>

			<input type="text" size="4" id="card_zip" name="card_zip" class="card-zip give-input<?php 
    if (give_field_is_required('card_zip', $form_id)) {
        echo ' required';
    }
    ?>
" placeholder="<?php 
    esc_html_e('Zip / Postal Code', 'give');
    ?>
" value="<?php 
    echo $zip;
    ?>
" <?php 
    if (give_field_is_required('card_zip', $form_id)) {
        echo ' required ';
    }
    ?>
/>
		</p>

		<p id="give-card-country-wrap" class="form-row form-row-first">
			<label for="billing_country" class="give-label">
				<?php 
    esc_html_e('Country', 'give');
    ?>
				<?php 
    if (give_field_is_required('billing_country', $form_id)) {
        ?>
					<span class="give-required-indicator">*</span>
				<?php 
    }
    ?>
				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php 
    esc_html_e('The country for your billing address.', 'give');
    ?>
"></span>
			</label>

			<select name="billing_country" id="billing_country" class="billing-country billing_country give-select<?php 
    if (give_field_is_required('billing_country', $form_id)) {
        echo ' required';
    }
    ?>
"<?php 
    if (give_field_is_required('billing_country', $form_id)) {
        echo ' required ';
    }
    ?>
>
				<?php 
    $selected_country = give_get_country();
    if ($logged_in && !empty($user_address['country']) && '*' !== $user_address['country']) {
        $selected_country = $user_address['country'];
    }
    $countries = give_get_country_list();
    foreach ($countries as $country_code => $country) {
        echo '<option value="' . esc_attr($country_code) . '"' . selected($country_code, $selected_country, false) . '>' . $country . '</option>';
    }
    ?>
			</select>
		</p>

		<p id="give-card-state-wrap" class="form-row form-row-last">
			<label for="card_state" class="give-label">
				<?php 
    esc_html_e('State / Province', 'give');
    ?>
				<?php 
    if (give_field_is_required('card_state', $form_id)) {
        ?>
					<span class="give-required-indicator">*</span>
				<?php 
    }
    ?>
				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php 
    esc_html_e('The state or province for your billing address.', 'give');
    ?>
"></span>
			</label>

			<?php 
    $selected_state = give_get_state();
    $states = give_get_states($selected_country);
    if ($logged_in && !empty($user_address['state'])) {
        $selected_state = $user_address['state'];
    }
    if (!empty($states)) {
        ?>
				<select name="card_state" id="card_state" class="card_state give-select<?php 
        if (give_field_is_required('card_state', $form_id)) {
            echo ' required';
        }
        ?>
"<?php 
        if (give_field_is_required('card_state', $form_id)) {
            echo ' required ';
        }
        ?>
>
					<?php 
        foreach ($states as $state_code => $state) {
            echo '<option value="' . $state_code . '"' . selected($state_code, $selected_state, false) . '>' . $state . '</option>';
        }
        ?>
				</select>
			<?php 
    } else {
        ?>
				<input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" placeholder="<?php 
        esc_html_e('State / Province', 'give');
        ?>
"/>
			<?php 
    }
    ?>
		</p>
		<?php 
    do_action('give_cc_billing_bottom');
    ?>
	</fieldset>
	<?php 
    echo ob_get_clean();
}