/** * create_eu_countries_vat_rates_tool. * * @version 2.3.10 * @since 2.3.10 */ function create_eu_countries_vat_rates_tool($header_html) { $the_tool_html = ''; $the_tool_html .= $header_html; // $the_tool_html .= '<h4>' . __( 'Settings', 'woocommerce-jetpack' ) . '</h4>'; $data = array(); $the_name = isset($_POST['wcj_tax_name']) ? $_POST['wcj_tax_name'] : __('VAT', 'woocommerce'); $data[] = array(__('Name', 'woocommerce-jetpack'), '<input class="input-text" type="text" name="wcj_tax_name" value="' . $the_name . '">'); $data[] = array('', '<input class="button-primary" type="submit" name="add_eu_countries_vat_rates" value="' . __('Add EU Countries VAT Rates', 'woocommerce-jetpack') . '">' . ' ' . __('Note: will add duplicates.', 'woocommerce-jetpack')); $the_tool_html .= '<p>'; $the_tool_html .= '<form method="post" action="">'; $the_tool_html .= wcj_get_table_html($data, array('table_heading_type' => 'vertical')); $the_tool_html .= '</form>'; $the_tool_html .= '</p>'; $the_tool_html .= '<h4>' . __('List of EU VAT rates to be added', 'woocommerce-jetpack') . '</h4>'; $eu_vat_rates = wcj_get_european_union_countries_with_vat(); $data = array(); $data[] = array('', __('Country', 'woocommerce-jetpack'), __('Rate', 'woocommerce-jetpack')); $i = 1; foreach ($eu_vat_rates as $country => $rate) { $data[] = array($i++, $country . ' - ' . wcj_get_country_name_by_code($country), $rate . '%'); } $the_tool_html .= wcj_get_table_html($data, array('table_class' => 'widefat', 'table_style' => 'width:50%;min-width:300px;')); $the_tool_html .= '<h4>' . __('Current standard tax rates', 'woocommerce-jetpack') . '</h4>'; $standard_tax_rates = wcj_get_rates_for_tax_class(''); $data = array(); $data[] = array('', __('Country', 'woocommerce-jetpack'), __('Rate', 'woocommerce-jetpack'), __('Name', 'woocommerce-jetpack')); $i = 1; foreach ($standard_tax_rates as $tax_rate_object) { $data[] = array($i++, $tax_rate_object->tax_rate_country . ' - ' . wcj_get_country_name_by_code($tax_rate_object->tax_rate_country), $tax_rate_object->tax_rate . '%', $tax_rate_object->tax_rate_name); } $the_tool_html .= wcj_get_table_html($data, array('table_class' => 'widefat', 'table_style' => 'width:75%;min-width:300px;')); echo $the_tool_html; }
/** * wcj_customer_shipping_country. * * @version 2.5.8 * @since 2.5.8 */ function wcj_customer_shipping_country($atts) { if (is_user_logged_in()) { $current_user = wp_get_current_user(); if ('' != ($meta = get_user_meta($current_user->ID, 'shipping_country', true))) { return 'yes' === $atts['full_country_name'] ? wcj_get_country_name_by_code($meta) : $meta; } } return ''; }
/** * get_settings. */ function get_settings() { $settings = array(); // Force country display $settings[] = array('title' => __('Force Base Country Display', 'woocommerce-jetpack'), 'type' => 'title', 'desc' => __('Force Base Country Display Options.', 'woocommerce-jetpack'), 'id' => 'wcj_address_formats_force_country_display_options'); $settings[] = array('title' => __('Force Base Country Display', 'woocommerce-jetpack'), 'id' => 'wcj_address_formats_force_country_display', 'default' => 'no', 'type' => 'checkbox'); $settings[] = array('type' => 'sectionend', 'id' => 'wcj_address_formats_force_country_display_options'); // Formats by Country $settings[] = array('title' => __('Address Formats by Country', 'woocommerce-jetpack'), 'type' => 'title', 'desc' => __('Address Formats by Country Options.', 'woocommerce-jetpack'), 'id' => 'wcj_address_formats_country_options'); // $formats = apply_filters( 'wcj_get_address_formats_filter', array() ); // $formats = WC()->countries->get_address_formats(); $formats = $this->get_default_address_formats(); foreach ($formats as $country_code => $format) { $settings[] = array('title' => 'default' === $country_code ? $country_code : $country_code . ' - ' . wcj_get_country_name_by_code($country_code), 'id' => 'wcj_address_formats_country_' . $country_code, 'default' => $format, 'type' => 'textarea', 'css' => 'width:300px;height:200px;'); } $settings[] = array('type' => 'sectionend', 'id' => 'wcj_address_formats_country_options'); return $this->add_enable_module_setting($settings); }
/** * Output custom columns for orders * @param string $column */ public function render_order_columns($column) { if ('country' != $column) { return; } $order = wc_get_order(get_the_ID()); //$country_code = wcj_get_customer_country( $order->customer_user ); $country_code = $order->billing_country; echo 2 == strlen($country_code) ? $this->wcj_get_country_flag_by_code($country_code) . ' ' . wcj_get_country_name_by_code($country_code) : wcj_get_country_name_by_code($country_code); }
/** * Output custom columns for orders * * @version 2.5.3 * @param string $column */ public function render_order_columns($column) { if ('country' === $column && 'yes' === get_option('wcj_orders_list_custom_columns_country', 'no')) { $order = wc_get_order(get_the_ID()); // $country_code = wcj_get_customer_country( $order->customer_user ); $country_code = $order->billing_country; echo 2 == strlen($country_code) ? $this->wcj_get_country_flag_by_code($country_code) . ' ' . wcj_get_country_name_by_code($country_code) : wcj_get_country_name_by_code($country_code); } $total_number = apply_filters('booster_get_option', 1, get_option('wcj_orders_list_custom_columns_total_number', 1)); for ($i = 1; $i <= $total_number; $i++) { if ('yes' === get_option('wcj_orders_list_custom_columns_enabled_' . $i, 'no')) { if ('wcj_orders_custom_column_' . $i === $column) { echo do_shortcode(get_option('wcj_orders_list_custom_columns_value_' . $i, '')); } } } }
/** * get_data function. */ public function get_html($data, $total_customers, $report_type = 'all_countries') { $html = ''; if ('all_countries' === $report_type) { $html .= '<h5>' . __('Total customers', 'woocommerce-jetpack') . ': ' . $total_customers . '</h5>'; $html .= '<table class="widefat" style="width:100% !important;"><tbody>'; $html .= '<tr>'; $html .= '<th></th>'; //'<th>' . __( 'Country Flag', 'woocommerce-jetpack' ) . '</th>'; $html .= '<th>' . __('Country Code', 'woocommerce-jetpack') . '</th>'; $html .= '<th>' . __('Customers Count', 'woocommerce-jetpack') . '</th>'; $html .= '<th>' . __('Percent of total', 'woocommerce-jetpack') . '</th>'; $html .= '<th></th>'; $html .= '<th></th>'; $html .= '</tr>'; $i = 0; foreach ($data as $country_code => $result) { $result = $result['customer_counter']; $html .= '<tr>'; $html .= '<td>' . ++$i . '</td>'; $country_code_link = '<a href="' . add_query_arg(array('country' => $country_code)) . '">' . $country_code . '</a>'; $html .= 2 == strlen($country_code) ? '<td>' . $country_code_link . '</td>' : '<td>' . $country_code . '</td>'; $html .= '<td>' . $result . '</td>'; $html .= 0 != $total_customers ? '<td>' . number_format($result / $total_customers * 100, 2) . '%' . '</td>' : '<td></td>'; $country_flag_img = '<img src="' . plugins_url() . '/' . 'woocommerce-jetpack' . '/assets/images/flag-icons/' . strtolower($country_code) . '.png" title="' . wcj_get_country_name_by_code($country_code) . '">'; $country_flag_img_link = '<a href="' . add_query_arg(array('country' => $country_code)) . '">' . $country_flag_img . ' ' . wcj_get_country_name_by_code($country_code) . '</a>'; $html .= 2 == strlen($country_code) ? '<td>' . $country_flag_img_link . '</td>' : '<td></td>'; $html .= '</tr>'; } $html .= '</tbody></table>'; } else { //if ( 'single_country' === $report_type ) { $country_code = $report_type; $html .= '<h5>' . __('Report for:', 'woocommerce-jetpack') . ' ' . wcj_get_country_name_by_code($country_code) . ' [' . $country_code . ']' . '</h5>'; $html .= 2 == strlen($country_code) ? wcj_get_table_html($data[$country_code]['total_spent'], array('table_class' => 'widefat')) : ''; } return $html; }