File tree Expand file tree Collapse file tree 4 files changed +18
-5
lines changed
Checkout/view/frontend/web/js Expand file tree Collapse file tree 4 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ $_helper = $this->helper('Magento\Catalog\Helper\Output');
78
78
<div class="actions-primary"<?= strpos ($ pos , $ viewMode . '-primary ' ) ? $ position : '' ?> >
79
79
<?php if ($ _product ->isSaleable ()): ?>
80
80
<?php $ postParams = $ block ->getAddToCartPostParams ($ _product ); ?>
81
- <form data-role="tocart-form" action="<?= /* @escapeNotVerified */ $ postParams ['action ' ] ?> " method="post">
81
+ <form data-role="tocart-form" data-product-sku=" <?= /* @escapeNotVerified */ $ _product -> getSku () ?> " action="<?= /* @escapeNotVerified */ $ postParams ['action ' ] ?> " method="post">
82
82
<input type="hidden" name="product" value="<?= /* @escapeNotVerified */ $ postParams ['data ' ]['product ' ] ?> ">
83
83
<input type="hidden" name="<?= /* @escapeNotVerified */ Action::PARAM_NAME_URL_ENCODED ?> " value="<?= /* @escapeNotVerified */ $ postParams ['data ' ][Action::PARAM_NAME_URL_ENCODED ] ?> ">
84
84
<?= $ block ->getBlockHtml ('formkey ' ) ?>
@@ -121,7 +121,9 @@ $_helper = $this->helper('Magento\Catalog\Helper\Output');
121
121
<script type="text/x-magento-init">
122
122
{
123
123
"[data-role=tocart-form], .form.map.checkout": {
124
- "catalogAddToCart": {}
124
+ "catalogAddToCart": {
125
+ "product_sku": "<?= /* @escapeNotVerified */ $ _product ->getSku () ?> "
126
+ }
125
127
}
126
128
}
127
129
</script>
Original file line number Diff line number Diff line change 16
16
<?php $ _product = $ block ->getProduct (); ?>
17
17
18
18
<div class="product-add-form">
19
- <form action="<?= /* @escapeNotVerified */ $ block ->getSubmitUrl ($ _product ) ?> " method="post"
19
+ <form data-product-sku="<?= /* @escapeNotVerified */ $ _product ->getSku () ?> "
20
+ action="<?= /* @escapeNotVerified */ $ block ->getSubmitUrl ($ _product ) ?> " method="post"
20
21
id="product_addtocart_form"<?php if ($ _product ->getOptions ()): ?> enctype="multipart/form-data"<?php endif ; ?> >
21
22
<input type="hidden" name="product" value="<?= /* @escapeNotVerified */ $ _product ->getId () ?> " />
22
23
<input type="hidden" name="selected_configurable_option" value="" />
Original file line number Diff line number Diff line change @@ -97,6 +97,8 @@ define([
97
97
success : function ( res ) {
98
98
var eventData , parameters ;
99
99
100
+ $ ( document ) . trigger ( 'ajax:addToCart' , form . data ( ) . productSku ) ;
101
+
100
102
if ( self . isLoaderEnabled ( ) ) {
101
103
$ ( 'body' ) . trigger ( self . options . processStop ) ;
102
104
}
Original file line number Diff line number Diff line change @@ -228,10 +228,18 @@ define([
228
228
} ,
229
229
230
230
/**
231
- * Update content after item remove.
231
+ * Update content after item remove
232
+ *
233
+ * @param elem
234
+ * @param response
232
235
* @private
233
236
*/
234
- _removeItemAfter : function ( ) {
237
+ _removeItemAfter : function ( elem , response ) {
238
+ var productData = customerData . get ( 'cart' ) ( ) . items . find ( function ( item ) {
239
+ return Number ( elem . data ( 'cart-item' ) ) === Number ( item [ 'item_id' ] ) ;
240
+ } ) ;
241
+
242
+ $ ( document ) . trigger ( 'ajax:removeFromCart' , productData [ 'product_sku' ] ) ;
235
243
} ,
236
244
237
245
/**
You can’t perform that action at this time.
0 commit comments