• Resolved Rich Holmes

    (@reholmes27)


    When clicking the preview icon, next to an order on the order list page, the modal pops up and makes the shipping address a link to a map URL. I’d like to remove the link and just have it as plain text, but the template doesn’t allow this and I can’t see any hooks that will help. Ideally there should be an option that if the shipping_address_map_url doesn’t equal NULL then show the link, otherwise just show the address. I can see how to remove the url from the data but that just puts a link with an empty href.

    • This topic was modified 1 year, 2 months ago by Rich Holmes.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    To remove the shipping address map link and display it as plain text in the WooCommerce order preview modal, you’ll need to make some modifications to your theme’s template files. Specifically, you’ll want to override the template responsible for rendering the order preview modal. Here’s a step-by-step guide on how to achieve this:

    1. Create a Child Theme (Optional): If you’re not already using a child theme, it’s a good practice to create one. This ensures that your customizations won’t be lost when the parent theme is updated.
    2. Locate the Template File: In your WooCommerce plugin or theme folder, find the template file responsible for rendering the order preview modal. This file is typically named something like order-preview.php or similar.
    3. Copy the Template to Your Child Theme: If you’re using a child theme, create a directory within your child theme folder named woocommerce. Then, copy the order-preview.php file from the parent theme or WooCommerce plugin into this woocommerce folder within your child theme.
    4. Edit the Template File: Open the copied order-preview.php file in a code editor. Look for the section of code that generates the shipping address link, which might look something like this:
       <?php if ( ! empty( $shipping_address_map_url ) ) : ?>
           <a href="<?php echo esc_url( $shipping_address_map_url ); ?>" target="_blank"><?php echo esc_html( $shipping_address ); ?></a>
       <?php else : ?>
           <?php echo esc_html( $shipping_address ); ?>
       <?php endif; ?>
    1. Modify the Code: Replace the code above with the following:
       <?php echo esc_html( $shipping_address ); ?>

    This modification will display the shipping address as plain text without a link to the map URL.

    1. Save the File: Save your changes to the order-preview.php file.
    2. Test: Visit your WooCommerce order list page and click the preview icon next to an order. The shipping address should now be displayed as plain text without a map link.

    By following these steps, you should be able to remove the shipping address map link in the order preview modal. Keep in mind that template file locations and structures can vary depending on your theme and WooCommerce version, so the exact file and code may differ slightly. Always back up your files before making changes, and be cautious to avoid breaking your site.

    Thread Starter Rich Holmes

    (@reholmes27)

    Hi

    Thanks for this but in this case it’s not a template file. The preview template is loaded from a function in the ListTable class, so I can’t copy to a child theme.

    Rich

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Remove the shipping address map link on preview modal’ is closed to new replies.