Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/tutor/ecommerce/Cart/CartFactory.php

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + <?php
2 + /**
3 + * Cart factory for creating cart object
4 + *
5 + * @package Tutor\Ecommerce
6 + * @author Themeum
7 + * @link https://themeum.com
8 + * @since 3.5.0
9 + */
10 +
11 + namespace Tutor\Ecommerce\Cart;
12 +
13 + use Tutor\Ecommerce\Cart\Contracts\CartInterface;
14 +
15 + if ( ! defined( 'ABSPATH' ) ) {
16 + exit;
17 + }
18 +
19 + /**
20 + * CartFactory class
21 + *
22 + * @since 3.5.0
23 + */
24 + class CartFactory {
25 +
26 + /**
27 + * Create a cart object
28 + *
29 + * @since 3.5.0
30 + *
31 + * @throws \Exception If monetization engine is not valid.
32 + *
33 + * @param string $monetization_engine Monetization engine.
34 + *
35 + * @return CartInterface
36 + */
37 + public static function create_cart( $monetization_engine ) : CartInterface {
38 + switch ( $monetization_engine ) {
39 + case 'wc':
40 + return new WooCart();
41 + case 'tutor':
42 + return new NativeCart();
43 + case 'edd':
44 + return new EddCart();
45 + default:
46 + throw new \Exception( 'Invalid monetization engine' );
47 + }
48 + }
49 + }
50 +