I am currently creating my first site using woocommerce for a client, and they are requesting for me to have a price increase per variation and quantity, however i am not sure how to do it. Here is an example of what they are asking for:
Product Type: Limestone
Variations:
- Product Size:
- 10kg bag
- 20kg bag
- 40kg bag
- Quantity:
- 1-20
TL;DR if the customer wants multiple 10kg bags, the price increases by £36 at a time, if they want multiple 20kg bags, the price increases by £30 at a time, and if they want multiple 40kg bags, the price doubles every time.
I have used woocommerce variations and attributes so far but now it would require modifying having 3x20 variations all of which require a different price, which would be easier to change if a statement is possible as follows:
if ($productsize === '10kg') {
$quantity = 2; //get quantity from textbox $_POST
$initial_price = 36; //get inital price from woocommerce global variable
$total_price = $inital_price * $quantity;
update_price($total_price); //a function to update the price in woocommerce when adding to cart
}
Obviously the code above does not use any woocommerce variables, however doing this for only 3 variations would be easier than manually entering 60 variations on one product for which we have >60 on our site.
Thanks in advance for any help.