public function do_shortcode()
    {
        global $wc_catalog_restrictions;
        ob_start();
        ?>

        <div class="location-picker">

            <?php 
        do_action('woocommerce_catalog_restrictions_before_choose_location_form');
        ?>

            <form name="location_picker" method="post">
                <?php 
        woocommerce_catalog_restrictions_country_input($wc_catalog_restrictions->get_location_for_current_user());
        ?>
                
                <input type="hidden" name="woocommerce_catalog_restrictions_location_picker" value="shortcode" />
                <input type="submit" name="save-location" value="Set Location" />
            </form>
            
            <?php 
        do_action('woocommerce_catalog_restrictions_before_choose_location_form');
        ?>
            <div style="clear:both;"></div>
        </div>

        <?php 
        return ob_get_clean();
    }
    public function do_shortcode()
    {
        global $woocommerce, $wc_cvo, $wc_catalog_restrictions;
        ob_start();
        ?>
		<?php 
        $locations = $woocommerce->countries->get_allowed_countries();
        ?>
		<?php 
        $location = $wc_catalog_restrictions->get_location_for_current_user();
        ?>
		<?php 
        $changeable = apply_filters('wc_location_changeable', $wc_cvo->setting('_wc_restrictions_locations_changeable') == 'yes');
        ?>
		<?php 
        if ($changeable || !isset($locations[$location]) || empty($location)) {
            ?>

			<div class="location-picker">

				<?php 
            do_action('woocommerce_catalog_restrictions_before_choose_location_form');
            ?>
				<form name="location_picker" method="post">
					<?php 
            woocommerce_catalog_restrictions_country_input($wc_catalog_restrictions->get_location_for_current_user());
            ?>

					<input type="hidden" name="woocommerce_catalog_restrictions_location_picker" value="shortcode" />
					<input type="submit" name="save-location" value="Set Location" />
				</form>

				<?php 
            do_action('woocommerce_catalog_restrictions_before_choose_location_form');
            ?>
				<div style="clear:both;"></div>
			</div>

		<?php 
        } else {
            ?>
			<?php 
            printf(__('Your Location is <strong>%s</strong>', 'wc_catalog_restrictions'), $locations[$wc_catalog_restrictions->get_location_for_current_user()]);
            ?>
		<?php 
        }
        ?>
		<?php 
        return ob_get_clean();
    }
    /**
     * widget function.
     *
     * @see WP_Widget
     * @access public
     * @param array $args
     * @param array $instance
     * @return void
     */
    function widget($args, $instance)
    {
        global $woocommerce, $wc_catalog_restrictions;
        extract($args);
        // Don't show if on the account page since that has a login
        if (is_account_page() && !is_user_logged_in()) {
            return;
        }
        $location_set_title = !empty($instance['location_set_title']) ? $instance['location_set_title'] : __('Current location is %s', 'wc_catalog_restrictions');
        $location_not_set_title = !empty($instance['location_not_set_title']) ? $instance['location_not_set_title'] : __('Choose your location', 'wc_catalog_restrictions');
        echo $before_widget;
        // Get redirect URL
        $redirect_to = apply_filters('woocommerce_catalog_restrictions_choose_location_widget_redirect', get_permalink(woocommerce_get_page_id('shop')));
        ?>
        <form method="post">
            <p><?php 
        woocommerce_catalog_restrictions_country_input($wc_catalog_restrictions->get_location_for_current_user(), array('label' => $location_not_set_title));
        ?>
</p>
            <p><input type="submit" class="submitbutton" name="wp-submit" id="wp-submit" value="<?php 
        _e('Go &rarr;', 'wc_catalog_restrictions');
        ?>
" /> </p>
            <div>
                <input type="hidden" name="redirect_to" class="redirect_to" value="<?php 
        echo esc_attr($redirect_to);
        ?>
" />
                <input type="hidden" name="testcookie" value="1" />
                <input type="hidden" name="woocommerce_catalog_restrictions_location_picker" value="sidebar" />
                <input type="hidden" name="rememberme" value="forever" />
            </div>
        </form>
        <?php 
        echo $after_widget;
    }
Пример #4
0
    do_action('woocommerce_catalog_restrictions_before_choose_location_description');
    ?>
	<?php 
    the_content();
    ?>
	<?php 
    do_action('woocommerce_catalog_restrictions_after_choose_location_description');
    ?>

	<?php 
    do_action('woocommerce_catalog_restrictions_before_choose_location_form');
    ?>

	<form name="choose-location" method="post">
		<?php 
    woocommerce_catalog_restrictions_country_input($wc_catalog_restrictions->get_location_for_current_user());
    ?>
		<br />

		<input type="hidden" value="shortcode" name="choose_location" />
		<input type="submit" name="save-location" value="<?php 
    _e('Set Location', 'wc_catalog_restrictions');
    ?>
" />
	</form>

	<?php 
    do_action('woocommerce_catalog_restrictions_before_choose_location_form');
    ?>

Пример #5
0
    do_action('woocommerce_catalog_restrictions_before_choose_location_description');
    ?>
    <?php 
    the_content();
    ?>
    <?php 
    do_action('woocommerce_catalog_restrictions_after_choose_location_description');
    ?>

    <?php 
    do_action('woocommerce_catalog_restrictions_before_choose_location_form');
    ?>

    <form name="choose-location" method="post">
        <?php 
    woocommerce_catalog_restrictions_country_input(isset($_SESSION['wc_location']) ? $_SESSION['wc_location'] : '');
    ?>
        <br />
        
        <input type="hidden" value="shortcode" name="choose_location" />
        <input type="submit" name="save-location" value="Set Location" />
    </form>

    <?php 
    do_action('woocommerce_catalog_restrictions_before_choose_location_form');
    ?>


<?php 
}
// end of the loop.
Пример #6
0
?>
</h3>

<table class="form-table">

	<?php 
if (current_user_can('administrator') || $can_change) {
    ?>
		<tr>
			<th><label><?php 
    _e('Location', 'wc_catalog_restrictions');
    ?>
</label></th>
			<td>
				<?php 
    woocommerce_catalog_restrictions_country_input($location);
    ?>
				<span class="description"><?php 
    __('The location for the user', 'wc_catalog_restrictions');
    ?>
.</span>
			</td>
		</tr>
	<?php 
}
?>

	<?php 
if (current_user_can('administrator')) {
    ?>
		<tr>