get_field_positions(); wp_localize_script( 'cfep-block-checkout-reorder', 'cfepBlockCheckoutData', array( 'fieldPositions' => $field_positions, ) ); } /** * Get all field positions for JavaScript */ private function get_field_positions() { $all_fields = CFEP_Block_Field_Manager::instance()->get_all_fields(null, true); $positions = array(); foreach ($all_fields as $field) { if (!$field['enabled']) { continue; } $key = $field['field_key']; $position = (int)$field['position']; // Add all possible variations of the field key $positions[$key] = $position; // Without prefix $base_key = str_replace(array('shipping_', 'billing_', 'cfep/'), '', $key); $positions[$base_key] = $position; // With cfep- prefix (how it might appear in HTML) $positions['cfep-' . $base_key] = $position; // With cfep/ prefix $positions['cfep/' . $base_key] = $position; } return $positions; } }