function wpsc_display_settings_page()
{
    ?>

	<div id="wpsc_options" class="wrap">
		<div id="icon_card"><br /></div>
		<h2><?php 
    _e('Store Settings', 'wpsc');
    ?>
</h2>
		<?php 
    wpsc_the_settings_tabs();
    if (isset($_GET['tab'])) {
        $page = $_GET['tab'];
    } else {
        $page = 'general';
    }
    if (!isset($_GET['isocode'])) {
        $_GET['isocode'] = '';
    }
    if (preg_match("/[a-zA-Z]{2,4}/", $_GET['isocode'])) {
        include WPSC_FILE_PATH . '/wpsc-admin/includes/tax_and_shipping.php';
        return;
    }
    if (isset($_GET['googlecheckoutshipping'])) {
        include WPSC_FILE_PATH . '/wpsc-merchants/library/google_shipping_country.php';
        return;
        exit;
    }
    if (isset($_GET['selected_all'])) {
        wpsc_submit_options($_GET['selected_all']);
    }
    ?>

		<div id='wpsc_options_page'>

		<?php 
    switch ($page) {
        case 'checkout':
            require_once WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/checkout.php';
            wpsc_options_checkout();
            break;
        case 'gateway':
            require_once WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/gateway.php';
            wpsc_options_gateway();
            break;
        case 'shipping':
            require_once WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/shipping.php';
            wpsc_options_shipping();
            break;
        case 'admin':
            require_once WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/admin.php';
            wpsc_options_admin();
            break;
        case 'presentation':
            require_once WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/presentation.php';
            wpsc_options_presentation();
            break;
        case 'taxes':
            wpec_taxes_settings_page();
            break;
        case 'marketing':
            require_once WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/marketing.php';
            wpsc_options_marketing();
            break;
        case 'import':
            require_once WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/import.php';
            wpsc_options_import();
            break;
        case 'general':
        default:
            require_once WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/general.php';
            wpsc_options_general();
            break;
    }
    $_SESSION['wpsc_settings_curr_page'] = $page;
    ?>

		</div>
	</div>

<?php 
}
function wpsc_display_settings_page()
{
    ?>
 <div id="wpsc_options" class="wrap">
	<?php 
    if (wpsc_check_theme_versions()) {
        ?>
		<div class="updated fade below-h2" id="message" style="background-color: rgb(255, 251, 204);">
			<p><?php 
        _e("It looks like your wp-e-commerce theme files are out of date, this can cause potential problems with some gateways and the appearances of the front end of your shop. <br /><strong>We recommend you download the latest version of wp-e-commerce unzip it, and copy the new themes folder into your 'uploads/wpsc/themes' folder on your site. Or port your changes across.</strong>", "wpsc");
        ?>
</p>
		</div>
	<?php 
    }
    wpsc_the_settings_tabs();
    if (isset($_GET['tab'])) {
        $page = $_GET['tab'];
    } else {
        $page = 'general';
    }
    if (preg_match("/[a-zA-Z]{2,4}/", $_GET['isocode'])) {
        include WPSC_FILE_PATH . '/tax_and_shipping.php';
        return;
    }
    if (isset($_GET['googlecheckoutshipping'])) {
        include WPSC_FILE_PATH . '/google_shipping_country.php';
        return;
        exit;
    }
    if (isset($_GET['selected_all'])) {
        wpsc_submit_options($_GET['selected_all']);
    }
    if ($_SESSION['wpsc_thumbnails_resized'] == true) {
        ?>
	<div class="updated fade below-h2" id="message" style="background-color: rgb(255, 251, 204);">
		<p><?php 
        _e("Thanks, your thumbnail images have been resized.");
        ?>
</p>
	</div>
	<?php 
        $_SESSION['wpsc_thumbnails_resized'] = false;
    }
    ?>
 <div id='wpsc_options_page'> <?php 
    switch ($page) {
        case "checkout":
            require_once 'includes/settings-pages/checkout.php';
            wpsc_options_checkout();
            break;
        case "gateway":
            require_once 'includes/settings-pages/gateway.php';
            wpsc_options_gateway();
            break;
        case "shipping":
            require_once 'includes/settings-pages/shipping.php';
            wpsc_options_shipping();
            break;
        case "admin":
            require_once 'includes/settings-pages/admin.php';
            wpsc_options_admin();
            break;
        case "presentation":
            require_once 'includes/settings-pages/presentation.php';
            wpsc_options_presentation();
            break;
        case "import":
            require_once 'includes/settings-pages/import.php';
            wpsc_options_import();
            break;
        default:
        case "general":
            require_once 'includes/settings-pages/general.php';
            wpsc_options_general();
            break;
    }
    $_SESSION['wpsc_settings_curr_page'] = $page;
    ?>
</div>
</div>
<?php 
}
function wpsc_display_settings_page()
{
    ?>
 <div id="wpsc_options" class="wrap">
<?php 
    wpsc_the_settings_tabs();
    if (isset($_GET['tab'])) {
        $page = $_GET['tab'];
    } else {
        $page = 'general';
    }
    if (preg_match("/[a-zA-Z]{2,4}/", $_GET['isocode'])) {
        include WPSC_FILE_PATH . '/tax_and_shipping.php';
        return;
    }
    if (isset($_GET['googlecheckoutshipping'])) {
        include WPSC_FILE_PATH . '/google_shipping_country.php';
        return;
        exit;
    }
    if (isset($_GET['selected_all'])) {
        wpsc_submit_options($_GET['selected_all']);
    }
    if ($_SESSION['wpsc_thumbnails_resized'] == true) {
        ?>
	<div class="updated fade below-h2" id="message" style="background-color: rgb(255, 251, 204);">
		<p><?php 
        _e("Thanks, your thumbnail images have been resized.");
        ?>
</p>
	</div>
	<?php 
        $_SESSION['wpsc_thumbnails_resized'] = false;
    }
    ?>
 <div id='wpsc_options_page'> <?php 
    switch ($page) {
        case "checkout":
            require_once 'includes/settings-pages/checkout.php';
            wpsc_options_checkout();
            break;
        case "gateway":
            require_once 'includes/settings-pages/gateway.php';
            wpsc_options_gateway();
            break;
        case "shipping":
            require_once 'includes/settings-pages/shipping.php';
            wpsc_options_shipping();
            break;
        case "admin":
            require_once 'includes/settings-pages/admin.php';
            wpsc_options_admin();
            break;
        case "presentation":
            require_once 'includes/settings-pages/presentation.php';
            wpsc_options_presentation();
            break;
        case "import":
            require_once 'includes/settings-pages/import.php';
            wpsc_options_import();
            break;
        default:
        case "general":
            require_once 'includes/settings-pages/general.php';
            wpsc_options_general();
            break;
    }
    $_SESSION['wpsc_settings_curr_page'] = $page;
    ?>
</div>
</div>
<?php 
}
Esempio n. 4
0
/**
 * @description: wpec_submit_taxes_options - filters the options submitted in $_POST. Uses
 *                                           wpsc_submit_options to submit filtered array.
 * @param: void
 * @return: null
 * */
