Skip to content

Commit 9003f2b

Browse files
MC-33743: Product page PayPal button adds 2 products to cart
1 parent be9762a commit 9003f2b

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

app/code/Magento/Paypal/view/frontend/web/js/in-context/product-express-checkout.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ define([
1515
defaults: {
1616
productFormSelector: '#product_addtocart_form',
1717
declinePayment: false,
18-
formInvalid: false
18+
formInvalid: false,
19+
productAddedToCart: false
1920
},
2021

2122
/** @inheritdoc */
@@ -45,9 +46,10 @@ define([
4546
onClick: function () {
4647
var $form = $(this.productFormSelector);
4748

48-
if (!this.declinePayment) {
49+
if (!this.declinePayment && !this.productAddedToCart) {
4950
$form.submit();
5051
this.formInvalid = !$form.validation('isValid');
52+
this.productAddedToCart = true;
5153
}
5254
},
5355

@@ -100,6 +102,24 @@ define([
100102
this.clientConfig.customerId = '';
101103

102104
return this.clientConfig;
105+
},
106+
107+
/** @inheritdoc */
108+
onError: function (err) {
109+
this.productAddedToCart = false;
110+
this._super();
111+
},
112+
113+
/** @inheritdoc */
114+
onCancel: function (data, actions) {
115+
this.productAddedToCart = false;
116+
this._super();
117+
},
118+
119+
/** @inheritdoc */
120+
afterOnAuthorize: function (res, resolve, reject, actions) {
121+
this.productAddedToCart = false;
122+
this._super();
103123
}
104124
});
105125
});

0 commit comments

Comments
 (0)