Shipping estimate also visible in related products

This topic has 9 replies, 3 voices, and was last updated 1 weeks, 2 days ago ago by Andrea

  • Avatar: Redgall
    Andrea
    Participant
    June 12, 2025 at 15:51

    In this code that you gave me the shipping estimate can be displayed within certain categories or by brand or tag etc. I removed it because it was not needed but now I can not display the shipping estimate within the related products. Can you help?

    Thanks.

    add_filter( ‘woocommerce_get_price_html’, ‘add_estimated_delivery_to_price’, 999, 2 );

    function add_estimated_delivery_to_price( $price, $product ) {
    /*if (is_tax(‘brand’) || is_shop() || is_product_category() || is_product_tag())*/
    { // Only in the shop and categories page

    // Escludi dalla pagina del singolo prodotto
    if ( is_product() ) {
    return $price;
    }

    ob_start();
    add_filter( ‘etheme_sales_booster_estimated_delivery’, ‘__return_true’ );
    $estimated_delivery = \Etheme_Sales_Booster_Estimated_Delivery::get_instance();
    $estimated_delivery->init( $product );
    $estimated_delivery->args[ ‘in_quick_view’ ] = true;
    $estimated_delivery->add_actions();
    $original_tag = $estimated_delivery->args[ ‘tag’ ];
    $estimated_delivery->args[ ‘tag’ ] = ‘div’;
    $estimated_delivery->output();
    $estimated_delivery->args[ ‘tag’ ] = $original_tag;
    remove_filter( ‘etheme_sales_booster_estimated_delivery’, ‘__return_true’ );
    $estimate = ob_get_clean();

    $price .= $estimate;
    }
    return $price;
    }

    8 Answers
    Avatar: Justin
    Luca Rossi
    Support staff
    June 13, 2025 at 06:41

    Dear Andrea,

    We hope this message finds you well.

    Kindly update the custom code to the following:

    
    add_filter('woocommerce_get_price_html', 'add_estimated_delivery_to_price', 999, 2);
    function add_estimated_delivery_to_price($price, $product) {
        if (is_product()) { // Only on the product page
    
            ob_start();
            add_filter('etheme_sales_booster_estimated_delivery', '__return_true');
            $estimated_delivery = \Etheme_Sales_Booster_Estimated_Delivery::get_instance();
            $estimated_delivery->init($product);
            $estimated_delivery->args['in_quick_view'] = true;
            $estimated_delivery->add_actions();
            $original_tag = $estimated_delivery->args['tag'];
            $estimated_delivery->args['tag'] = 'div';
            $estimated_delivery->output();
            $estimated_delivery->args['tag'] = $original_tag;
            remove_filter('etheme_sales_booster_estimated_delivery', '__return_true');
            $estimate = ob_get_clean();
    
            $price .= $estimate;
        }
        return $price;
    }
    

    Additionally, please include the following custom CSS under XStore > Theme Options > Theme Custom CSS > Global CSS:

    
    .elementor-widget-woocommerce-product-etheme_price .sales-booster-estimated-delivery {
        display: none !important;
    }
    

    Thank you in advance for your assistance.

    Best regards,
    The 8Theme Team

    Avatar: Redgall
    Andrea
    Participant
    June 13, 2025 at 10:05

    no unfortunately the code also removed in the category page of the products.

    I also had an idea that by eliminating it it would appear everywhere after
    if ( is_product() ) {
    return $price;
    }

    And so I would have had to work on css to hide where I did not want it to appear. But I was wondering if there was another way but it seems to me from your intervention that there is not.

    Avatar: Justin
    Luca Rossi
    Support staff
    June 13, 2025 at 10:24

    Dear Andrea,

    Thank you for reaching out.

    At this time, the current solution is the most suitable option available. Please note that any further customization would fall outside the scope of the standard support services we offer.

    We appreciate your understanding.

    Best regards,
    The 8Theme Team

    Avatar: Redgall
    Andrea
    Participant
    June 13, 2025 at 10:47

    Thanks always for the support you give and in a timely manner.

    I point out to you for the second time that since you introduce an element with a plus and in this case Product Estimate you must clarify before purchasing that this is limited in its display, that there is no control except deciding the min and max days. It may seem strange to you but I chose the XStore theme for the second time and this time it was precisely for this functionality that otherwise choosing another theme I would have had to buy another plugin. Well if I knew before that this functionality was limited I would not have chosen your theme again so stop writing that “any further customization is outside the scope of the standard support services we offer” because otherwise you write in the description of the theme how it works and that to make it display where one wants (for example category 1 yes category 2 no) you have to pay extra, in this way you leave freedom to choose your theme or not. Good work.

    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    June 13, 2025 at 11:56

    Dear @Andrea,

    We hope this message finds you well.

    Could you please provide us with screenshots and detailed information regarding the specific locations where you would like the estimated text to be displayed, as well as the areas where you prefer it not to appear? This will help us work on a solution that best meets your requirements.

    If possible, kindly include the URLs of the relevant pages as well.

    Thank you in advance for your cooperation.

    Best regards,
    Jack Richardson
    The 8Theme Team

    Avatar: Redgall
    Andrea
    Participant
    June 13, 2025 at 13:33

    Hi,
    maybe you will get it in the next update. You should have the option to decide where to show.

    Files is visible for topic creator and
    support staff only.
    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    June 13, 2025 at 15:56

    Dear @Andrea,

    We hope this message finds you well.

    Could you kindly review the following solution and let us know if it meets your requirements? You can find a preview of the implementation here: https://prnt.sc/aaXyehdDni-n.

    This solution enables the Estimated Delivery feature to be displayed within any Product grid, list, or carousel widget. You can choose to show this information only in the widgets where it is relevant.

    To implement this functionality, we have made modifications to your child-theme/functions.php file by adding the following code snippet:

    add_filter('etheme_product_grid_list_product_elements', function($elements) {
        $stock_position = array_search('stock', array_keys($elements));
        if ( $stock_position > 1 ) {
            $elements = array_slice( $elements, 0, $stock_position, true ) +
                        array( 'et_estimated_delivery' => esc_html__( 'Estimated Delivery', 'xstore-child' ) ) +
                        array_slice( $elements, $stock_position, count( $elements ) - $stock_position, true );
        } else {
            $elements['et_estimated_delivery'] = esc_html__( 'Estimated Delivery', 'xstore-child');
        }
        return $elements;
    });
    
    add_action( 'etheme_product_grid_list_product_element_render', function($key, $product, $edit_mode, $main_class) {
        if ( $key == 'et_estimated_delivery' ) { 
            add_filter('etheme_sales_booster_estimated_delivery', '__return_true');
            $estimated_delivery = \Etheme_Sales_Booster_Estimated_Delivery::get_instance();
            $estimated_delivery->init($product);
            $estimated_delivery->add_actions();
            $original_tag = $estimated_delivery->args['tag'];
            $estimated_delivery->args['tag'] = 'div';
            $estimated_delivery->output();
            $estimated_delivery->args['tag'] = $original_tag;
            remove_filter('etheme_sales_booster_estimated_delivery', '__return_true');
        }
    }, 10, 4 );

    You can view the frontend result here: https://prnt.sc/WkWw91mYOpyU.

    We would greatly appreciate your feedback to confirm whether this solution addresses your request.

    Best regards,
    Jack Richardson
    The 8Theme Team

    Avatar: Redgall
    Andrea
    Participant
    June 13, 2025 at 16:37

    But this is a great result, fantastic!
    I hope that sooner or later this default change will be added so as to remove in the function.php file but for now it’s good like this! Thanks again for your effort!

  • Viewing 9 results - 1 through 9 (of 9 total)

The issue related to '‘Shipping estimate also visible in related products’' has been successfully resolved, and the topic is now closed for further responses

Helpful Topics

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.