mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-31 06:52:50 +08:00
✨ New enum to define product choices
This commit is contained in:
parent
0e0a73db11
commit
6061d9e20e
1 changed files with 56 additions and 0 deletions
56
modules/ppcp-settings/src/Enum/ProductChoicesEnum.php
Normal file
56
modules/ppcp-settings/src/Enum/ProductChoicesEnum.php
Normal 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 );
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue