get_id() ); } /** * {@inheritDoc} */ public function run( WC_Product $product ) { $result = $this->result(); $price = $product->get_price(); $has_price = '' !== (string) $price && is_numeric( $price ) && (float) $price > 0; $stock_status = (string) $product->get_stock_status(); $has_status = '' !== $stock_status; $manages_stock = $product->managing_stock(); $stock_quantity = $product->get_stock_quantity(); $qty_consistent = ! $manages_stock || ( null !== $stock_quantity ); // Price is the dominant signal (0.6); coherent availability is the rest. $score = ( $has_price ? 0.6 : 0.0 ) + ( $has_status && $qty_consistent ? 0.4 : 0.0 ); $result->set_score( $score ); if ( ! $has_price ) { $result->add_issue( 'missing_price', __( 'No price set — agents cannot recommend or transact a product without a price.', 'agentictrack-agent-readiness-for-woocommerce' ), ARWC_Check_Result::SEVERITY_CRITICAL ); } if ( ! $has_status ) { $result->add_issue( 'missing_stock_status', __( 'Stock status is undefined — set in stock / out of stock explicitly.', 'agentictrack-agent-readiness-for-woocommerce' ), ARWC_Check_Result::SEVERITY_WARNING ); } if ( $manages_stock && null === $stock_quantity ) { $result->add_issue( 'managed_stock_no_quantity', __( 'Stock management is on but no quantity is set — availability is ambiguous to agents.', 'agentictrack-agent-readiness-for-woocommerce' ), ARWC_Check_Result::SEVERITY_WARNING ); } return $result; } }