// image 5
function add_image_5_meta_field() {
global $post;
// Get the existing value
$image_5 = get_post_meta($post->ID, ‘image_5’, true);
// Output the field
echo ‘<div class=”options_group”>’;
woocommerce_wp_text_input(
array(
‘id’ => ‘image_5’,
‘label’ => __(‘Image_5’, ‘woocommerce’), // Updated label
‘placeholder’ => __(‘Enter Image_5 Time’, ‘woocommerce’),
‘desc_tip’ => ‘true’,
‘description’ => __(‘This is a custom meta field for Image_5 time.’, ‘woocommerce’),
‘value’ => $image_5,
)
);
echo ‘</div>’;
}
add_action(‘woocommerce_product_options_general_product_data’, ‘add_image_5_meta_field’);
// Save image_5 meta field data
function save_image_5_meta_field($post_id) {
$image_5 = isset($_POST[‘image_5’]) ? sanitize_text_field($_POST[‘image_5’]) : ”;
update_post_meta($post_id, ‘image_5’, $image_5); // Updated meta key
}
add_action(‘woocommerce_process_product_meta’, ‘save_image_5_meta_field’);
// Add image_5 meta field to REST API response
function add_image_5_to_api($response, $post, $request) {
$image_5_value = get_post_meta($post->ID, ‘image_5’, true); // Updated meta key
if ($image_5_value) {
$response->data[‘meta_data’][] = array(
‘key’ => ‘image_5’, // Updated meta key
‘value’ => $image_5_value,
);
}
return $response;
}
add_filter(‘woocommerce_rest_prepare_product_object’, ‘add_image_5_to_api’, 10, 3);
This code is in the functions.php create a field for getting the IMAGE URL from NetSuite and this will be called in the Product detail Page