wordpress - Filter to check quantity at checkout -


I have a specific task that is possible I want to apply with WooCommerce. I have a method that allows me to do WUIJOIRE Check if the amount of items in the cart is divisible by 12?

Actually I have a shop setup, but I need customers to order order quantity of 12 (this is the size of the box that I ship these items). However, I have some product variations (size, width, etc.) and I want the customer to mix variations to reach the quantities of 12 or (24, 36, etc.).

I believe that the easiest way to do this is to establish a function that checks the total cart quantity and if it is divisible by 12. If so, then he can move forward. If not, then they need to change their amounts to continue. Does anyone have experience on whether there is a plugin that suits it or if there is some custom code that I can add?

Any help is greatly appreciated.

Regards, Ryan

This should work for you:

Add the following to the function. php file will check it in checkout and see if there is a multiple of volume 12, if so, then it is okay, if you do not get the error message, then you need to buy 12 products quantity will not be able to move forward.

  add_action ('woocommerce_check_cart_items', 'woocommerce_check_cart_quantities'); Function woocommerce_check_cart_quantities () {global $ woocommerce; $ Multiplier = 12; $ Total_products = 0; Forex Currency ($ woocommerce-> Cart-> get_cart () $ cart_item_key = & gt; $ values) {$ total_products + = $ value ['quantity']; } If (($ total_products% $ multiplier)> 0) $ woocommerce- & gt; add_error (sprintf (__ ('you need to buy quantity of products%', 'woocommerce'), $ multiples); }   

The above post has made some changes.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -