| 1 |
<?php |
| 2 |
/** |
| 3 |
* Product service interface |
| 4 |
* |
| 5 |
* @package SeQura/WC |
| 6 |
* @subpackage SeQura/WC/Services |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace SeQura\WC\Services\Product; |
| 10 |
|
| 11 |
use DateTime; |
| 12 |
use WC_Product; |
| 13 |
|
| 14 |
/** |
| 15 |
* Handle use cases related to products |
| 16 |
*/ |
| 17 |
interface Interface_Product_Service { |
| 18 |
|
| 19 |
/** |
| 20 |
* Get desired first charge date for a product |
| 21 |
* |
| 22 |
* @param int|WC_Product $product The product ID or product object |
| 23 |
* @return DateTime|null|string |
| 24 |
*/ |
| 25 |
public function get_desired_first_charge_date( $product, bool $raw_value = false ); |
| 26 |
|
| 27 |
/** |
| 28 |
* Get product instance |
| 29 |
* |
| 30 |
* @param int|WC_Product $product The product ID or product object |
| 31 |
*/ |
| 32 |
public function get_product_instance( $product ): ?WC_Product; |
| 33 |
|
| 34 |
/** |
| 35 |
* Check if product is a service |
| 36 |
* |
| 37 |
* @param int|WC_Product $product The product ID or product object |
| 38 |
*/ |
| 39 |
public function is_service( $product ): bool; |
| 40 |
|
| 41 |
/** |
| 42 |
* Update is service value |
| 43 |
*/ |
| 44 |
public function set_is_service( int $product_id, ?string $value ): void; |
| 45 |
|
| 46 |
/** |
| 47 |
* Check if product is banned |
| 48 |
* |
| 49 |
* @param int|WC_Product $product The product ID or product object |
| 50 |
*/ |
| 51 |
public function is_banned( $product ): bool; |
| 52 |
|
| 53 |
/** |
| 54 |
* Check if product and category ban lists are empty |
| 55 |
*/ |
| 56 |
public function is_ban_list_empty(): bool; |
| 57 |
|
| 58 |
/** |
| 59 |
* Update is_banned value |
| 60 |
*/ |
| 61 |
public function set_is_banned( int $product_id, ?string $value ): void; |
| 62 |
|
| 63 |
/** |
| 64 |
* Get product is_banned value |
| 65 |
* |
| 66 |
* @param int|WC_Product $product The product ID or product object |
| 67 |
*/ |
| 68 |
public function get_is_banned( $product ): bool; |
| 69 |
|
| 70 |
/** |
| 71 |
* Get product service end date |
| 72 |
* |
| 73 |
* @param WC_Product|int $product the product we are building item info for. |
| 74 |
*/ |
| 75 |
public function get_service_end_date( $product, bool $raw_value = false ): string; |
| 76 |
|
| 77 |
/** |
| 78 |
* Update service end date value |
| 79 |
*/ |
| 80 |
public function set_service_end_date( int $product_id, ?string $value ): void; |
| 81 |
|
| 82 |
/** |
| 83 |
* Update desired_first_charge_date value |
| 84 |
*/ |
| 85 |
public function set_desired_first_charge_date( int $product_id, ?string $value ): void; |
| 86 |
|
| 87 |
/** |
| 88 |
* Get registration amount |
| 89 |
* |
| 90 |
* @param WC_Product|int $product the product we are building item info for. |
| 91 |
*/ |
| 92 |
public function get_registration_amount( $product, bool $to_cents = false ): float; |
| 93 |
|
| 94 |
/** |
| 95 |
* Update registration amount value |
| 96 |
*/ |
| 97 |
public function set_registration_amount( int $product_id, ?float $value ): void; |
| 98 |
|
| 99 |
/** |
| 100 |
* Check if we can display widget of a payment method for a product |
| 101 |
* |
| 102 |
* @param WC_Product|int $product the product. |
| 103 |
* @param array<string, string> $method the payment method. See PaymentMethodsResponse::toArray() output |
| 104 |
*/ |
| 105 |
public function can_display_widget_for_method( $product, $method ): bool; |
| 106 |
|
| 107 |
/** |
| 108 |
* Get enabledForServices from general settings. |
| 109 |
*/ |
| 110 |
public function is_enabled_for_services( ?string $country = null ): bool; |
| 111 |
|
| 112 |
/** |
| 113 |
* Get allowFirstServicePaymentDelay from general settings. |
| 114 |
*/ |
| 115 |
public function is_allow_first_service_payment_delay( ?string $country = null ): bool; |
| 116 |
|
| 117 |
/** |
| 118 |
* Get allowServiceRegistrationItems from general settings. |
| 119 |
*/ |
| 120 |
public function is_allow_service_registration_items( ?string $country = null ): bool; |
| 121 |
|
| 122 |
/** |
| 123 |
* Get defaultServicesEndDate from general settings. |
| 124 |
*/ |
| 125 |
public function get_default_services_end_date(): string; |
| 126 |
|
| 127 |
/** |
| 128 |
* Get the reference of a given product |
| 129 |
*/ |
| 130 |
public function get_reference( WC_Product $product ): string; |
| 131 |
|
| 132 |
/** |
| 133 |
* Get product name |
| 134 |
*/ |
| 135 |
public function get_name( WC_Product $product ): string; |
| 136 |
} |
| 137 |
|