Artmart
Artmart

Reputation: 51

Making the +/- Plus and Minus quantity button go up in increments of 12 in WooCommerce

I have been trying to solve what I thought might be an easy fix but I can't seem to find any information anywhere.

My problem is this:

I am setting up a wholesale store using WooCommerce with the min/max quantity and wholesale store plugins. I want to show a simple product with its single unit price (no problem) but as all products in the store are wholesale they can only be sold in (multiples) cartons of 6 or 12.

The min/max plugin allows me to set a minimum order quantity (say 12 items) but when I click on the -/+ Minus and Plus quantity selector to add another carton (another 12 items) it only adds one number (single item) at a time... E.g. 13, 14, 15, 16 and so on.

So my question is... "Is it possible to modify the 'quantity.php' file so the order quantities only go up in increments of 12?" (E.g. 12, 24, 36, 48, etc.)

I know I could simply set up and show the single carton cost as a simple product or do variables but my client wants to show a per unit price.

Thanks in advance for any feedback you may have.

Upvotes: 5

Views: 7167

Answers (4)

helgatheviking
helgatheviking

Reputation: 26319

There's no need to change core, nor even to use WooCommerce's template override. As Rashid points out, there is a filter in place for modifying this value. We just need to use it. Put this in a site-specific plugin.

add_filter( 'woocommerce_quantity_input_step', 'kia_quantity_input_step', 10, 2 );
function kia_quantity_input_step( $step, $product ){
    return 6; // the will be the new step value
}

Upvotes: 1

rashid
rashid

Reputation: 296

I wanted similar functionality for my cart section which I achieved like this.

In the woocommerce template file forlders navigate to cart->cart.php file then search for something like this

apply_filters( 'woocommerce_quantity_input_step', '1', $_product );

Then change '1' to '12'. I believe it should be similar if you want to change on single product page.

Upvotes: 0

Ben Donahower
Ben Donahower

Reputation: 1

I'm sure you've moved on by now, but for posterity's sake this plug in might do what you are looking for:

http://www.woothemes.com/products/minmax-quantities/

Upvotes: 0

Ewout
Ewout

Reputation: 2478

This is quite hard to do without any hackery. If you don't mind changing a core file (which you will have to do again each time you update WooCommerce), you can do the following:

  • open wp-content/plugins/woocommerce/assets/js/frontend/woocommerce.js
  • go to line 34 "$qty.val(currentVal + 1);" and change '1' into '12'.
  • do the same for the minus function on line 52

note that this affects ALL products!

Upvotes: -1

Related Questions