You've already forked wc-composable-product
All checks were successful
- Upgrade PHPUnit 9.6 → 10, update phpunit.xml.dist schema - Add PHPCS 3.13 with WordPress-Extra + PHPCompatibilityWP standards - PHPCBF auto-fix + manual fixes for full WPCS compliance - Add phpcs job to release workflow (parallel with lint) - Pin composer platform to PHP 8.3 to prevent incompatible dep locks Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
116 lines
3.4 KiB
PHP
116 lines
3.4 KiB
PHP
<?php
|
|
/**
|
|
* Admin Settings
|
|
*
|
|
* @package Magdev\WcComposableProduct
|
|
*/
|
|
|
|
namespace Magdev\WcComposableProduct\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 = array(
|
|
array(
|
|
'title' => __( 'Composable Products Settings', 'wc-composable-product' ),
|
|
'type' => 'title',
|
|
'desc' => __( 'Configure default settings for composable products.', 'wc-composable-product' ),
|
|
'id' => 'wc_composable_settings',
|
|
),
|
|
array(
|
|
'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' => array(
|
|
'min' => '1',
|
|
'step' => '1',
|
|
),
|
|
'desc_tip' => true,
|
|
),
|
|
array(
|
|
'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' => array(
|
|
'sum' => __( 'Sum of selected products', 'wc-composable-product' ),
|
|
'fixed' => __( 'Fixed price', 'wc-composable-product' ),
|
|
),
|
|
'desc_tip' => true,
|
|
),
|
|
array(
|
|
'title' => __( 'Include Non-Public Products', 'wc-composable-product' ),
|
|
'desc' => __( 'Allow draft and private products to appear in composable product selections. Useful when products should only be sold as part of a composition, not individually.', 'wc-composable-product' ),
|
|
'id' => 'wc_composable_include_unpublished',
|
|
'type' => 'checkbox',
|
|
'default' => 'no',
|
|
),
|
|
array(
|
|
'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',
|
|
),
|
|
array(
|
|
'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',
|
|
),
|
|
array(
|
|
'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',
|
|
),
|
|
array(
|
|
'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 );
|
|
}
|
|
}
|