function wpec_submit_taxes_options()
{
    //define the name of the checkbox options
    $taxes_check_options = array('wpec_taxes_enabled');
    //check if checkbox options are checked and modify post output
    foreach ($taxes_check_options as $option) {
        $_POST['wpsc_options'][$option] = isset($_POST['wpsc_options'][$option]) ? 1 : 0;
    }
    // foreach
    //currently there are two types - bands and rates
    $taxes_rates_types = array('rates', 'bands');
    foreach ($taxes_rates_types as $taxes_type) {
        $saved_rates = array();
        //keep track of saved rates
        $exists = array();
        //keep track of what rates or names have been saved
        //check the rates
        if (isset($_POST['wpsc_options']['wpec_taxes_' . $taxes_type])) {
            foreach ($_POST['wpsc_options']['wpec_taxes_' . $taxes_type] as $tax_rate) {
                if (!isset($tax_rate['region_code'])) {
                    $tax_rate['region_code'] = '';
                }
                //if there is no country then skip
                if (empty($tax_rate['country_code'])) {
                    continue;
                }
                //bands - if the name already exists then skip - if not save it
                if ($taxes_type == 'bands') {
                    if (empty($tax_rate['name']) || in_array($tax_rate['name'], $exists) || $tax_rate['name'] == 'Disabled') {
                        continue;
                    } else {
                        $exists[] = $tax_rate['name'];
                        $saved_rates[] = $tax_rate;
                    }
                    // if
                }
                // if
                //rates - check the shipping checkbox
                if ($taxes_type == 'rates') {
                    //if there is no rate then skip
                    if (empty($tax_rate['rate'])) {
                        continue;
                    }
                    $tax_rate['shipping'] = isset($tax_rate['shipping']) ? 1 : 0;
                    //check if country exists
                    if (array_key_exists($tax_rate['country_code'], $exists)) {
                        //if region already exists skip
                        if (array_search($tax_rate['region_code'], $exists[$tax_rate['country_code']]) == $tax_rate['country_code']) {
                            continue;
                        } else {
                            //it's not in the array add it
                            $exists[$tax_rate['country_code']][] = $tax_rate['region_code'];
                            //save it
                            $saved_rates[] = $tax_rate;
                        }
                        // if
                    } else {
                        //add codes to exists array
                        $exists[$tax_rate['country_code']][] = $tax_rate['region_code'];
                        //save it
                        $saved_rates[] = $tax_rate;
                    }
                    // if
                }
                // if
            }
            // foreach
        }
        // if
        //replace post tax rates with filtered rates
        $_POST['wpsc_options']['wpec_taxes_' . $taxes_type] = $saved_rates;
    }
    // foreach
    //submit options using built in functions
    wpsc_submit_options();
}