function wpsc_product_taxes_forms() { global $post, $wpdb, $wpsc_product_defaults; $product_data = get_post_custom($post->ID); $product_data['meta'] = $product_meta = array(); if (!empty($product_data['_wpsc_product_metadata'])) { $product_data['meta'] = $product_meta = maybe_unserialize($product_data['_wpsc_product_metadata'][0]); } if (!isset($product_data['meta']['_wpsc_custom_tax'])) { $product_data['meta']['_wpsc_custom_tax'] = ''; } $custom_tax = $product_data['meta']['_wpsc_custom_tax']; if (!isset($product_meta['custom_tax'])) { $product_meta['custom_tax'] = 0.0; } //Add New WPEC-Taxes Bands Here $wpec_taxes_controller = new wpec_taxes_controller(); //display tax bands $band_select_settings = array('id' => 'wpec_taxes_band', 'name' => 'meta[_wpsc_product_metadata][wpec_taxes_band]', 'label' => __('Custom Tax Band', 'wp-e-commerce')); $wpec_taxes_band = ''; if (isset($product_meta['wpec_taxes_band'])) { $band = $wpec_taxes_controller->wpec_taxes->wpec_taxes_get_band_from_index($product_meta['wpec_taxes_band']); $wpec_taxes_band = array('index' => $band['index'], 'name' => $band['name']); } $taxable_checkbox_settings = array('type' => 'checkbox', 'id' => 'wpec_taxes_taxable', 'name' => 'meta[_wpsc_product_metadata][wpec_taxes_taxable]', 'label' => __('Product is exempt from taxation.', 'wp-e-commerce')); if (isset($product_meta['wpec_taxes_taxable']) && 'on' == $product_meta['wpec_taxes_taxable']) { $taxable_checkbox_settings['checked'] = 'checked'; } //add taxable amount only for exclusive tax if (!$wpec_taxes_controller->wpec_taxes_isincluded()) { $taxable_amount_input_settings = array('id' => 'wpec_taxes_taxable_amount', 'name' => 'meta[_wpsc_product_metadata][wpec_taxes_taxable_amount]', 'label' => __('Taxable Amount', 'wp-e-commerce'), 'description' => __('Taxable amount in your currency, not percentage of price.', 'wp-e-commerce')); if (isset($product_meta['wpec_taxes_taxable_amount'])) { $taxable_amount_input_settings['value'] = $product_meta['wpec_taxes_taxable_amount']; if (!empty($product_meta['wpec_taxes_taxable_amount'])) { $taxable_amount_input_settings['value'] = wpsc_format_number($taxable_amount_input_settings['value']); } } } // if $output = '<a name="wpsc_tax"></a>'; $output .= '<p>' . $wpec_taxes_controller->wpec_taxes_build_input($taxable_checkbox_settings) . '</p>'; $output .= '<p>' . $wpec_taxes_controller->wpec_taxes_display_tax_bands($band_select_settings, $wpec_taxes_band) . '</p>'; $output .= '<p>'; $output .= !$wpec_taxes_controller->wpec_taxes_isincluded() ? $wpec_taxes_controller->wpec_taxes_build_input($taxable_amount_input_settings) : ''; $output .= '</p>'; if (!$wpec_taxes_controller->wpec_taxes->wpec_taxes_get_enabled()) { $output = '<p>' . sprintf(__('Taxes are not enabled. See <a href="%s">Settings > Taxes</a>', 'wp-e-commerce'), admin_url('options-general.php?page=wpsc-settings&tab=taxes')) . '</p>'; } echo $output; wp_nonce_field('update', 'wpsc_product_tax_nonce'); }
function wpsc_product_taxes_forms() { global $post, $wpdb, $wpsc_product_defaults; $product_data = get_post_custom($post->ID); $product_data['meta'] = $product_meta = array(); if (!empty($product_data['_wpsc_product_metadata'])) { $product_data['meta'] = $product_meta = maybe_unserialize($product_data['_wpsc_product_metadata'][0]); } if (!isset($product_data['meta']['_wpsc_custom_tax'])) { $product_data['meta']['_wpsc_custom_tax'] = ''; } $custom_tax = $product_data['meta']['_wpsc_custom_tax']; if (!isset($product_meta['custom_tax'])) { $product_meta['custom_tax'] = 0.0; } //Add New WPEC-Taxes Bands Here $wpec_taxes_controller = new wpec_taxes_controller(); //display tax bands $band_select_settings = array('id' => 'wpec_taxes_band', 'name' => 'meta[_wpsc_product_metadata][wpec_taxes_band]', 'label' => __('Custom Tax Band', 'wpsc')); $wpec_taxes_band = ''; if (isset($product_meta['wpec_taxes_band'])) { $band = $wpec_taxes_controller->wpec_taxes->wpec_taxes_get_band_from_index($product_meta['wpec_taxes_band']); $wpec_taxes_band = array('index' => $band['index'], 'name' => $band['name']); } $taxable_checkbox_settings = array('type' => 'checkbox', 'id' => 'wpec_taxes_taxable', 'name' => 'meta[_wpsc_product_metadata][wpec_taxes_taxable]', 'label' => __('This product is not taxable.', 'wpsc')); if (isset($product_meta['wpec_taxes_taxable']) && 'on' == $product_meta['wpec_taxes_taxable']) { $taxable_checkbox_settings['checked'] = 'checked'; } //add taxable amount only for exclusive tax if (!$wpec_taxes_controller->wpec_taxes_isincluded()) { $taxable_amount_input_settings = array('id' => 'wpec_taxes_taxable_amount', 'name' => 'meta[_wpsc_product_metadata][wpec_taxes_taxable_amount]', 'label' => __('Taxable Amount', 'wpsc'), 'description' => __('Taxable amount in your currency, not percentage of price.', 'wpsc')); if (isset($product_meta['wpec_taxes_taxable_amount'])) { $taxable_amount_input_settings['value'] = $product_meta['wpec_taxes_taxable_amount']; } } // if ?> <a name="wpsc_tax"></a> <p><?php echo $wpec_taxes_controller->wpec_taxes_display_tax_bands($band_select_settings, $wpec_taxes_band); ?> </p> <p> <?php if (!$wpec_taxes_controller->wpec_taxes_isincluded()) { ?> <?php echo $wpec_taxes_controller->wpec_taxes_build_input($taxable_amount_input_settings); ?> <?php } ?> </p> <p><?php echo $wpec_taxes_controller->wpec_taxes_build_input($taxable_checkbox_settings); ?> </p> <?php }