How to change the text add to cart to pre order?

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

  • Avatar: Ombi
    Ombi
    Participant
    December 15, 2024 at 14:41

    Good afternoon friends,

    Currently our online store has 2 types of products. pre-order and in-stock products.

    I created 2 product templates, one for pre-order and one for in-stock. For pre-order I want to change the text button to pre-order.

    While for available products the text remains the default, how do I do it? I don’t see edit text in the settings.

    Files is visible for topic creator and
    support staff only.
    3 Answers
    Avatar: Justin
    Luca Rossi
    Support staff
    December 16, 2024 at 10:32

    Dear @Ombi,

    Thank you for reaching out to us.

    To address your request, the solution involves creating a “Pre-order” product category and assigning the relevant products to this category. Once this is done, you can modify the “Add to Cart” button text by adding the following custom code to the functions.php file located in your XStore child theme:

    
    add_filter( 'woocommerce_product_single_add_to_cart_text', 'woocommerce_add_to_cart_button_text_single' );  
    function woocommerce_add_to_cart_button_text_single() {  
        if ( has_term( 'pre-order', 'product_cat' ) ) {  
            return 'Pre-Order';  
        }  
        return __( 'Add To Cart', 'woocommerce' );  
    }  
    

    We hope this solution meets your requirements. Should you have any further questions or need additional assistance, please do not hesitate to contact us.

    Best regards,
    The 8Theme Team

    Avatar: Ombi
    Ombi
    Participant
    December 17, 2024 at 08:44

    its work, thank you

    Avatar: Justin
    Luca Rossi
    Support staff
    December 17, 2024 at 09:01

    Glad it’s working fine.

    If you need anything else please let us know.

    Best regards,
    The 8Theme Team

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

The issue related to '‘How to change the text add to cart to pre order?’' has been successfully resolved, and the topic is now closed for further responses

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