New enum to define product choices

This commit is contained in:
Philipp Stracker 2025-02-14 13:11:58 +01:00
parent 0e0a73db11
commit 6061d9e20e
No known key found for this signature in database

View file

@ -0,0 +1,56 @@
<?php
/**
* Defines valid "product" options that can be chosen during onboarding.
*
* @package WooCommerce\PayPalCommerce\Settings\Enum
*/
declare( strict_types = 1 );
namespace WooCommerce\PayPalCommerce\Settings\Enum;
/**
* Enum for the "product" list choice.
*/
class ProductChoicesEnum {
/**
* Virtual products that don't require shipping
* Sample: downloads, courses, events
*/
public const VIRTUAL = 'virtual';
/**
* Physical products that require shipping
* Sample: books, clothing, electronics
*/
public const PHYSICAL = 'physical';
/**
* Subscription products that require automatic payments
* Sample: memberships, subscriptions
*/
public const SUBSCRIPTIONS = 'subscriptions';
/**
* Get all valid seller types.
*
* @return array List of all valid seller_types.
*/
public static function get_valid_values() : array {
return array(
self::VIRTUAL,
self::PHYSICAL,
self::SUBSCRIPTIONS,
);
}
/**
* Check if a given type is valid.
*
* @param string $type The value to validate.
* @return bool True, if the value is a valid seller_type.
*/
public static function is_valid( string $type ) : bool {
return in_array( $type, self::get_valid_values(), true );
}
}