Fix brand and cost meta retrieval using get_post_meta

- Changed from $product->get_meta() to get_post_meta()
- get_post_meta() is more reliable for custom meta fields
- Fixed cost decimal places to 2

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-13 09:28:13 +01:00
parent 0683f794dc
commit 32b1024032

View File

@@ -884,10 +884,10 @@ class Informatiq_SP_Admin {
$product_id = $product->get_id();
// Get brand and cost from meta.
$brand = $product->get_meta( '_brand', true );
$cost = $product->get_meta( '_cost', true );
$cost = $cost !== '' ? round( (float) $cost, 4 ) : null;
// Get brand and cost from post meta.
$brand = get_post_meta( $product_id, '_brand', true );
$cost = get_post_meta( $product_id, '_cost', true );
$cost = ( $cost !== '' && $cost !== false ) ? round( (float) $cost, 2 ) : null;
// Get local price (tax-inclusive for comparison with Google).
$sale_price = $product->get_sale_price();