public function column_tax($item)
    {
        $meta = get_post_meta($item->ID, '_wpsc_product_metadata', true);
        if (!$meta || !isset($meta['wpec_taxes_taxable_amount'])) {
            $tax = '';
        } else {
            $tax = wpsc_format_number($meta['wpec_taxes_taxable_amount']);
        }
        ?>
			<input type="text" name="wpsc_variations[<?php 
        echo $item->ID;
        ?>
][product_metadata][wpec_taxes_taxable_amount]" value="<?php 
        echo esc_attr($tax);
        ?>
" />
		<?php 
    }
/**
 * Product Shipping Forms
 *
 * @uses  wpsc_validate_weight_unit()
 * @uses  wpsc_validate_dimension_unit()
 */
function wpsc_product_shipping_forms($product = false, $field_name_prefix = 'meta[_wpsc_product_metadata]', $bulk = false)
{
    if (!$product) {
        $product_id = get_the_ID();
    } else {
        $product_id = $product->ID;
    }
    $meta = get_post_meta($product_id, '_wpsc_product_metadata', true);
    if (!is_array($meta)) {
        $meta = array();
    }
    $defaults = array('weight' => '', 'weight_unit' => wpsc_validate_weight_unit(), 'demension_unit' => wpsc_validate_dimension_unit(), 'dimensions' => array(), 'shipping' => array(), 'no_shipping' => '', 'display_weight_as' => '');
    $dimensions_defaults = array('height' => 0, 'width' => 0, 'length' => 0);
    $shipping_defaults = array('local' => '', 'international' => '');
    $meta = array_merge($defaults, $meta);
    $meta['dimensions'] = array_merge($dimensions_defaults, $meta['dimensions']);
    $meta['shipping'] = array_merge($shipping_defaults, $meta['shipping']);
    extract($meta, EXTR_SKIP);
    foreach ($shipping as $key => &$val) {
        $val = wpsc_format_number($val);
    }
    $weight = wpsc_convert_weight($weight, 'pound', $weight_unit);
    $dimension_units = wpsc_dimension_units();
    $weight_units = wpsc_weight_units();
    // Why we need this????
    $measurements = $dimensions;
    $measurements['weight'] = $weight;
    $measurements['weight_unit'] = $weight_unit;
    // End why
    ?>
	<div class="wpsc-stock-editor<?php 
    if ($bulk) {
        echo ' wpsc-bulk-edit';
    }
    ?>
">
		<p class="wpsc-form-field">
			<input type="checkbox" id="wpsc-product-no-shipping" name="<?php 
    echo esc_attr($field_name_prefix);
    ?>
[no_shipping]" value="1" <?php 
    checked($no_shipping && !$bulk);
    ?>
>
			<label for="wpsc-product-no-shipping"><?php 
    _e('Product will <em>not</em> be shipped to customer', 'wp-e-commerce');
    ?>
</label>
		</p>

		<div class="wpsc-product-shipping-section wpsc-product-shipping-weight-dimensions">
			<p><strong><?php 
    esc_html_e('Calculate Shipping Costs based on measurements', 'wp-e-commerce');
    ?>
</strong></p>

			<!-- WEIGHT INPUT -->
			<p class="wpsc-form-field">
				<?php 
    if ($bulk) {
        ?>
					<input class="wpsc-bulk-edit-fields" type="checkbox" name="wpsc_bulk_edit[fields][measurements][weight]" value="1" />
				<?php 
    }
    ?>
				<label for="wpsc-product-shipping-weight"><?php 
    echo esc_html_e('Weight', 'wp-e-commerce');
    ?>
</label>
				<span class="wpsc-product-shipping-input">
					<input type="text" id="wpsc-product-shipping-weight" name="<?php 
    echo esc_attr($field_name_prefix);
    ?>
[weight]" value="<?php 
    if (!$bulk) {
        echo esc_attr(wpsc_format_number($weight));
    }
    ?>
" />
					<select id="wpsc-product-shipping-weight-unit" name="<?php 
    echo $field_name_prefix;
    ?>
[weight_unit]">
							<?php 
    foreach ($weight_units as $unit => $unit_label) {
        ?>
								<option value="<?php 
        echo esc_attr($unit);
        ?>
" <?php 
        if (!$bulk) {
            selected($unit, $measurements['weight_unit']);
        }
        ?>
><?php 
        echo esc_html($unit_label);
        ?>
</option>
							<?php 
    }
    ?>
						</select>
				</span>
			</p>
			<!-- END WEIGHT INPUT -->

			<!-- DIMENSIONS INPUT -->
			<p class="wpsc-form-field">
				<?php 
    if ($bulk) {
        ?>
					<input class="wpsc-bulk-edit-fields" type="checkbox" name="wpsc_bulk_edit[fields][measurements][dimensions]" value="1" />
				<?php 
    }
    ?>
				<label for="wpsc-product-shipping-weight"><?php 
    echo esc_html_e('Dimensions', 'wp-e-commerce');
    ?>
</label>
				<span class="wpsc-product-shipping-input">
					<input placeholder="L" type="text" id="wpsc-product-shipping-length" name="<?php 
    echo esc_attr($field_name_prefix);
    ?>
[dimensions][length]" value="<?php 
    if (!$bulk && $dimensions['length'] > 0) {
        echo esc_attr(wpsc_format_number($dimensions['length']));
    }
    ?>
" />&nbsp;&times;&nbsp;
					<input placeholder="W" type="text" id="wpsc-product-shipping-width" name="<?php 
    echo esc_attr($field_name_prefix);
    ?>
[dimensions][width]" value="<?php 
    if (!$bulk && $dimensions['width'] > 0) {
        echo esc_attr(wpsc_format_number($dimensions['width']));
    }
    ?>
" />&nbsp;&times;&nbsp;
					<input placeholder="H" type="text" id="wpsc-product-shipping-height" name="<?php 
    echo esc_attr($field_name_prefix);
    ?>
[dimensions][height]" value="<?php 
    if (!$bulk && $dimensions['height'] > 0) {
        echo esc_attr(wpsc_format_number($dimensions['height']));
    }
    ?>
" />
					<select id="wpsc-product-shipping-dimensions-unit" name="<?php 
    echo $field_name_prefix;
    ?>
[dimension_unit]">
						<?php 
    foreach ($dimension_units as $unit => $unit_label) {
        ?>
							<option value="<?php 
        echo esc_attr($unit);
        ?>
" <?php 
        if (!$bulk && isset($meta['dimension_unit'])) {
            selected($unit, $meta['dimension_unit']);
        }
        // Dirty code
        ?>
><?php 
        echo esc_html($unit_label);
        ?>
</option>
						<?php 
    }
    ?>
					</select>
				</span>
			</p>
			<!-- END DEMENSION INPUT -->

		</div>

		<?php 
    $currency_type = get_option('currency_type');
    $country = new WPSC_Country($currency_type);
    $ct_symb = $country->get_currency_symbol_html();
    ?>

		<div class="wpsc-product-shipping-section wpsc-product-shipping-flat-rate">
			<p><strong><?php 
    esc_html_e('Flat Rate Settings', 'wp-e-commerce');
    ?>
</strong></p>
			<p class="wpsc-form-field">
				<?php 
    if ($bulk) {
        ?>
					<input class="wpsc-bulk-edit-fields" type="checkbox" name="wpsc_bulk_edit[fields][shipping][local]" value="1" />
				<?php 
    }
    ?>
				<label for="wpsc-product-shipping-flatrate-local"><?php 
    esc_html_e('Local Shipping Fee', 'wp-e-commerce');
    ?>
</label>
				<span>
					<?php 
    echo esc_html($ct_symb);
    ?>
					<input type="text" id="wpsc-product-shipping-flatrate-local" name="<?php 
    echo esc_html($field_name_prefix);
    ?>
[shipping][local]" value="<?php 
    if (!$bulk) {
        echo $shipping['local'];
    }
    ?>
"  />
				</span>
			</p>
			<p class="wpsc-form-field">
				<?php 
    if ($bulk) {
        ?>
					<input class="wpsc-bulk-edit-fields" type="checkbox" name="wpsc_bulk_edit[fields][shipping][international]" value="1" />
				<?php 
    }
    ?>
				<label for="wpsc-product-shipping-flatrate-international"><?php 
    esc_html_e('International Shipping Fee', 'wp-e-commerce');
    ?>
</label>
				<span>
					<?php 
    echo esc_html($ct_symb);
    ?>
					<input type="text" id="wpsc-product-shipping-flatrate-international" name="<?php 
    echo esc_html($field_name_prefix);
    ?>
[shipping][international]" value="<?php 
    if (!$bulk) {
        echo $shipping['international'];
    }
    ?>
"  />
				</span>
			</p>
		</div>
	</div>
	<?php 
    wp_nonce_field('update', 'wpsc_product_shipping_nonce');
}
Example #3
0
    public function display()
    {
        global $wpdb, $wpsc_shipping_modules, $external_shipping_modules, $internal_shipping_modules;
        // sort into external and internal arrays.
        foreach ($GLOBALS['wpsc_shipping_modules'] as $key => $module) {
            if (empty($module)) {
                continue;
            }
            if (isset($module->is_external) && $module->is_external) {
                $external_shipping_modules[$key] = $module;
            } else {
                $internal_shipping_modules[$key] = $module;
            }
        }
        ?>

		<h3><?php 
        esc_html_e('Shipping Settings', 'wp-e-commerce');
        ?>
</h3>
		<input type='hidden' name='shipping_submits' value='true' />
		<?php 
        wp_nonce_field('update-options', 'wpsc-update-options');
        ?>
		<input type='hidden' name='wpsc_admin_action' value='submit_options' />
		<table class='form-table'>
			<?php 
        /* wpsc_setting_page_update_notification displays the wordpress styled notifications */
        wpsc_settings_page_update_notification();
        ?>
			<tr>
				<th scope="row"><?php 
        _e('Use Shipping', 'wp-e-commerce');
        ?>
</th>
				<td>
					<input type='hidden' value='1' name='wpsc_options[do_not_use_shipping]' />
					<input type='checkbox' value='0' name='wpsc_options[do_not_use_shipping]' id='do_not_use_shipping' <?php 
        checked('0', get_option('do_not_use_shipping'));
        ?>
 /> <label for='do_not_use_shipping'><?php 
        _e('Enable Shipping settings', 'wp-e-commerce');
        ?>
</label>
					<p class='description'><?php 
        esc_html_e('If you are only selling digital downloads, you should turn this off.', 'wp-e-commerce');
        ?>
</p>
				</td>
			</tr>

			<tr>
				<th><?php 
        esc_html_e('Shipping Origin City', 'wp-e-commerce');
        ?>
</th>
				<td>
					<input type='text' name='wpsc_options[base_city]' value='<?php 
        echo esc_attr(get_option('base_city'));
        ?>
' />
					<p class='description'><?php 
        esc_html_e('The name of the city where you fulfill and ship orders from. This enables us to give your customers more accurate shipping pricing.', 'wp-e-commerce');
        ?>
</p>
				</td>
			</tr>
			<tr>
				<th><?php 
        esc_html_e('Shipping Origin Zipcode/Postcode', 'wp-e-commerce');
        ?>
</th>
				<td>
					<input type='text' name='wpsc_options[base_zipcode]' value='<?php 
        echo esc_attr(get_option('base_zipcode'));
        ?>
' />
					<p class='description'>
						<?php 
        esc_html_e('The ZIP code / Postal code from where you fulfill and ship orders.', 'wp-e-commerce');
        ?>
<br />
						<?php 
        esc_html_e('If you are based in the United States, then this field is required in order for the UPS and USPS Shipping Calculators to work.', 'wp-e-commerce');
        ?>
					</p>
				</td>
			</tr>
			<tr>
				<th scope="row"><?php 
        _e('Shipwire', 'wp-e-commerce');
        ?>
<span style='color: red;'></span></th>
				<td>
					<input type='hidden' value='0' name='wpsc_options[shipwire]' />
					<input type='checkbox' onclick='jQuery("#wpsc_shipwire_setting").toggle( jQuery(this).prop("checked") );' value='1' name='wpsc_options[shipwire]' id='shipwire' <?php 
        checked('1', get_option('shipwire'));
        ?>
 />
					<label for='shipwire'><?php 
        _e('Enable Shipwire Integration', 'wp-e-commerce');
        ?>
</label>
					<p class='description'><?php 
        printf(__('<a href="%1$s" target="_blank">Shipwire</a> provide e-commerce fulfillment warehouses. WP eCommerce can integrate stock inventory and shipping tracking with their service.', 'wp-e-commerce'), 'http://www.shipwire.com/pp/o.php?id=11922');
        ?>
</p>
				</td>
			</tr>
			<?php 
        switch (get_option('shipwire')) {
            case 1:
                $shipwire_settings = '';
                break;
            case 0:
            default:
                $shipwire_settings = 'style="display: none;"';
                break;
        }
        ?>
			<tr id='wpsc_shipwire_setting' <?php 
        echo $shipwire_settings;
        ?>
>
				<th>&nbsp;</th>
				<td>
					<table>
						<tr>
							<th><?php 
        esc_html_e('Shipwire Email', 'wp-e-commerce');
        ?>
</th>
							<td><input type="text" name='wpsc_options[shipwireemail]' value="<?php 
        echo esc_attr(get_option('shipwireemail'));
        ?>
" /></td>
						</tr>
						<tr>
							<th><?php 
        esc_html_e('Shipwire Password', 'wp-e-commerce');
        ?>
</th>
							<td><input type="text" name='wpsc_options[shipwirepassword]' value="<?php 
        echo esc_attr(get_option('shipwirepassword'));
        ?>
" /></td>
						</tr>
						<tr>
							<th><?php 
        esc_html_e('Use Test Server?', 'wp-e-commerce');
        ?>
</th>
							<td><input type="checkbox" name='wpsc_options[shipwire_test_server]' value="0" <?php 
        checked('1', get_option('shipwire_test_server', '0'));
        ?>
 /></td>
						</tr>
						<tr>
							<th><?php 
        esc_html_e('Force Sync with Shipwire', 'wp-e-commerce');
        ?>
</th>
							<td>
								<a class="shipwire_sync button"><?php 
        esc_html_e('Update Tracking and Inventory', 'wp-e-commerce');
        ?>
</a>
								<img src="<?php 
        echo esc_url(wpsc_get_ajax_spinner());
        ?>
" class="ajax-feedback" title="" alt="" />
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<?php 
        $currency_data = WPSC_Countries::get_currency_data(get_option('currency_type'), true);
        if ($currency_data['symbol'] != '') {
            $currency_sign = $currency_data['symbol_html'];
        } else {
            $currency_sign = $currency_data['code'];
        }
        ?>
			<tr>
				<th><?php 
        _e('Free Shipping Discount', 'wp-e-commerce');
        ?>
</th>
				<td>
					<?php 
        if (get_option('shipping_discount') == 1) {
            $shipping_discount_settings = 'style=\'display: block;\'';
        } else {
            $shipping_discount_settings = '';
        }
        ?>
					<input type='hidden' value='0' name='wpsc_options[shipping_discount]' />
					<input type='checkbox' onclick='jQuery("#shipping_discount_value").toggle( jQuery(this).prop("checked") );' value='1' name='wpsc_options[shipping_discount]' id='shipping_discount' <?php 
        checked('1', get_option('shipping_discount'));
        ?>
 />
					<label for='shipping_discount'><?php 
        _e('Enable Free Shipping Discount', 'wp-e-commerce');
        ?>
</label>

				</td>
			</tr>
			<tr>
				<td>&nbsp;</td>
				<td colspan="2">
					<?php 
        $value = wpsc_format_number(get_option('shipping_discount_value'));
        ?>
					<div <?php 
        echo $shipping_discount_settings;
        ?>
 id='shipping_discount_value'>

					<?php 
        printf(__('Sales over or equal to %1$s<input type="text" size="6" name="wpsc_options[shipping_discount_value]" value="%2$s" id="shipping_discount_value" /> will receive free shipping.', 'wp-e-commerce'), $currency_sign, esc_attr($value));
        ?>
					</div>
				</td>
			</tr>
		</table>

		<?php 
        submit_button(__('Save Changes', 'wp-e-commerce'));
        ?>

		<h3><?php 
        _e('Shipping Modules', 'wp-e-commerce');
        ?>
</h3>
		<p class='description'><?php 
        _e('To enable shipping in WP eCommerce you must select which shipping methods you want to enable on your site.', 'wp-e-commerce');
        ?>
</p>
		<p class='description'>
			<strong><?php 
        _e('Tip', 'wp-e-commerce');
        ?>
</strong>:
			<?php 
        printf(__('For fixed-price shipping options such as "Pickup - $0, Overnight - $10, Same day - $20, etc.", install our free <a href="%1$s">Fixed Rate Shipping</a> plugin.', 'wp-e-commerce'), 'http://wordpress.org/extend/plugins/wp-e-commerce-fixed-rate-shipping/');
        ?>
		</p>

		<h4><?php 
        _e('Internal Shipping Calculators', 'wp-e-commerce');
        ?>
</h4>
		<table id='wpsc-shipping-options-internal' class='wpsc-edit-module-options wp-list-table widefat plugins'>
			<thead>
				<tr>
					<th scope="col" id="wpsc-shipping-options-internal-active" class="manage-column"><?php 
        _e('Active', 'wp-e-commerce');
        ?>
</th>
					<th scope="col" id="wpsc-shipping-options-internal-name" class="manage-column column-name"><?php 
        _e('Shipping Calculator', 'wp-e-commerce');
        ?>
</th>
				</tr>
			</thead>
			<tfoot>
				<tr>
					<th scope="col" id="wpsc-shipping-options-internal-active" class="manage-column"><?php 
        _e('Active', 'wp-e-commerce');
        ?>
</th>
					<th scope="col" id="wpsc-shipping-options-internal-name" class="manage-column column-name"><?php 
        _e('Shipping Calculator', 'wp-e-commerce');
        ?>
</th>
				</tr>
			</tfoot>
			<tbody>
				<?php 
        foreach ($internal_shipping_modules as $shipping) {
            $force = $shipping->getInternalName() === (string) get_user_option('wpsc_settings_selected_shipping_module', get_current_user_id());
            $this->shipping_list_item($shipping, $force);
        }
        ?>
			</tbody>
		</table>
		<?php 
        submit_button(__('Save Changes', 'wp-e-commerce'));
        ?>

		<h4><?php 
        _e('External Shipping Calculators', 'wp-e-commerce');
        ?>
</h4>
		<?php 
        if (!function_exists('curl_init')) {
            ?>
			<p style='color: red; font-size:8pt; line-height:10pt;'>
				<?php 
            _e('The following shipping modules all need cURL which is not installed on this server. You may need to contact your web hosting provider to get it set up. ', 'wp-e-commerce');
            ?>
			</p>
		<?php 
        }
        ?>
		<table id='wpsc-shipping-options-external' class='wpsc-edit-module-options wp-list-table widefat plugins'>
			<thead>
				<tr>
					<th scope="col" id="wpsc-shipping-options-external-active" class="manage-column"><?php 
        _e('Active', 'wp-e-commerce');
        ?>
</th>
					<th scope="col" id="wpsc-shipping-options-external-name" class="manage-column column-name"><?php 
        _e('Shipping Calculator', 'wp-e-commerce');
        ?>
</th>
				</tr>
			</thead>
			<tfoot>
				<tr>
					<th scope="col" id="wpsc-shipping-options-external-active" class="manage-column"><?php 
        _e('Active', 'wp-e-commerce');
        ?>
</th>
					<th scope="col" id="wpsc-shipping-options-external-name" class="manage-column column-name"><?php 
        _e('Shipping Calculator', 'wp-e-commerce');
        ?>
</th>
				</tr>
			</tfoot>
			<tbody>
				<?php 
        foreach ($external_shipping_modules as $shipping) {
            $force = $shipping->getInternalName() === (string) get_user_option('wpsc_settings_selected_shipping_module', get_current_user_id());
            $this->shipping_list_item($shipping, $force);
        }
        ?>
			</tbody>
		</table>
		<?php 
    }
