Minimal quantity of product to order

  • Posts: 210
  • Thank you received: 4
  • Hikashop Business
4 years 8 months ago #309473

-- HikaShop version -- : 4.2.1
-- Joomla version -- : 3.9.10
-- PHP version -- : 7

Hi,

How to enable the setting to add products to the cart not by one thing, but by how much you install in the product?

For example, it has product, the price is indicated per piece, while it is sold in packages of only 100 pieces.
Moreover, if people add this product to the basket, they will add 100, 200, 300, and so on.

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
4 years 8 months ago #309478

Hello,

You'll probably find a solution through that thread :

There is now a "show select price" choice for the "quantity input" setting of the products so that the dropdown can be based on the minimum quantities of your product prices.
So enter the different unit prices (which can be the same) and their respective minimum quantities in the Prices section and the system will base itself on them to display the quantity dropdown.


www.hikashop.com/forum/product-category-...-listing.html#243656

Please Log in or Create an account to join the conversation.

  • Posts: 210
  • Thank you received: 4
  • Hikashop Business
4 years 8 months ago #309513

this theme is too dificult

is any solution like <input type="number" step="step_number"> there i can choose step_number in
product page backoffice ?

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
4 years 8 months ago #309516

Hello,

That kind of solution will require custom development, can you give us more information about what you want and why ? So that we can properly advise you ? Thank you.

Kind regards,
Mohamed Thelji.

Please Log in or Create an account to join the conversation.

  • Posts: 210
  • Thank you received: 4
  • Hikashop Business
4 years 8 months ago #309649

Mohamed Thelji wrote: Hello,

That kind of solution will require custom development, can you give us more information about what you want and why ? So that we can properly advise you ? Thank you.

Kind regards,
Mohamed Thelji.


I want to make sure that the basket is added immediately
the quantity of goods is a multiple of how much will be indicated in the product settings. for example, immediately 20, 50, 200, 1000 pieces, etc.
and if you set 20 pc per step only 20, 40, 60, 80 etc will be added in to basket.

This is necessary cauz some goods are sold only in packages, but from the data source information about them is stored in pieces and the price is indicated for a piece, not for a package. But a package may include more than 1 pc, for ex. 100 pcs, so it have to be
100, 200, 300 , 400 etc pcs to cart , but user (buyer) may not understand about it, i mean you cant add 102 pcs of such product into cart.

in other words, we sell some goods only in bulk, do not sell at retail.

Please Log in or Create an account to join the conversation.

  • Posts: 81513
  • Thank you received: 13068
  • MODERATOR
4 years 8 months ago #309655

Hi,

If you use "show select" in the "quantity input method" setting and enter the minimum quantity per order to 100, then the quantity input field will automatically be 100,200,300,400,etc
This should do what you need I think.

Please Log in or Create an account to join the conversation.

  • Posts: 210
  • Thank you received: 4
  • Hikashop Business
4 years 8 months ago #309677

nicolas wrote: Hi,

If you use "show select" in the "quantity input method" setting and enter the minimum quantity per order to 100, then the quantity input field will automatically be 100,200,300,400,etc
This should do what you need I think.


it is inconvenient, caus "show select" in the "quantity input method" change all web site view
from html5 input to select input.

Please Log in or Create an account to join the conversation.

  • Posts: 81513
  • Thank you received: 13068
  • MODERATOR
4 years 8 months ago #309691

In that case, you want to edit the file "quantity" of the view "layouts" via the menu Display>Views and customize the display of the quantity input to meet your needs.

Please Log in or Create an account to join the conversation.

  • Posts: 210
  • Thank you received: 4
  • Hikashop Business
4 years 8 months ago #309753

nicolas wrote: In that case, you want to edit the file "quantity" of the view "layouts" via the menu Display>Views and customize the display of the quantity input to meet your needs.


do you mean like i may try to make custom field and after include into quantity.php like if this custom field is like i need
show input with step ?

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
4 years 8 months ago #309765

Hello,

I'm sorry but I didn't fully understand what you meant through your last message.
Nicolas only advised your to edit the code of the "quantity" file of the "layouts" view of your front-end template, through the page "Hikashop->Display->Views", so that you could change the displaying of the dropdown according to your needs.

