How to display product labels / product badges before or after product details

This topic has 4 replies, 2 voices, and was last updated 5 days, 3 hours ago ago by Luca Rossi

  • Avatar: Yasir Alam 8Theme
    Yasir Alam 8Theme
    Participant
    December 16, 2024 at 08:30

    Please check the private content area

    Content is visible for topic creator and
    support staff only.
    Files is visible for topic creator and
    support staff only.
    3 Answers
    Avatar: Justin
    Luca Rossi
    Support staff
    December 17, 2024 at 07:51

    Dear @Yasir Alam,

    Thank you for reaching out to us.

    We would like to inform you that there is a hook available that allows you to add custom code to display your badges and the Sale Booster estimated delivery date.

    To implement this, please try adding the following custom code to the functions.php file located in your XStore Child Theme:

    
    add_action('after_etheme_product_grid_list_product_element_title', 'after_etheme_product_grid_list_product_element_title', 999);  
    function after_etheme_product_grid_list_product_element_title(){  
        echo do_shortcode('[your-badges-shortcode]');  
        echo do_shortcode('[etheme_sales_booster_estimated_delivery]');  
    }  
    

    Should you have any questions or require further assistance, please do not hesitate to contact us.

    Best regards,
    The 8Theme Team

    Avatar: Yasir Alam 8Theme
    Yasir Alam 8Theme
    Participant
    December 17, 2024 at 08:08

    Please check private content area

    Content is visible for topic creator and
    support staff only.
    Files is visible for topic creator and
    support staff only.
    Avatar: Justin
    Luca Rossi
    Support staff
    December 17, 2024 at 11:22

    Hi @Yasir Alam 8Theme,

    What’s your product badges, so we can replace the shortcode for you?

    We already see you have this code in your website:

    
    function after_etheme_product_grid_list_product_element_title() {   
        // Run the shortcode and capture the output
        $shortcode_output = do_shortcode('[etheme_sales_booster_estimated_delivery days_type="number"]');
    
        // Debug: Output the shortcode result to check its format
        // echo '<pre>' . print_r($shortcode_output, true) . '</pre>';
    
        // Extract the numbers (days) from the shortcode output
        preg_match_all('/\d+/', $shortcode_output, $matches);
    
        // Ensure we are getting the correct numbers, looking for the last number (max_days)
        $days = isset($matches[0]) ? $matches[0] : [];
        
        if (count($days) < 2) {
            // If we only have one number, use it for max_days
            $max_days = isset($days[0]) ? intval($days[0]) : 0;
        } else {
            // Otherwise, use the second number as max_days
            $max_days = intval($days[1]);
        }
    
        // Convert max days to hours
        $max_hours = $max_days * 24;
    
        // Output the custom HTML with the max hours
        echo '
        <div class="delivery">
            <div class="express">
                <img src="https://axhubs.com/wp-content/uploads/axhub-logo.svg" class="mr-1" alt="">
                <div><span style="font-weight: bold;margin-right:2px;">Express Delivery:</span> ' . $max_hours . ' hours</div>
            </div>
        </div>';
    
    }
    

    Best regards,
    The 8Theme Team

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

You must be logged in to reply to this topic.Log in/Sign up

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.