Tagged: 

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #707901

    Hi want to add a phone number to every product after the buy button on the single product page in a Woocommerce store. Where do I start?
    Thanks

    #708650

    Hey fanlokbun,

    Try to add this code in functions.php:

    add_action( 'woocommerce_after_add_to_cart_button', 'addtocart_button_func' );
    function addtocart_button_func() {
            echo '<div class="my_phone_number">XXX-XXXX</div>';
    }

    Just replace XXX-XXXX with your phone number. Let us know if it works :)

    Best regards,
    Nikko

    • This reply was modified 8 years, 1 month ago by Nikko.
    #708685

    Hi Nikko,
    I get this error:

    Parse error: syntax error, unexpected ‘addtocart_button_func’ (T_STRING), expecting ‘(‘ in /home/fordtrac/public_html/fordtractorsales.co.uk/wp-content/themes/orion-theme/functions.php on line 17

    This is line 17:
    function add_content_after addtocart_button_func() {
    Thanks for your help
    Rob

    #708885

    Hi,

    Sorry about that, I have fixed the code I have given above, can you try to check it out.

    Best regards,
    Nikko

    #709114

    Hi Nikko,
    It hasn’t worked but I think it is because I don’t have an add to cart button now. I have replaced it with “Request a Quote” button. this is the div:

    <div class="yith-ywraq-add-to-quote add-to-quote-2718">
        <div class="yith-ywraq-add-button show" style="display:block">
            
    <a href="#" class="add-request-quote-button button" data-product_id="2718" data-wp_nonce="17c79cf36a">
        Add to quote</a>
    <img src="http://fordtractorsales.co.uk/wp-content/plugins/yith-woocommerce-request-a-quote/assets/images/wpspin_light.gif" class="ajax-loading" alt="loading" style="visibility:hidden" width="16" height="16">    </div>
        </div>

    If you could adjust the code for me I would be most grateful. I don’t want to break anything.
    Thanks
    Rob

    #709312

    Hi,

    Yes, it wouldn’t work since Add to Quote removes the Add to Cart button. Are you using the pro or free version of Yith Add to Quote plugin?

    Best regards,
    Nikko

    #709319

    Free at the moment. The client may want to upgrade it later.
    Thanks
    Rob

    #710029

    Hi,

    Try to change the code I gave you to this one:

    add_action( 'woocommerce_single_product_summary', 'add_phone', 36 );
    function add_phone() {
        echo '<div class="my_phone_number">XXX-XXXX</div>';
    }

    To style it, just add this to Quick CSS (located in Enfold > General Styling):

    .my_phone_number {
        display: inline-block;
        font-size: 20px;
        padding: 0 20px;
    }

    Just change the values as you see fit. Let us know if it works :)

    Best regards,
    Nikko

    #710298

    Perfect!
    Many thanks Nikko

    #710514

    Hi,

    Glad we could help!
    We really appreciate it if you rate our theme on themeforest https://themeforest.net/downloads
    To know more about enfold features please check – http://kriesi.at/documentation/enfold/
    Thank you for using Enfold :)

    Best regards,
    Nikko

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.