PluginProbe
StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More / 2.2.0
StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More v2.2.0
2.3.0 2.2.0 2.1.1 2.1.0 2.0.0 1.10.0 1.9.1 1.9.0 1.2.1 1.2.2 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 All 59 releases
storeengine / includes / utils / traits / integration.php

integration.php in StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More 2.2.0, at includes/utils/traits/integration.php

69 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace StoreEngine\Utils\traits;
4
5 use StoreEngine\Classes\Data\IntegrationRepositoryData;
6 use StoreEngine\Classes\Exceptions\StoreEngineException;
7 use StoreEngine\Classes\IntegrationRepository;
8 use StoreEngine\Classes\Price;
9 use StoreEngine\Classes\Product\SimpleProduct;
10 use StoreEngine\Classes\ProductFactory;
11
12 trait Integration {
13
14 /**
15 * @param int $price_id
16 *
17 * @return \StoreEngine\Classes\Integration[]
18 * @throws StoreEngineException
19 */
20 public static function get_integrations_by_price_id( int $price_id ): array {
21 try {
22 return ( new Price( $price_id ) )->get_integrations();
23 } catch ( StoreEngineException $e ) {
24 return [];
25 }
26 }
27
28 /**
29 * @param int $product_id
30 *
31 * @return IntegrationRepositoryData[]
32 * @throws StoreEngineException
33 */
34 public static function get_integrations_by_product_id( int $product_id ): array {
35 return ProductFactory::getProduct( $product_id )->get_integrations();
36 }
37
38 /**
39 * @param string $provider
40 * @param int $integration_id
41 *
42 * @return IntegrationRepositoryData[]
43 */
44 public static function get_integration_repository_by_id( string $provider, int $integration_id ): array {
45 return ( new IntegrationRepository( $provider ) )->get_by_id( $integration_id )->get_objects();
46 }
47
48 /**
49 * @param string $provider
50 * @param int $price_id
51 *
52 * @return ?IntegrationRepositoryData
53 */
54 public static function get_integration_repository_by_price_id( string $provider, int $price_id ): ?IntegrationRepositoryData {
55 return ( new IntegrationRepository( $provider ) )->get_by_price_id( $price_id );
56 }
57
58 /**
59 * @param string $provider
60 * @param array $args
61 *
62 * @return IntegrationRepositoryData[]
63 */
64 public static function get_integration_repository_by_provider( string $provider, array $args = [] ): array {
65 return ( new IntegrationRepository( $provider ) )->get_by_provider( $args )->get_objects();
66 }
67
68 }
69