[Skip to main content](#vessel-content)

#   How to define quantity for products that use "Custom Quantity Plugin"?

##

- **[::REZA::](/forum/user/40414-reza "View ::REZA::'s Profile")**
- [![::REZA::'s Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/40414-reza "View ::REZA::'s Profile") Topic Author
- [ Offline](/forum/user/40414-reza)

Less More

- Posts: 6
- Thank you received: 0
-

5 years 6 months ago [\#331996](#331996) by [::REZA::](/forum/user/40414-reza "View ::REZA::'s Profile")  *[How to define quantity for products that use "Custom Quantity Plugin"?](/forum/4-how-to/902440-how-to-define-quantity-for-products-that-use-custom-quantity-plugin#331996 "-- HikaShop version -- : 4.4.0 -- Joomla version -- : 3.9.23 -- PHP version -- : 7.3  Hi I'm using Custom Quantity Plugin for some of my products and everything is ok. User inserts required length in cm, then selects quantity and cart updates successfully.  The code in &quot;custom quantity plugin&quot;.  The question is how should I define product quantity in administrator. For example, I have 1000 cm of product &quot;A&quot;, which can be sold in any length between 10cm - 400cm, and the user can select the quantity too. like 3 pieces of 30cm.  Should I define quantity in cm?  Thanks for your help.")* was created by *[::REZA::](/forum/user/40414-reza "View ::REZA::'s Profile")*

-- HikaShop version -- : 4.4.0
-- Joomla version -- : 3.9.23
-- PHP version -- : 7.3

Hi
I'm using Custom Quantity Plugin for some of my products and everything is ok. User inserts required length in cm, then selects quantity and cart updates successfully.

**The code in "custom quantity plugin".**Code:

$currencyClass = hikashop_get('class.currency'); $quantity = @$product-&gt;cart_product_quantity; if(!empty($product-&gt;length)){ $quantity = $quantity*$product-&gt;length/100; } $currencyClass-&gt;quantityPrices($product-&gt;prices,$quantity,$product-&gt;cart_product_total_quantity);

The question is how should I define product quantity in administrator. For example, I have 1000 cm of product "A", which can be sold in any length between 10cm - 400cm, and the user can select the quantity too. like 3 pieces of 30cm.

Should I define quantity in cm?

Thanks for your help.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzkwMjQ0MC1ob3ctdG8tZGVmaW5lLXF1YW50aXR5LWZvci1wcm9kdWN0cy10aGF0LXVzZS1jdXN0b20tcXVhbnRpdHktcGx1Z2luP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86363
- Thank you received: 14297
-
-

5 years 6 months ago [\#332014](#332014) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[How to define quantity for products that use "Custom Quantity Plugin"?](/forum/4-how-to/902440-how-to-define-quantity-for-products-that-use-custom-quantity-plugin#332014 "-- HikaShop version -- : 4.4.0 -- Joomla version -- : 3.9.23 -- PHP version -- : 7.3  Hi I'm using Custom Quantity Plugin for some of my products and everything is ok. User inserts required length in cm, then selects quantity and cart updates successfully.  The code in &quot;custom quantity plugin&quot;.  The question is how should I define product quantity in administrator. For example, I have 1000 cm of product &quot;A&quot;, which can be sold in any length between 10cm - 400cm, and the user can select the quantity too. like 3 pieces of 30cm.  Should I define quantity in cm?  Thanks for your help.")*

Hi,

You can't do that.
You can only define the number of times the product can be sold. And in the settings of the custom field where the dimension is entered, you can use the regular expression check setting to define the minimum and maximum length that can be entered in the field.
But there is no mechanism to calculate the total purchased length against an available length to restrict this.
That would require the development of a separate plugin to handle it.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzkwMjQ0MC1ob3ctdG8tZGVmaW5lLXF1YW50aXR5LWZvci1wcm9kdWN0cy10aGF0LXVzZS1jdXN0b20tcXVhbnRpdHktcGx1Z2luP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.041 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
