Automattic\WooCommerce\Admin\Features\Blueprint\Exporters
ExportWCSettingsTax{}└─ ExportWCSettings
Class ExportWCSettingsTax
This class exports WooCommerce settings on the Tax page.
No Hooks.
Usage
$ExportWCSettingsTax = new ExportWCSettingsTax(); // use class methods
Methods
- public export()
- public get_alias()
- public get_description()
- public get_label()
- private generateTaxRateSteps( string $table )
- protected get_page_id()
Notes
- Package: Automattic\WooCommerce\Admin\Features\Blueprint\Exporters
ExportWCSettingsTax{} ExportWCSettingsTax{} code WC 9.9.5
class ExportWCSettingsTax extends ExportWCSettings { use UseWPFunctions; /** * Get the alias for this exporter. * * @return string */ public function get_alias() { return 'setWCSettingsTax'; } /** * Export WooCommerce tax rates. * * @return array array of steps */ public function export(): array { $basic_tax_settings = parent::export(); return array( $basic_tax_settings, ...$this->generateTaxRateSteps( 'woocommerce_tax_rates' ), ...$this->generateTaxRateSteps( 'woocommerce_tax_rate_locations' ), ); } /** * Return label used in the frontend. * * @return string */ public function get_label() { return __( 'Tax', 'woocommerce' ); } /** * Return description used in the frontend. * * @return string */ public function get_description() { return __( 'Includes all settings in WooCommerce | Settings | Tax.', 'woocommerce' ); } /** * Get the page ID for the settings page. * * @return string */ protected function get_page_id(): string { return 'tax'; } /** * Generate SQL steps for exporting data. * * @param string $table Table identifier. * @return array Array of RunSql steps. */ private function generateTaxRateSteps( string $table ): array { global $wpdb; $table = $wpdb->prefix . $table; return array_map( fn( $record ) => new RunSql( Util::array_to_insert_sql( $record, $table, 'replace into' ) ), $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM %i', $table ), ARRAY_A ), ); } }