Automattic\WooCommerce\Internal\CLI\Migrator\Platforms\Webflow
WebflowMapper::extract_prices
Convert Webflow price.value (minor units, e.g. cents) into a decimal string, and detect sale pricing via compare-at-price.
Method of the class: WebflowMapper{}
No Hooks.
Returns
Array{regular_price:. ?string, sale_price: ?string}
Usage
// private - for code of main (parent) class only $result = $this->extract_prices( $sku_field ): array;
- $sku_field(object) (required)
- SKU fieldData.
WebflowMapper::extract_prices() WebflowMapper::extract prices code WC 11.0.0
private function extract_prices( object $sku_field ): array {
$price = $this->price_to_decimal( $sku_field->price ?? null );
$compare_key = 'compare-at-price';
$compare_price = $this->price_to_decimal( $sku_field->{$compare_key} ?? null );
if ( null !== $compare_price && null !== $price && (float) $compare_price > (float) $price ) {
return array(
'regular_price' => $compare_price,
'sale_price' => $price,
);
}
return array(
'regular_price' => $price,
'sale_price' => null,
);
}