/**
 * wpsc_currency_display function.
 *
 * @access public
 * @param mixed $price_in
 * @param mixed $args
 * @return string
 */
function wpsc_currency_display($price_in, $args = null)
{
    global $wpdb;
    $currency_code = '';
    $args = apply_filters('wpsc_toggle_display_currency_code', $args);
    $query = shortcode_atts(array('display_currency_symbol' => true, 'display_decimal_point' => true, 'display_currency_code' => false, 'display_as_html' => true, 'isocode' => false), $args);
    // No decimal point, no decimals
    if (false == $query['display_decimal_point']) {
        $decimals = 0;
    } else {
        $decimals = 2;
    }
    // default is 2
    $decimals = apply_filters('wpsc_modify_decimals', $decimals);
    // Format the price for output
    $price_out = wpsc_format_number($price_in, $decimals);
    // Get currency settings
    $currency_type = get_option('currency_type');
    if (!$query['isocode']) {
        // @todo: can deprecate this caching because the WPSC_Countries class already caches the data
        if (!($wpsc_currency_data = wp_cache_get($currency_type, 'wpsc_currency_id'))) {
            $wpsc_currency_data = WPSC_Countries::get_currency_data($currency_type, true);
            wp_cache_set($currency_type, $wpsc_currency_data, 'wpsc_currency_id');
        }
    } elseif (!($wpsc_currency_data = wp_cache_get($query['isocode'], 'wpsc_currency_isocode'))) {
        $wpsc_currency_data = WPSC_Countries::get_currency_data($currency_type, true);
        wp_cache_set($query['isocode'], $wpsc_currency_data, 'wpsc_currency_isocode');
    }
    // Figure out the currency code
    if ($query['display_currency_code']) {
        $currency_code = $wpsc_currency_data['code'];
    }
    // Figure out the currency sign
    $currency_sign = '';
    if ($query['display_currency_symbol']) {
        if (!empty($wpsc_currency_data['symbol'])) {
            if ($query['display_as_html'] && !empty($wpsc_currency_data['symbol_html'])) {
                $currency_sign = $wpsc_currency_data['symbol_html'];
            } else {
                $currency_sign = $wpsc_currency_data['symbol'];
            }
        } else {
            $currency_sign = $wpsc_currency_data['code'];
            $currency_code = '';
        }
    }
    $currency_sign_location = get_option('currency_sign_location');
    // Rejig the currency sign location
    switch ($currency_sign_location) {
        case 1:
            $format_string = '%3$s%1$s%2$s';
            break;
        case 2:
            $format_string = '%3$s %1$s%2$s';
            break;
        case 4:
            $format_string = '%1$s%2$s  %3$s';
            break;
        case 3:
        default:
            $format_string = '%1$s %2$s%3$s';
            break;
    }
    // Compile the output
    $output = trim(sprintf($format_string, $currency_code, $currency_sign, $price_out));
    if (!$query['display_as_html']) {
        $output = "" . $output . "";
    } else {
        $output = "<span class='pricedisplay'>" . $output . "</span>";
    }
    // Return results
    return apply_filters('wpsc_currency_display', $output);
}