Skip to content

Commit

Permalink
Merge pull request #11 from koala-framework/update-add-to-cart-box
Browse files Browse the repository at this point in the history
Update cart-box also for ajax-view detail product pages
  • Loading branch information
fraxachun committed Jan 15, 2019
2 parents ca02625 + 9d12fbf commit 6aa5965
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 17 deletions.
7 changes: 7 additions & 0 deletions KwcShop/Kwc/Shop/AddToCart/Component.defer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
var componentEvent = require('kwf/component-event');

onReady.onRender('.kwcClass',function(el) {
el.find('.kwfUp-formContainer').on('kwfUp-form-submitSuccess', function (event) {
componentEvent.trigger('kwfUp-shop-addToCart');
});
});
1 change: 0 additions & 1 deletion KwcShop/Kwc/Shop/AddToCart/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ public static function getSettings($param = null)
$ret = parent::getSettings($param);
$ret['orderProductData'] = 'KwcShop_Kwc_Shop_AddToCart_OrderProductData';
$ret['productTypeText'] = trlKwfStatic('Product');
$ret['rootElementClass'] .= ' kwfUp-addToCartForm';
return $ret;
}

Expand Down
27 changes: 12 additions & 15 deletions KwcShop/Kwc/Shop/Box/Cart/Component.defer.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
var onReady = require('kwf/commonjs/on-ready');
var getKwcRenderUrl = require('kwf/commonjs/get-kwc-render-url');
var $ = require('jQuery');
var componentEvent = require('kwf/commonjs/component-event');

onReady.onRender('.kwcClass',function(el) {
var url = getKwcRenderUrl();

$.each($('.kwfUp-addToCartForm .kwfUp-formContainer'), $.proxy(function(index, form) {
$(form).on('kwfUp-form-submitSuccess', $.proxy(function(event) {
$.ajax({
url: url,
data: { componentId: el.data('component-id') },
success: function(response) {
el.html(response);
onReady.callOnContentReady(el, {newRender: true});
}
});
}, el));
}, el));
}, { priority: 0 }); //call after Kwc.Form.Component
componentEvent.on('kwfUp-shop-addToCart', function() {
$.ajax({
url: getKwcRenderUrl(),
data: {componentId: el.data('component-id')},
success: function (response) {
el.html($(response).html());
onReady.callOnContentReady(el, {newRender: true});
}
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
var componentEvent = require('kwf/component-event');

onReady.onRender('.kwcClass',function(el) {
el.find('.kwfUp-formContainer').on('kwfUp-form-submitSuccess', function (event) {
componentEvent.trigger('kwfUp-shop-addToCart');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ public static function getSettings($param = null)
//$ret['flags']['processInput'] = false;
$ret['placeholder']['submitButton'] = trlKwfStatic('add to cart');
$ret['generators']['child']['component']['success'] = 'KwcShop_Kwc_Shop_AddToCartAbstract_Success_Component';
$ret['rootElementClass'] .= ' kwfUp-addToCartForm';
return $ret;
}

Expand Down

0 comments on commit 6aa5965

Please sign in to comment.