Automattic\WooCommerce\Admin\Features\Blueprint\Exporters

ExportWCTaxRates{}WC 1.0

Class ExportWCTaxRates

This class exports WooCommerce tax rates and implements the StepExporter interface.

Хуков нет.

Использование

$ExportWCTaxRates = new ExportWCTaxRates();
// use class methods

Методы

  1. public export()
  2. public get_description()
  3. public get_label()
  4. public get_step_name()

Заметки

  • Пакет: Automattic\WooCommerce\Admin\Features\Blueprint\Exporters

Код ExportWCTaxRates{} WC 9.7.1

class ExportWCTaxRates implements StepExporter {

	/**
	 * Export WooCommerce tax rates.
	 *
	 * @return SetWCTaxRates
	 */
	public function export() {
		global $wpdb;

		// Fetch tax rates from the database.
		$rates = $wpdb->get_results(
			"
            SELECT *
            FROM {$wpdb->prefix}woocommerce_tax_rates as tax_rates
            ",
			ARRAY_A
		);

		// Fetch tax rate locations from the database.
		$locations = $wpdb->get_results(
			"
            SELECT *
            FROM {$wpdb->prefix}woocommerce_tax_rate_locations as locations
            ",
			ARRAY_A
		);

		// Create a new SetWCTaxRates step with the fetched data.
		$step = new SetWCTaxRates( $rates, $locations );
		$step->set_meta_values(
			array(
				'plugin' => 'woocommerce',
			)
		);

		return $step;
	}

	/**
	 * Get the name of the step.
	 *
	 * @return string
	 */
	public function get_step_name() {
		return 'setWCTaxRates';
	}

	/**
	 * Return label used in the frontend.
	 *
	 * @return string
	 */
	public function get_label() {
		return __( 'Tax Rates', 'woocommerce' );
	}

	/**
	 * Return description used in the frontend.
	 *
	 * @return string
	 */
	public function get_description() {
		return __( 'It includes tax rates and locations.', 'woocommerce' );
	}
}