Using Product Attributes in WooCommerce price calculations

By: Jason Berry | Asked: 09/07/2023
ForumsCategory: Code HelpUsing Product Attributes in WooCommerce price calculations
Jason Berry asked 1 year ago

When doing a WooCommerce product options form and calculating price based on a formula, is it possible to use a product attribute as part of that formula?

My example is as follows:

I have 3 products that are identical except each product has an attribute called "number of buttons". 

Product 1 has 1 button

Product 2 has 2 buttons

Product 3 has 3 buttons  

I have a "custom options" form allowing them to select the color of their buttons. What I need to do is charge, by color, multiplied by how many buttons that product has. I have this in another plugin already, but looking to see if FF can do it too.

Red costs $1/button

Blue costs $3/button

So the math formula would be: "[color price, which is a FF field] * [product_attribute_number_of_buttons]" Is it possible to reference the product attribute (i.e. it's not a FF field itself) in the formula?

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right