File tree Expand file tree Collapse file tree 8 files changed +60
-7
lines changed
Block/Express/InContext/Minicart
templates/express/in-context/shortcut
blank/Magento_Paypal/web/css/source/module
luma/Magento_Paypal/web/css/source/module
dev/tests/functional/tests/app/Magento/Checkout/Test/Block Expand file tree Collapse file tree 8 files changed +60
-7
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ class Button extends Template implements ShortcutInterface
26
26
27
27
const BUTTON_ELEMENT_INDEX = 'button_id ' ;
28
28
29
+ const BUTTON_ELEMENT_CLASS_NAME = 'button_class ' ;
30
+
29
31
const CART_BUTTON_ELEMENT_INDEX = 'add_to_cart_selector ' ;
30
32
31
33
/**
@@ -132,6 +134,14 @@ public function getContainerId()
132
134
return $ this ->getData (self ::BUTTON_ELEMENT_INDEX );
133
135
}
134
136
137
+ /**
138
+ * @return string
139
+ */
140
+ public function getButtonClassName ()
141
+ {
142
+ return $ this ->getData (self ::BUTTON_ELEMENT_CLASS_NAME );
143
+ }
144
+
135
145
/**
136
146
* @return string
137
147
*/
Original file line number Diff line number Diff line change 92
92
<item name =" template" xsi : type =" string" >Magento_Paypal::express/in-context/shortcut/button.phtml</item >
93
93
<item name =" alias" xsi : type =" string" >paypal.express-in-context.mini-cart</item >
94
94
<item name =" button_id" xsi : type =" string" >paypal-express-in-context-mini-cart</item >
95
+ <item name =" button_class" xsi : type =" string" >paypal-express-in-context-checkout</item >
95
96
</argument >
96
97
<argument name =" payment" xsi : type =" object" >Magento\Paypal\Model\Express</argument >
97
98
</arguments >
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ use Magento\Paypal\Block\Express\InContext\Minicart\Button;
12
12
$ config = [
13
13
'Magento_Paypal/js/in-context/button ' => [
14
14
'id ' => $ block ->getContainerId (),
15
+ 'paypalButtonClass ' => $ block ->getButtonClassName (),
15
16
'paypalButton ' => Button::PAYPAL_BUTTON_ID ,
16
17
'addToCartSelector ' => $ block ->getAddToCartSelector ()
17
18
]
@@ -20,7 +21,7 @@ $config = [
20
21
?>
21
22
<div data-mage-init='<?php /* @noEscape */ echo json_encode ($ config ); ?> '
22
23
class="paypal checkout paypal-logo <?php /* @noEscape */ echo $ block ->getContainerId (); ?> -container">
23
- <a id ="<?php /* @noEscape */ echo $ block ->getContainerId (); ?> " href="#">
24
+ <a class ="<?php /* @noEscape */ echo $ block ->getButtonClassName (); ?> " href="#">
24
25
<img class="paypal-button-hidden"
25
26
src="<?php /* @noEscape */ echo $ block ->getImageUrl () ?> "
26
27
alt="Check out with PayPal" />
Original file line number Diff line number Diff line change 5
5
define (
6
6
[
7
7
'uiComponent' ,
8
+ 'Magento_Checkout/js/model/quote' ,
8
9
'jquery' ,
9
10
'domReady!'
10
11
] ,
11
12
function (
12
13
Component ,
14
+ quote ,
13
15
$
14
16
) {
15
- 'use strict' ;
16
-
17
17
return Component . extend ( {
18
18
19
19
defaults : { } ,
@@ -31,12 +31,25 @@ define(
31
31
* @returns {Object }
32
32
*/
33
33
initEvents : function ( ) {
34
- $ ( '#' + this . id ) . off ( 'click.' + this . id )
34
+
35
+ $ ( '.' + this . paypalButtonClass ) . off ( 'click.' + this . id )
35
36
. on ( 'click.' + this . id , this . click . bind ( this ) ) ;
36
37
38
+ quote . totals . subscribe ( function ( newValue ) {
39
+ // TODO: check for value
40
+ this . showLink ( ) ;
41
+ } , this ) ;
42
+
37
43
return this ;
38
44
} ,
39
45
46
+ /**
47
+ * Display PayPal in-context checkout link
48
+ */
49
+ showLink : function ( ) {
50
+ $ ( '.' + this . paypalButtonClass ) . show ( ) ;
51
+ } ,
52
+
40
53
/**
41
54
* @param {Object } event
42
55
* @returns void
Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ define(
25
25
defaults : {
26
26
clientConfig : {
27
27
28
+ inited : false ,
29
+
28
30
/**
29
31
* @param {Object } event
30
32
*/
@@ -33,7 +35,12 @@ define(
33
35
34
36
event . preventDefault ( ) ;
35
37
36
- paypalExpressCheckout . checkout . initXO ( ) ;
38
+ if ( ! this . clientConfig . inited ) {
39
+ paypalExpressCheckout . checkout . initXO ( ) ;
40
+ this . clientConfig . inited = true ;
41
+ } else {
42
+ paypalExpressCheckout . checkout . closeFlow ( ) ;
43
+ }
37
44
38
45
$ . get (
39
46
this . path ,
@@ -52,11 +59,11 @@ define(
52
59
}
53
60
) . fail (
54
61
function ( ) {
55
- $ ( 'body' ) . trigger ( 'processStop' ) ;
56
62
paypalExpressCheckout . checkout . closeFlow ( ) ;
57
63
}
58
64
) . always (
59
65
function ( ) {
66
+ $ ( 'body' ) . trigger ( 'processStop' ) ;
60
67
customerData . invalidate ( [ 'cart' ] ) ;
61
68
}
62
69
) ;
Original file line number Diff line number Diff line change 53
53
& :extend(.abs-action-button-as-link all );
54
54
}
55
55
}
56
+
57
+ .paypal-express-in-context-checkout {
58
+ display : none ;
59
+ }
56
60
}
Original file line number Diff line number Diff line change 49
49
& :extend(.abs-action-button-as-link all );
50
50
}
51
51
}
52
+
53
+ .paypal-express-in-context-checkout {
54
+ display : none ;
55
+ }
52
56
}
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ class Cart extends Block
62
62
*
63
63
* @var string
64
64
*/
65
- protected $ inContextPaypalCheckoutButton = '# paypal-express-in-context-mini-cart ' ;
65
+ protected $ inContextPaypalCheckoutButton = 'ul.checkout-methods-items a. paypal-express-in-context-checkout ' ;
66
66
67
67
/**
68
68
* Locator value for "Check out with Braintree PayPal" button.
@@ -184,6 +184,7 @@ public function paypalCheckout()
184
184
*/
185
185
public function inContextPaypalCheckout ()
186
186
{
187
+ $ this ->waitForCheckoutButton ();
187
188
$ this ->_rootElement ->find ($ this ->inContextPaypalCheckoutButton )->click ();
188
189
$ this ->browser ->selectWindow ();
189
190
$ this ->waitForFormLoaded ();
@@ -262,4 +263,16 @@ public function waitCartContainerLoading()
262
263
{
263
264
$ this ->waitForElementVisible ($ this ->cartContainer );
264
265
}
266
+
267
+ /**
268
+ * Wait until in-context checkout button is visible.
269
+ *
270
+ * @return void
271
+ */
272
+ public function waitForCheckoutButton ()
273
+ {
274
+ $ this ->waitForElementVisible ($ this ->inContextPaypalCheckoutButton );
275
+ }
276
+
277
+
265
278
}
You can’t perform that action at this time.
0 commit comments