Home Forums WoodMart support forum contact us button

contact us button

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #659805

    guy-7200
    Participant

    hey
    i have some products without price and want to have to have a Contact Us button for them, how can do it?

    #659989

    Hello,

    There is no option available for this in the theme settings. This requires customization, which is beyond our support policy.

    I have searched for a possible solution and found a custom function that you can add to your functions.php file. I have tested this code on our test site, and it is working fine.

    If the provided code does not work as expected, unfortunately, we are unable to modify it further.

    Add this to your theme’s functions.php file of the theme.

    // Display "Contact Us" button on single product and shop page if price is missing
    add_action( 'woocommerce_after_shop_loop_item', 'show_contact_us_button_on_archive', 20 );
    add_action( 'woocommerce_single_product_summary', 'show_contact_us_button_on_single', 20 );
    
    function show_contact_us_button_on_archive() {
        global $product;
        if ( ! $product->get_price() ) {
            echo '<a href="' . esc_url( get_permalink( get_page_by_title( 'Contact Us' ) ) ) . '" class="button contact-us-button" style="background-color: #0073aa; color: #fff; padding: 10px 15px; display: inline-block; margin-top: 10px;">Contact Us</a>';
        }
    }
    
    function show_contact_us_button_on_single() {
        global $product;
        if ( ! $product->get_price() ) {
            echo '<a href="' . esc_url( get_permalink( get_page_by_title( 'Contact Us' ) ) ) . '" class="button contact-us-button" style="background-color: #0073aa; color: #fff; padding: 10px 20px; margin-top: 10px; display: inline-block;">Contact Us</a>';
        }
    }

    Hope this Helps!

    Best Regards,

    #659997

    guy-7200
    Participant

    i will try that .
    thank you im appreaciat your help

    #660050

    Hello,

    You’re very welcome! I’m glad I could help. If you need anything else, feel free to reach out!

    Thanks for contacting us.
    Have a great day.

    Best Regards,

Viewing 4 posts - 1 through 4 (of 4 total)