cancel
Showing results for 
Search instead for 
Did you mean: 

Quantity is not getting added in product description page

Quantity is not getting added in product description page

Quantity is not adding to cart page from product description page
but for updating quantity it is working fine
so please suggest me asap.

qtyy.phtml page below

<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

/** @var $block \Magento\Catalog\Block\Product\View */
?>
<?php $_product = $block->getProduct(); ?>
<style>
#qty{
text-align:center;
text-align: center;
width: 89px;
border: none;
border-bottom: 2px solid #e1e1e1;
border-radius: 0;
}
.label span{
 
color: #4c4c4c;
font-family: "OpenSans-SemiBold";
font-size: 13px;
}
</style>
<?php
$ves = $this->helper('Ves\Themesettings\Helper\Theme');
$show_addtocart = $ves->getProductPageCfg('element_settings/show_addtocart');
?>
<?php if($show_addtocart){ ?>
<?php $buttonTitle = __('Add to Cart'); ?>
<?php if ($_product->isSaleable()): ?>
<div class="box-tocart custom-boxcart">
<div class="fieldset">
<?php if ($block->shouldRenderQuantity()): ?>
<div class="field qty">
<tr class="custom-qty"><th> <label class="label" for="qty"><span><?php /* @escapeNotVerified */ echo __('Quantity') ?></span></label></th>
 
<td><div class="control">
<div class="quantity-adder pull-right">
<div class="quantity-number pull-right">
<input type="number"
name="qty"
id="qty"
maxlength="12"
value="<?php /* @escapeNotVerified */ echo $block->getProductDefaultQty() * 1 ?>"
title="<?php /* @escapeNotVerified */ echo __('Quantity') ?>" class="input-text qty"
data-validate="<?php echo $block->escapeHtml(json_encode($block->getQuantityValidators())) ?>"
/>
</div>
<div class="quantity-wrapper pull-left">
<span class="add-up add-action" data-parentqty="true"><i class="icon icon-1189"></i></span>
<span class="add-down add-action" data-parentqty="true"><i class="icon icon-1190"></i></span>
</div>
</div></td>
</tr>
<script type="text/javascript">
require(["jquery"], function(){
jQuery(window).ready( function(){
jQuery(".quantity-adder .add-action").click( function(){
if( jQuery(this).hasClass('add-up') ) {
jQuery(".quantity-adder .qty").val( parseInt(jQuery(".quantity-adder .qty").val()) + 1 );
}else {
if( parseInt(jQuery(".quantity-adder .qty").val()) > 1 ) {
jQuery(".quantity-adder .qty").val( parseInt(jQuery(".quantity-adder .qty").val()) - 1 );
}
}
} );
})
});
</script>
</div>
</div>
<?php endif; ?>
 
</div>
</div>
<?php endif; ?>
<?php if ($block->isRedirectToCartEnabled()) : ?>
<script type="text/x-magento-init">
{
"#product_addtocart_form": {
"Magento_Catalog/product/view/validation": {
"radioCheckboxClosest": ".nested"
}
}
}
</script>
<?php else : ?>
<script>
require([
'jquery',
'mage/mage',
'Magento_Catalog/product/view/validation',
'Magento_Catalog/js/catalog-add-to-cart'
], function ($) {
'use strict';

$('#product_addtocart_form').mage('validation', {
radioCheckboxClosest: '.nested',
submitHandler: function (form) {
var widget = $(form).catalogAddToCart({
bindSubmit: false
});

widget.catalogAddToCart('submitForm', $(form));

return false;
}
});
});
</script>
<?php endif; ?>
<?php } ?>
1 REPLY 1

Re: Quantity is not getting added in product description page

Hello @muzaffaripc52d ,

 

Look like structure breaking issue please recheck with attached code.

 

 

<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

/** @var $block \Magento\Catalog\Block\Product\View */
?>
<?php $_product = $block->getProduct(); ?>
<style>
#qty{
text-align:center;
text-align: center;
width: 89px;
border: none;
border-bottom: 2px solid #e1e1e1;
border-radius: 0;
}
.label span{
 
color: #4c4c4c;
font-family: "OpenSans-SemiBold";
font-size: 13px;
}
</style>
<?php
	$ves = $this->helper('Ves\Themesettings\Helper\Theme');
	$show_addtocart = $ves->getProductPageCfg('element_settings/show_addtocart');
?>
<?php if($show_addtocart){ ?>
<?php $buttonTitle = __('Add to Cart'); ?>
<?php if ($_product->isSaleable()): ?>
<div class="box-tocart custom-boxcart">
<div class="fieldset">
<?php if ($block->shouldRenderQuantity()): ?>
	<div class="field qty">
		<tr class="custom-qty">
			<th> <label class="label" for="qty"><span><?php /* @escapeNotVerified */ echo __('Quantity') ?></span></label></th>
			<td>
				<div class="control">
					<div class="quantity-adder pull-right">
						<div class="quantity-number pull-right">
							<input type="number"
							name="qty"
							id="qty"
							maxlength="12"
							value="<?php /* @escapeNotVerified */ echo $block->getProductDefaultQty() * 1 ?>"
							title="<?php /* @escapeNotVerified */ echo __('Quantity') ?>" class="input-text qty"
							data-validate="<?php echo $block->escapeHtml(json_encode($block->getQuantityValidators())) ?>"
							/>
						</div>
						<div class="quantity-wrapper pull-left">
							<span class="add-up add-action" data-parentqty="true"><i class="icon icon-1189"></i></span>
							<span class="add-down add-action" data-parentqty="true"><i class="icon icon-1190"></i></span>
						</div>
					</div>
				</div>
			</td>
		</tr>
		<script type="text/javascript">
			require(["jquery"], function(){
				jQuery(window).ready( function(){
					jQuery(".quantity-adder .add-action").click( function(){
						if( jQuery(this).hasClass('add-up') ) {
							jQuery(".quantity-adder .qty").val( parseInt(jQuery(".quantity-adder .qty").val()) + 1 );
						}else {
							if( parseInt(jQuery(".quantity-adder .qty").val()) > 1 ) {
								jQuery(".quantity-adder .qty").val( parseInt(jQuery(".quantity-adder .qty").val()) - 1 );
							}
						}
					});
				})
			});
		</script>
	</div>
<?php endif; ?>
</div>
 
</div>
<?php endif; ?>
<?php if ($block->isRedirectToCartEnabled()) : ?>
<script type="text/x-magento-init">
{
	"#product_addtocart_form": {
		"Magento_Catalog/product/view/validation": {
		"radioCheckboxClosest": ".nested"
		}
	}
}
</script>
<?php else : ?>
	<script>
	require([
	'jquery', 'mage/mage', 'Magento_Catalog/product/view/validation', 'Magento_Catalog/js/catalog-add-to-cart'
	], function ($) {
		'use strict';

		$('#product_addtocart_form').mage('validation', {
		radioCheckboxClosest: '.nested',
		submitHandler: function (form) {
			var widget = $(form).catalogAddToCart({
				bindSubmit: false
			});

			widget.catalogAddToCart('submitForm', $(form));

			return false;
		}
		});
	});
	</script>
<?php endif; ?>
<?php } ?>

 

 

If it helps click on Kudos and Accept as Solution.

 

Thank you

Hiren Patel