M
M
MaximYurin2017-02-14 01:58:39
WooCommerce
MaximYurin, 2017-02-14 01:58:39

How to set a step of 50 units for a certain category of goods in the basket in the input, and also assign a price for these 50 units. to have a correct calculation?

Good day. Guys please help a newbie. The question is. How to assign a step in the input of 50 units (50,100,150,200), etc. in the shopping cart for a certain category of a group of goods (let's say we have a snack category). Let's say we are talking about grams. I tried to use the WooCommerce Advanced Product Quantities plugin, it seemed to be what I needed, in terms of a step of 50, but in terms of pricing and in terms of functionality, it did not work quite correctly. Maybe you can set rules or a function for the step in the input for the snack category, as well as rules for the correct calculation ??? Or are there any other approaches or methods how to solve this kind of issue. The photo is attached to make it clear what I'm interested to know. Thank you all in advance for your help and understanding! All the best to you!!!
2b12049fff88437d9c889b37684cb96b.jpg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WP Panda, 2017-02-14
@MaximYurin

I just crashed the woocommerce test site, and I can’t check it.
But judging by this.
https://docs.woocommerce.com/wc-apidocs/source-fun...
and this
https://github.com/woocommerce/woocommerce/blob/ma...
You need to do this:

add_filter( 'woocommerce_quantity_input_args', 'wpp_woocommerce_step_quantity_input', 10, 2 );

function wpp_woocommerce_step_quantity_input( $args, $product ) {
       // ТУТ можете слазить в $product и сделать проверку на доп условие
       // которое допишите к if ( is_cart( ) && допусловие  )
  if ( is_cart( ) ) {
                  $args['min_value']  = 50;
            $args['step']            = 50; 
        }
  return $args;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question