var calculateQuantityPrice = function($action, $this) {
var $siblings = $this.closest('.input-row').find('input:text');
var $basketSum = $this.closest('.basket-row').find('.sum-container span');
var presentValue = parseInt($siblings.val());
var priceValue = parseInt($basketSum.attr('data-sum'));
var presentPriceValue = parseInt($basketSum.text());
if ($action == 'plus') {
$siblings.val(presentValue + 1);
$basketSum.text(priceValue + presentPriceValue + ' руб.');
} else if ($action == 'minus') {
$siblings.val(presentValue - 1);
$basketSum.text(presentPriceValue - priceValue + ' руб.');
}
};
$('.p-btn').click(function(e) {
e.preventDefault();
calculateQuantityPrice('plus', $( this ))
});
$('.m-btn').click(function(e) {
e.preventDefault();
calculateQuantityPrice('minus', $( this ));
});