function decrease_stock(int $product_id): void { $quantity = (int) get_post_meta($product_id, '_stock', true); update_post_meta($product_id, '_stock', $quantity - 1); } decrease_stock($product_id);