<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Форум ReadyScript &mdash; Странности при изменении количества добавляемого товара]]></title>
	<link rel="self" href="https://forum.readyscript.ru/feed/atom/topic/2090/" />
	<updated>2020-04-29T13:06:22Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.readyscript.ru/topic/2090/strannosti-pri-izmenenii-kolichestva-dobavlyaemogo-tovara/</id>
		<entry>
			<title type="html"><![CDATA[Странности при изменении количества добавляемого товара]]></title>
			<link rel="alternate" href="https://forum.readyscript.ru/post/11094/#p11094" />
			<content type="html"><![CDATA[<p>В карточке товара и на странице категории стоят кнопки изменения количества добавляемого товара, при шаге 0.5 работает корректно, но если поставить в 100 г, (Шаг изменения количества товара в корзине 0.1, Единица измерения кг.)</p><p>то выводит в поле вот такое. Начинается обычно с третьего шага. Показывает - 0,30000000000000004</p><p><a href="https://imageban.ru"><span class="postimg"><img src="https://i4.imageban.ru/out/2020/04/29/3f8e7cac78f65669abc7c0964c328e03.jpg" alt="https://i4.imageban.ru/out/2020/04/29/3f8e7cac78f65669abc7c0964c328e03.jpg" /></span></a> <a href="https://imageban.ru"><span class="postimg"><img src="https://i2.imageban.ru/out/2020/04/29/a141178eb95f52aab4856a6f22b16deb.jpg" alt="https://i2.imageban.ru/out/2020/04/29/a141178eb95f52aab4856a6f22b16deb.jpg" /></span></a> <a href="https://imageban.ru"><span class="postimg"><img src="https://i2.imageban.ru/out/2020/04/29/5c7acee28da8be779b75f2e323dedc53.jpg" alt="https://i2.imageban.ru/out/2020/04/29/5c7acee28da8be779b75f2e323dedc53.jpg" /></span></a></p><p>И в корзине, сначала выскакивает не округленное значение, но после обновления округляется</p><p><a href="https://imageban.ru"><span class="postimg"><img src="https://i2.imageban.ru/out/2020/04/29/6151c60e47b096097cb6ade9e90d40f9.jpg" alt="https://i2.imageban.ru/out/2020/04/29/6151c60e47b096097cb6ade9e90d40f9.jpg" /></span></a> <a href="https://imageban.ru"><span class="postimg"><img src="https://i5.imageban.ru/out/2020/04/29/491fca3f32088da0f4d6ddb18db050ab.jpg" alt="https://i5.imageban.ru/out/2020/04/29/491fca3f32088da0f4d6ddb18db050ab.jpg" /></span></a></p><p>Вот код</p><div class="codebox"><pre><code>{hook name=&quot;catalog-product:action-buttons&quot; title=&quot;{t}Карточка товара:кнопки{/t}&quot;}
                    &lt;div class=&quot;cat-product-quantity rs-product-amount&quot;&gt;
                &lt;div class=&quot;quantity&quot;&gt;
                    &lt;input type=&quot;number&quot; step=&quot;{$product-&gt;getAmountStep()}&quot; value=&quot;{$product-&gt;getAmountStep()}&quot; name=&quot;amount&quot; class=&quot;rs-field-amount&quot;&gt;
                    &lt;div class=&quot;quantity-nav rs-unit-block&quot;&gt;

                        &lt;div class=&quot;quantity-button quantity-up rs-inc&quot; data-amount-step=&quot;{$product-&gt;getAmountStep()}&quot;&gt;&lt;/div&gt;
                        &lt;div class=&quot;quantity-button quantity-down rs-dec&quot; data-amount-step=&quot;{$product-&gt;getAmountStep()}&quot;&gt;&lt;/div&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
            &lt;/div&gt;
        {/hook}</code></pre></div><br /><div class="codebox"><pre><code>&lt;script&gt;
            // Кнопки увеличения кол-ва товара в карточке товара
            $(&#039;.rs-product-amount .rs-inc&#039;).off(&#039;click&#039;).on(&#039;click&#039;, function() {
                var amountField = $(this).closest(&#039;.rs-product-amount&#039;).find(&#039;.rs-field-amount&#039;);
                amountField.val( (+amountField.val()) + ($(this).data(&#039;amount-step&#039;)-0) );
            });

            $(&#039;.rs-product-amount .rs-dec&#039;).off(&#039;click&#039;).on(&#039;click&#039;, function() {
                var amountField = $(this).closest(&#039;.rs-product-amount&#039;).find(&#039;.rs-field-amount&#039;);
                var val = (+amountField.val());
                  if (val &gt; $(this).data(&#039;amount-step&#039;)) {
                amountField.val( val - $(this).data(&#039;amount-step&#039;) );
                  }
            });
            &lt;/script&gt;</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Алексей]]></name>
				<uri>https://forum.readyscript.ru/user/1554/</uri>
			</author>
			<updated>2020-04-29T13:06:22Z</updated>
			<id>https://forum.readyscript.ru/post/11094/#p11094</id>
		</entry>
</feed>