Editing these line will do the job :

	case 'show_select':
		if(empty($max_quantity))
			$max_quantity = (int)$min_quantity * 15;
?>
		<div class="hikashop_product_quantity_div hikashop_product_quantity_input_div_select"><?php
			$r = range($min_quantity, $max_quantity, $min_quantity);
			if(!in_array($current_quantity, $r))
				$r[] = $current_quantity;
			if(!in_array($max_quantity, $r))
				$r[] = $max_quantity;
			$values = array_combine($r, $r);
			ksort($values);
			echo JHTML::_('select.genericlist', $values, '', 'style="width:auto;" class="no-chzn" onchange="var el = document.getElementById(\''.$id.'\'); el.value = this.value; el.onchange();"', 'value', 'text', $current_quantity, $id.'_select');
			?>
			<input id="<?php echo $id; ?>" type="hidden" value="<?php echo $current_quantity; ?>" class="hikashop_product_quantity_field" name="<?php echo $quantity_fieldname; ?>" data-hk-qty-old="<?php echo $current_quantity; ?>" data-hk-qty-min="<?php echo $min_quantity; ?>" data-hk-qty-max="<?php echo $max_quantity; ?>" onchange="<?php echo $script; ?>" <?php echo $extra_data; ?> />
		</div>
<?php
		break;
We wish you a nice day !
Kind regards,
Mohamed Thelji.

Please Log in or Create an account to join the conversation.

  • Posts: 210
  • Thank you received: 4
  • Hikashop Business
2 years 7 months ago #335503

Hello there,

I custimozed some code in show_quantity.php

case 'show_html5':
		$html5_data = ((int)$max_quantity > 0) ? 'max="'.(int)$max_quantity.'"' : '';

		$step=$min_quantity;
?>
		<div class="hikashop_product_quantity_div hikashop_product_quantity_input_div_simplified">
			<input id="<?php echo $id; ?>" type="number" step="<?php echo $step; ?>" min="<?php echo $min_quantity; ?>" value="<?php echo $current_quantity; ?>" class="hikashop_product_quantity_field" name="<?php echo $name; ?>" data-hk-qty-min="<?php echo $min_quantity; ?>" data-hk-qty-max="<?php echo $max_quantity; ?>"  onchange="window.hikashop.checkQuantity(this);" />
		</div>

Where to find window.hikashop.checkQuantity(this) function ? Now i need to make feature = if user adds to basket quantity thru manual , popup message have to display text = Warning the quantity must be a multiple of the minimum quantity !

Like then user try to add quantity more than it on stock popup message

Thanx

Last edit: 2 years 7 months ago by Bender.

Please Log in or Create an account to join the conversation.

  • Posts: 81513
  • Thank you received: 13068
  • MODERATOR
2 years 7 months ago #335508

Hi,

The checkQuantity function is located in the file media/com_hikashop/js/hikashop.js
Note however that you don't need to modify the code of that function in that file.
First, you could copy / paste the code of that function in the view file like this:

<script>
window.hikashop.checkQuantity = function (el) {
 .... code ....
}
</script>
That way, it would override the default function we have in HikaShop and thus you wouldn't loose your modifications to it when you update.

Another solution is to register the event quantity.checked:
<script>
window.Oby.registerAjax(["quantity.checked"],function(params){
 console.log(params.el);
}
</script>
As you can see in the default checkQuantity function, the code to display the notification popup is:
if(hkjQuery.notify) {
				this.translate(['QUANTITY_CHANGE_IMPOSSIBLE', 'MINIMUM_FOR_PRODUCT_IS_X'], function(trans){
					hkjQuery(el).notify({title:trans[0],text:trans[1].replace('%s', min), image:'<i class="fa fa-3x fa-exclamation-circle"></i>'},{style:"metro",className:"warning",arrowShow:true});
				});
			}
You just need to check the key MINIMUM_FOR_PRODUCT_IS_X to a custom translation key of yours

Please Log in or Create an account to join the conversation.

Time to create page: 0.110 seconds
Powered by Kunena Forum