Files
wc-composable-product/includes/Admin/Settings.php

109 lines
3.5 KiB
PHP
Raw Normal View History

<?php
/**
* Admin Settings
*
* @package WC_Composable_Product
*/
namespace WC_Composable_Product\Admin;
defined('ABSPATH') || exit;
/**
* Settings class
*/
class Settings extends \WC_Settings_Page {
/**
* Constructor
*/
public function __construct() {
$this->id = 'composable_products';
$this->label = __('Composable Products', 'wc-composable-product');
parent::__construct();
}
/**
* Get settings array
*
* @return array
*/
public function get_settings() {
$settings = [
[
'title' => __('Composable Products Settings', 'wc-composable-product'),
'type' => 'title',
'desc' => __('Configure default settings for composable products.', 'wc-composable-product'),
'id' => 'wc_composable_settings',
],
[
'title' => __('Default Selection Limit', 'wc-composable-product'),
'desc' => __('Default number of items customers can select.', 'wc-composable-product'),
'id' => 'wc_composable_default_limit',
'type' => 'number',
'default' => '5',
'custom_attributes' => [
'min' => '1',
'step' => '1',
],
'desc_tip' => true,
],
[
'title' => __('Default Pricing Mode', 'wc-composable-product'),
'desc' => __('How to calculate the price of composable products.', 'wc-composable-product'),
'id' => 'wc_composable_default_pricing',
'type' => 'select',
'default' => 'sum',
'options' => [
'sum' => __('Sum of selected products', 'wc-composable-product'),
'fixed' => __('Fixed price', 'wc-composable-product'),
],
'desc_tip' => true,
],
[
'title' => __('Show Product Images', 'wc-composable-product'),
'desc' => __('Display product images in the selection interface.', 'wc-composable-product'),
'id' => 'wc_composable_show_images',
'type' => 'checkbox',
'default' => 'yes',
],
[
'title' => __('Show Product Prices', 'wc-composable-product'),
'desc' => __('Display individual product prices in the selection interface.', 'wc-composable-product'),
'id' => 'wc_composable_show_prices',
'type' => 'checkbox',
'default' => 'yes',
],
[
'title' => __('Show Total Price', 'wc-composable-product'),
'desc' => __('Display the total price as customers make selections.', 'wc-composable-product'),
'id' => 'wc_composable_show_total',
'type' => 'checkbox',
'default' => 'yes',
],
[
'type' => 'sectionend',
'id' => 'wc_composable_settings',
],
];
return apply_filters('wc_composable_settings', $settings);
}
/**
* Output the settings
*/
public function output() {
$settings = $this->get_settings();
\WC_Admin_Settings::output_fields($settings);
}
/**
* Save settings
*/
public function save() {
$settings = $this->get_settings();
\WC_Admin_Settings::save_fields($settings);
}
}