Everything you need to know about the ACF add-on

This document explains what the ACF add-on for Advanced Product Fields for WooCommerce does and how it can be set up.

Introduction

The ACF add-on allows you to use ACF fields alongside our plugin’s formula-based pricing feature. This is particularly helpful when your product pricing relies on extra information you want to manage within your WordPress admin dashboard, whether it’s within an ACF options page or ACF fields on the product page itself.

Learn by example

Consider this scenario: you’re in the business of selling raw gold products. The price of gold changes daily, so you would have to adjust all your product prices daily too. That’s a lot of work an not a good use of your time!

Instead of manually editing all products every day, it would be a better idea to create an ACF setting in your WordPress dashboard where you can easily update the unit price of gold.

This variable can be used in formula-based pricing so all your products are immediately up-to-date with the the price changes.

Let’s build this example!

How to set it up

To follow this tutorial, you should know what ACF is and how it works. If not, we suggest heading over to the ACF website to familiarize yourself.

There are 2 ways you can add additional data to your WooCommerce products with ACF:

  1. Via an options page, which is a global page accessible through the WordPress menu.
  2. By adding the data via the Edit Product screen.

ACF

In our example, we create an option page. It’s a page that appears in the WordPress main menu so you can easily access it. We created a page for our gold settings:

From then on, you can use ACF as you are familiar with to create the settings that should appear on the page. We created a simple number field to hold the unit price:

Advanced Product Fields for WooCommerce

Since we are using an ACF options pag, we need to enable that formula in the WooCommerce settings at WooCommerce > Settings > Product Fields > ACF Integration:

Next, you can access this value in pricing formulas of fields created with Advanced Product Fields for WooCommerce.

Below is our example product. Customers can buy raw gold grains and choose how much grams they want:

The formula to correctly multiply the chosen grams with the price as defined through ACF is easy:

acf_option(gold_unit_price) * 5

acf_option() is the function that accesses a value from an ACF options page and gold_unit_price is the key of the ACF field we created.

Here is the configuration of our select field:

The ACF addon exposes 2 functions you can use in formula-based pricing:

  • acf() to target an ACF field defined on the Edit Product screen.
  • acf_option() to target an ACF field defined in any of your option screens.

Was this article helpful?

Related Articles