Completed
Branch FET-8209-allow-multiple-carts (f5b2f0)
by
unknown
57:50 queued 46:34
created
core/services/cart/TicketCartItem.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 
4 4
 use EventEspresso\core\interfaces\EEI_Ticket;
5 5
 
6
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
7
-	exit( 'No direct script access allowed' );
6
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
7
+	exit('No direct script access allowed');
8 8
 }
9 9
 
10 10
 
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
 	 * @param EEI_Ticket 	$ticket
30 30
 	 * @param Cart 			$cart
31 31
 	 */
32
-	public function __construct( EEI_Ticket $ticket, Cart $cart ) {
32
+	public function __construct(EEI_Ticket $ticket, Cart $cart) {
33 33
 		$this->item = $ticket;
34
-		parent::__construct( $cart );
34
+		parent::__construct($cart);
35 35
 	}
36 36
 
37 37
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 * @return string
41 41
 	 */
42 42
 	public function generateSKU() {
43
-		return md5( $this->item->ID() . $this->item->name_and_info() );
43
+		return md5($this->item->ID().$this->item->name_and_info());
44 44
 	}
45 45
 
46 46
 
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
 	 * @return object
51 51
 	 * @throws \EE_Error
52 52
 	 */
53
-	public function validateItem( $item ) {
54
-		if ( ! $item instanceof \EE_Ticket ) {
55
-			throw new \EE_Error( 'Invalid or missing ticket in cart.' );
53
+	public function validateItem($item) {
54
+		if ( ! $item instanceof \EE_Ticket) {
55
+			throw new \EE_Error('Invalid or missing ticket in cart.');
56 56
 		}
57 57
 		return $item;
58 58
 	}
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 * @return float
64 64
 	 */
65 65
 	public function calculatePrice() {
66
-		return (float)( $this->getItem()->ticket_price() * $this->quantity );
66
+		return (float) ($this->getItem()->ticket_price() * $this->quantity);
67 67
 	}
68 68
 
69 69
 
Please login to merge, or discard this patch.
core/services/cart/CartCreator.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -5,8 +5,8 @@  discard block
 block discarded – undo
5 5
 use EventEspresso\core\interfaces\cart\CartCreatorInterface;
6 6
 use EventEspresso\core\interfaces\cart\CartCalculatorRepositoryInterface;
7 7
 
8
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
9
-	exit( 'No direct script access allowed' );
8
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
9
+	exit('No direct script access allowed');
10 10
 }
11 11
 
12 12
 
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  * @since 		$VID:$
23 23
  *
24 24
  */
25
-class CartCreator implements CartCreatorInterface{
25
+class CartCreator implements CartCreatorInterface {
26 26
 
27 27
 	/**
28 28
 	 * @type CartItemRepository $cartItemRepository
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	/**
35 35
 	 * @param CartItemRepository $cartItemRepository
36 36
 	 */
37
-	function __construct( CartItemRepository $cartItemRepository ) {
37
+	function __construct(CartItemRepository $cartItemRepository) {
38 38
 		$this->cartItemRepository = $cartItemRepository;
39 39
 	}
40 40
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
 	protected function generateID() {
44 44
 		$admin = is_admin() && ! EE_FRONT_AJAX ? 'admin-' : '';
45
-		return uniqid( $admin );
45
+		return uniqid($admin);
46 46
 	}
47 47
 
48 48
 
@@ -53,13 +53,13 @@  discard block
 block discarded – undo
53 53
 	 * @param    CartCalculatorRepositoryInterface $cartCalculatorRepository
54 54
 	 * @return 	CartInterface
55 55
 	 */
56
-	public function getNewCart( CartCalculatorRepositoryInterface $cartCalculatorRepository ) {
56
+	public function getNewCart(CartCalculatorRepositoryInterface $cartCalculatorRepository) {
57 57
 		return new Cart(
58 58
 			$this->generateID(),
59 59
 			$this->cartItemRepository,
60 60
 			$cartCalculatorRepository,
61 61
 			new CartTotal(),
62
-			new \DateTime( 'now', new \DateTimeZone( 'UTC' ) )
62
+			new \DateTime('now', new \DateTimeZone('UTC'))
63 63
 		);
64 64
 	}
65 65
 
Please login to merge, or discard this patch.
core/services/cart/cartItemOption.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\services\cart;
3 3
 
4
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-	exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @return string
35 35
 	 */
36 36
 	public function SKU() {
37
-		if ( empty( $this->SKU ) ) {
37
+		if (empty($this->SKU)) {
38 38
 			$this->SKU = $this->generateSKU();
39 39
 		}
40 40
 		return $this->SKU;
Please login to merge, or discard this patch.
core/services/cart/DiscountCartCalculator.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@  discard block
 block discarded – undo
4 4
 use EventEspresso\core\interfaces\cart\CartInterface;
5 5
 use EventEspresso\core\interfaces\cart\CartCalculatorInterface;
6 6
 
7
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
8
-	exit( 'No direct script access allowed' );
7
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
8
+	exit('No direct script access allowed');
9 9
 }
10 10
 
11 11
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 * @param CartTotal     $cartTotal
52 52
 	 * @return CartTotal
53 53
 	 */
54
-	public function calculateTotal( CartInterface $cart, CartTotal $cartTotal ) {
54
+	public function calculateTotal(CartInterface $cart, CartTotal $cartTotal) {
55 55
 		$this->cart = $cart;
56 56
 		$this->cartTotal = $cartTotal;
57 57
 		$this->calculateDiscountTotal();
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 */
65 65
 	protected function calculateDiscountTotal() {
66 66
 		$discountCartItems = $this->cart->getDiscountCartItems();
67
-		foreach ( $discountCartItems as $discountCartItem ) {
67
+		foreach ($discountCartItems as $discountCartItem) {
68 68
 			$discountTotal = $discountCartItem->calculatePrice();
69 69
 			$this->cartTotal->discountTotal -= $discountTotal;
70 70
 			$this->cartTotal->preTaxSubtotal -= $discountTotal;
Please login to merge, or discard this patch.
core/services/cart/DiscountCartItem.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 
4 4
 use EventEspresso\core\interfaces\cart\DiscountInterface;
5 5
 
6
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
7
-	exit( 'No direct script access allowed' );
6
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
7
+	exit('No direct script access allowed');
8 8
 }
9 9
 
10 10
 
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
 	 * @param DiscountInterface $discount
30 30
 	 * @param Cart 			$cart
31 31
 	 */
32
-	public function __construct( DiscountInterface $discount, Cart $cart ) {
32
+	public function __construct(DiscountInterface $discount, Cart $cart) {
33 33
 		$this->item = $discount;
34
-		parent::__construct( $cart );
34
+		parent::__construct($cart);
35 35
 	}
36 36
 
37 37
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 * @return string
41 41
 	 */
42 42
 	public function generateSKU() {
43
-		return md5( $this->item->ID() . $this->item->description() );
43
+		return md5($this->item->ID().$this->item->description());
44 44
 	}
45 45
 
46 46
 
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
 	 * @return object
51 51
 	 * @throws \EE_Error
52 52
 	 */
53
-	public function validateItem( $item ) {
54
-		if ( ! $item instanceof DiscountInterface ) {
55
-			throw new \EE_Error( 'Invalid or missing discount in cart.' );
53
+	public function validateItem($item) {
54
+		if ( ! $item instanceof DiscountInterface) {
55
+			throw new \EE_Error('Invalid or missing discount in cart.');
56 56
 		}
57 57
 		return $item;
58 58
 	}
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 * @return float
64 64
 	 */
65 65
 	public function calculatePrice() {
66
-		return (float)( $this->getItem()->amount() * $this->quantity );
66
+		return (float) ($this->getItem()->amount() * $this->quantity);
67 67
 	}
68 68
 
69 69
 
Please login to merge, or discard this patch.
core/services/cart/CartCalculatorForTickets.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@  discard block
 block discarded – undo
4 4
 use EventEspresso\core\interfaces\cart\CartInterface;
5 5
 use EventEspresso\core\interfaces\cart\CartCalculatorInterface;
6 6
 
7
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
8
-	exit( 'No direct script access allowed' );
7
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
8
+	exit('No direct script access allowed');
9 9
 }
10 10
 
11 11
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 * @param CartTotal     $cartTotal
52 52
 	 * @return CartTotal
53 53
 	 */
54
-	public function calculateTotal( CartInterface $cart, CartTotal $cartTotal ) {
54
+	public function calculateTotal(CartInterface $cart, CartTotal $cartTotal) {
55 55
 		$this->cart = $cart;
56 56
 		$this->cartTotal = $cartTotal;
57 57
 		$this->calculateTicketTotal();
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 */
65 65
 	protected function calculateTicketTotal() {
66 66
 		$ticketCartItems = $this->cart->getTicketCartItems();
67
-		foreach ( $ticketCartItems as $ticketCartItem ) {
67
+		foreach ($ticketCartItems as $ticketCartItem) {
68 68
 			$this->cartTotal->ticketCount += $ticketCartItem->quantity();
69 69
 			$ticketTotal = $ticketCartItem->calculatePrice();
70 70
 			$this->cartTotal->ticketTotal += $ticketTotal;
Please login to merge, or discard this patch.
core/services/cart/CartCalculatorRepository.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
 	 * @param CartCalculatorInterface $cartCalculator
29 29
 	 * @return bool
30 30
 	 */
31
-	public function addCartCalculator( CartCalculatorInterface $cartCalculator ) {
32
-		return $this->add( $cartCalculator, $cartCalculator->name() );
31
+	public function addCartCalculator(CartCalculatorInterface $cartCalculator) {
32
+		return $this->add($cartCalculator, $cartCalculator->name());
33 33
 	}
34 34
 
35 35
 
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
 	 * @param mixed $name
39 39
 	 * @return CartCalculatorInterface
40 40
 	 */
41
-	public function getCartCalculator( $name ) {
42
-		$cartCalculator = $this->get_by_info( $name );
43
-		if ( ! $cartCalculator instanceof CartCalculatorInterface ) {
41
+	public function getCartCalculator($name) {
42
+		$cartCalculator = $this->get_by_info($name);
43
+		if ( ! $cartCalculator instanceof CartCalculatorInterface) {
44 44
 			// exception ??
45 45
 		}
46 46
 		return $cartCalculator;
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
 	 * @param CartCalculatorInterface $cartCalculator
53 53
 	 * @return bool
54 54
 	 */
55
-	public function hasCartCalculator( CartCalculatorInterface $cartCalculator ) {
56
-		return $this->contains( $cartCalculator );
55
+	public function hasCartCalculator(CartCalculatorInterface $cartCalculator) {
56
+		return $this->contains($cartCalculator);
57 57
 	}
58 58
 
59 59
 
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
 	 * @param mixed $name
63 63
 	 * @return bool
64 64
 	 */
65
-	public function hasCartCalculatorByName( $name ) {
66
-		$cartCalculator = $this->get_by_info( $name );
67
-		return $this->contains( $cartCalculator );
65
+	public function hasCartCalculatorByName($name) {
66
+		$cartCalculator = $this->get_by_info($name);
67
+		return $this->contains($cartCalculator);
68 68
 	}
69 69
 
70 70
 
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 	 * @param CartCalculatorInterface $cartCalculator
74 74
 	 * @return void
75 75
 	 */
76
-	public function removeCartCalculator( CartCalculatorInterface $cartCalculator ) {
77
-		$this->remove( $cartCalculator );
76
+	public function removeCartCalculator(CartCalculatorInterface $cartCalculator) {
77
+		$this->remove($cartCalculator);
78 78
 	}
79 79
 
80 80
 
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
 	 * @param mixed $name
84 84
 	 * @return void
85 85
 	 */
86
-	public function removeCartCalculatorByName( $name ) {
87
-		$cartCalculator = $this->get_by_info( $name );
88
-		$this->remove( $cartCalculator );
86
+	public function removeCartCalculatorByName($name) {
87
+		$cartCalculator = $this->get_by_info($name);
88
+		$this->remove($cartCalculator);
89 89
 	}
90 90
 
91 91
 
Please login to merge, or discard this patch.
core/services/cart/CartManager.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
 		 CartRepositoryInterface $CartRepository,
60 60
 		 CartCalculatorRepositoryInterface $cartCalculatorRepository
61 61
 	 ) {
62
-		 $this->session 		= $session;
63
-		 $this->cartCreator 	= $CartCreator;
62
+		 $this->session = $session;
63
+		 $this->cartCreator = $CartCreator;
64 64
 		 $this->cartRepository 	= $CartRepository;
65 65
 		 $this->cartCalculators = $cartCalculatorRepository;
66
-		 do_action( 'AHEE__CartManager__construct__complete', $this );
66
+		 do_action('AHEE__CartManager__construct__complete', $this);
67 67
 	 }
68 68
 
69 69
 
@@ -73,15 +73,15 @@  discard block
 block discarded – undo
73 73
 	  * @param bool  $createNew
74 74
 	  * @return CartInterface
75 75
 	  */
76
-	 public function getCart( $ID, $createNew = false ) {
77
-		 $cart = $this->cartRepository->getCart( $ID );
78
-		 if ( ! $cart instanceof Cart ) {
79
-			 $cart = $this->getCartFromSession( $ID );
76
+	 public function getCart($ID, $createNew = false) {
77
+		 $cart = $this->cartRepository->getCart($ID);
78
+		 if ( ! $cart instanceof Cart) {
79
+			 $cart = $this->getCartFromSession($ID);
80 80
 		 }
81
-		 if ( ! $cart instanceof Cart && $createNew ) {
81
+		 if ( ! $cart instanceof Cart && $createNew) {
82 82
 			 $cart = $this->createCart();
83 83
 		 }
84
-		 if ( ! $cart instanceof Cart ) {
84
+		 if ( ! $cart instanceof Cart) {
85 85
 			 // exception ?
86 86
 		 }
87 87
 		 return $cart;
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
 	  * @param mixed $ID
94 94
 	  * @return CartInterface
95 95
 	  */
96
-	 public function getCartFromSession( $ID ) {
96
+	 public function getCartFromSession($ID) {
97 97
 		 // try getting the cart out of the session
98
-		 $cart = $this->session->cart( $ID );
99
-		 if ( $cart instanceof Cart && $ID == $cart->ID() ) {
100
-			 if ( $this->cartRepository->addCart( $cart ) ) {
98
+		 $cart = $this->session->cart($ID);
99
+		 if ($cart instanceof Cart && $ID == $cart->ID()) {
100
+			 if ($this->cartRepository->addCart($cart)) {
101 101
 				 return $cart;
102 102
 			 }
103 103
 		 }
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 	  * @return CartInterface
113 113
 	  */
114 114
 	 protected function createCart() {
115
-		 $cart = $this->cartCreator->getNewCart( $this->cartCalculators );
116
-		 if ( $this->cartRepository->addCart( $cart ) ) {
115
+		 $cart = $this->cartCreator->getNewCart($this->cartCalculators);
116
+		 if ($this->cartRepository->addCart($cart)) {
117 117
 			 return $cart;
118 118
 		 }
119 119
 		 return null;
Please login to merge, or discard this patch.
core/services/cart/PromotionRepository.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 	 * @param \EE_Promotion $promotion
27 27
 	 * @return bool
28 28
 	 */
29
-	public function add_promotion( \EE_Promotion $promotion ) {
30
-		return $this->add( $promotion, $promotion->ID() );
29
+	public function add_promotion(\EE_Promotion $promotion) {
30
+		return $this->add($promotion, $promotion->ID());
31 31
 	}
32 32
 
33 33
 
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 	 * @param mixed $ID
37 37
 	 * @return null | object
38 38
 	 */
39
-	public function get_promotion( $ID ) {
40
-		$promotion = $this->get_by_info( $ID );
41
-		if ( ! $promotion instanceof \EE_Ticket ) {
39
+	public function get_promotion($ID) {
40
+		$promotion = $this->get_by_info($ID);
41
+		if ( ! $promotion instanceof \EE_Ticket) {
42 42
 			// ??? exception ???
43 43
 		}
44 44
 		return $promotion;
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 	 * @param mixed $ID
51 51
 	 * @return null | object
52 52
 	 */
53
-	public function get_promotion_by_id( $ID ) {
54
-		return $this->get_by_info( $ID );
53
+	public function get_promotion_by_id($ID) {
54
+		return $this->get_by_info($ID);
55 55
 	}
56 56
 
57 57
 
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 	 * @param \EE_Promotion $promotion
61 61
 	 * @return bool
62 62
 	 */
63
-	public function has_promotion( \EE_Promotion $promotion ) {
64
-		return $this->has( $promotion );
63
+	public function has_promotion(\EE_Promotion $promotion) {
64
+		return $this->has($promotion);
65 65
 	}
66 66
 
67 67
 
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
 	 * @param mixed $ID
71 71
 	 * @return bool
72 72
 	 */
73
-	public function has_promotion_by_id( $ID ) {
74
-		$promotion = $this->get_by_info( $ID );
75
-		return $this->has( $promotion );
73
+	public function has_promotion_by_id($ID) {
74
+		$promotion = $this->get_by_info($ID);
75
+		return $this->has($promotion);
76 76
 	}
77 77
 
78 78
 
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 	 * @param \EE_Promotion $promotion
82 82
 	 * @return bool | int
83 83
 	 */
84
-	public function save_promotion( \EE_Promotion $promotion ) {
85
-		return $this->persist( $promotion, 'save' );
84
+	public function save_promotion(\EE_Promotion $promotion) {
85
+		return $this->persist($promotion, 'save');
86 86
 	}
87 87
 
88 88
 
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
 	 * @param mixed $ID
92 92
 	 * @return bool | int
93 93
 	 */
94
-	public function save_promotion_by_id( $ID ) {
95
-		$promotion = $this->get_by_info( $ID );
96
-		return $this->persist( $promotion, 'save' );
94
+	public function save_promotion_by_id($ID) {
95
+		$promotion = $this->get_by_info($ID);
96
+		return $this->persist($promotion, 'save');
97 97
 	}
98 98
 
99 99
 
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 	 * @param \EE_Promotion $promotion
103 103
 	 * @return void
104 104
 	 */
105
-	public function remove_promotion( \EE_Promotion $promotion ) {
106
-		$this->remove( $promotion );
105
+	public function remove_promotion(\EE_Promotion $promotion) {
106
+		$this->remove($promotion);
107 107
 	}
108 108
 
109 109
 
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
 	 * @param mixed $ID
113 113
 	 * @return void
114 114
 	 */
115
-	public function remove_promotion_by_id( $ID ) {
116
-		$promotion = $this->get_by_info( $ID );
117
-		$this->remove( $promotion );
115
+	public function remove_promotion_by_id($ID) {
116
+		$promotion = $this->get_by_info($ID);
117
+		$this->remove($promotion);
118 118
 	}
119 119
 
120 120
 
Please login to merge, or discard this patch.