*/ public function get_settings(): array { $stored = function_exists( 'get_option' ) ? get_option( self::OPTION_SETTINGS, array() ) : array(); $stored = is_array( $stored ) ? $stored : array(); return array_replace_recursive( $this->defaults(), $stored ); } /** * @param array $settings Settings. */ public function save_settings( array $settings ): bool { if ( ! function_exists( 'update_option' ) ) { return true; } return (bool) update_option( self::OPTION_SETTINGS, $settings, false ); } /** * @return array */ public function get_setup_state(): array { $stored = function_exists( 'get_option' ) ? get_option( self::OPTION_SETUP_STATE, array() ) : array(); $stored = is_array( $stored ) ? $stored : array(); return array_replace( array( 'current_step' => 1, 'completed' => false, 'updated_at' => '', ), $stored ); } /** * @param array $state Setup state. */ public function save_setup_state( array $state ): bool { if ( ! function_exists( 'update_option' ) ) { return true; } return (bool) update_option( self::OPTION_SETUP_STATE, $state, false ); } public function clear_audit_cache(): void { if ( function_exists( 'delete_option' ) ) { delete_option( self::OPTION_AUDIT_CACHE ); } } /** * @param array $report Audit report. */ public function save_audit_cache( array $report ): bool { if ( ! function_exists( 'update_option' ) ) { return true; } return (bool) update_option( self::OPTION_AUDIT_CACHE, $report, false ); } /** * @return array|null */ public function get_audit_cache(): ?array { $stored = function_exists( 'get_option' ) ? get_option( self::OPTION_AUDIT_CACHE, null ) : null; return is_array( $stored ) ? $stored : null; } /** * @return array */ private function defaults(): array { return array( 'schema_version' => 1, 'languages' => array( 'admin_language' => LanguageCatalog::BOSNIAN, 'default_document_language' => LanguageCatalog::BOSNIAN, 'enabled_customer_languages' => array( LanguageCatalog::BOSNIAN ), ), 'merchant' => array( 'legal_name' => '', 'registered_name' => '', 'registration_number' => '', 'registration_authority' => '', 'tax_id' => '', 'vat_registered' => false, 'vat_number' => '', 'address' => '', 'city' => '', 'postcode' => '', 'country' => 'BA', 'phone' => '', 'email' => '', 'site' => '', 'establishment' => '', 'supplier_relationship' => 'SAME_AS_MERCHANT', 'separate_supplier_name' => '', 'separate_supplier_email' => '', ), 'sales' => array( 'distance_sale_registration_confirmed' => false, 'physical_goods_scope_confirmed' => false, 'complaints_contact' => '', 'returns_contact' => '', 'complaints_email' => '', 'complaints_phone' => '', 'returns_same_as_complaints' => false, 'returns_email' => '', 'returns_phone' => '', 'returns_address' => '', 'returns_use_merchant_address' => false, 'returns_recipient' => '', 'returns_street' => '', 'returns_postcode' => '', 'returns_city' => '', 'returns_country' => '', 'offer_validity_configured' => false, 'warranty_information_configured' => false, 'payment_delivery_information_confirmed' => false, 'sells_across_bih' => false, 'cross_entity_mode' => 'PRECAUTIONARY_UNION', ), 'terms' => array( 'contract_formation_mode' => 'ORDER_CREATED', 'contract_formation_status' => '', 'contract_formation_provider' => '', 'order_process_information_confirmed' => false, 'terms_accessible_saveable_confirmed' => false, 'rs_payment_obligation_confirmed' => false, ), 'delivery' => array( 'completed_means_dispatched' => false, 'customer_email_id' => 'customer_processing_order', ), 'documents' => array( 'basic_pdf_enabled' => false, 'basic_pdf_email_id' => 'customer_processing_order', ), ); } }