Why does the WooCommerce connector use regular_price instead of price?

Why does the WooCommerce connector use regular_price instead of price?

TL;DR

Because price in WooCommerce is a computed, read-only field, while regular_price is the correct field for setting product prices via the API.

How WooCommerce pricing works (API perspective)

In the WooCommerce REST API, product pricing is split into different fields with very different roles:

Field

Description

regular_price

The base product price (normal price, no discount). This is the field that must be used to set or update prices via the API.

sale_price

Optional discounted price. If set (and valid), WooCommerce considers the product “on sale”.

price

A calculated field that represents the final effective price:

  • equals sale_price if a sale is active

  • otherwise equals regular_price

Field price is derived by WooCommerce internally and is not intended to be written to directly.

Official API reference: https://woocommerce.github.io/woocommerce-rest-api-docs/#products

Summary

WooCommerce treats price as a calculated field, derived automatically from regular_price and sale_price. For this reason, the connector always uses regular_price, ensuring predictable behavior and full compatibility with the WooCommerce REST API.

Related Posts