• Resolved ashop1

    (@ashop1)


    Hello, I hope you are very well.

    I need a little help on this matter, I want to make the whatsaap link that I have on the simple product page works with the number of the supplier that published the product. I already saw that the same code has it on another website but maybe I use a custom field with acf, I don’t want that but what I want is to obtain the number of billing_whatsapp (which is a field that I created just like the woocommerce billing_phone exists ) or better yet obtain the whatsapp number from the field that I created specifically for the seller in the sellers registry.

    Below I show you the links, the screenshots and the corresponding code so that you can verify this and if it is possible that they give me this precious help that I need and I can not solve:

    the code I use:
    https://decodecms.com/consultar-dudas-de-produtos-por-whatsapp-en-woocommerce/

    add_action (‘woocommerce_share’, ‘dcms_question_whatsapp’);

    function dcms_question_whatsapp () {
    $ phone = ‘34123456789’;
    $ message = ‘I want product information:’ .get_the_title (). ‘ ‘;
    $ text = ‘Ask for WhatsApp’;
    $ ico = ‘‘;

    $ url = ‘https://api.whatsapp.com/send?phone=’.$phone.’&text=’.str_replace (‘ ‘,’% 20 ‘, $ message);
    $ link = ‘‘. $ ico. ‘<span>’. $ text. ‘</span> ‘;

    echo ‘<div class = “dc-whatsapp-container”>’. $ link. ‘</div>’;
    };

    the web that already has the same code implemented and uses wcfm: https://setevende.com/producto/tabla-playera-mickey-mouse/

    my product page: https://www.avellanedashop.com/publicacion/tony-v-sneakers/

    the registration of sellers with the whatsapp field:
    https://www.avellanedashop.com/vender/

    If you need more information let me know, thank you very much in advance!

    The page I need help with: [log in to see the link]

Viewing 7 replies - 16 through 22 (of 22 total)
  • Plugin Author WC Lovers

    (@wclovers)

    I put WhatsApp with a capital letter as it was seen in inspect

    Don’t do this, during save it’s sanitize.

    Show me your code screenshot, here it’s totally corrupted

    Thread Starter ashop1

    (@ashop1)

    The code that they told me to write after $ phone to get the provider’s phone number from the field I created for its registration does not work for me.

    Here they told me: https://www.ads-software.com/support/topic/get-whatsapp-field-data-from-sellers-registration-for-link-on-product-page/

    Attached capture of the code: https://ibb.co/mG7TyZs

    As I mentioned, I also created a field in the woocommerce registry for customers called billing_whatsapp. In the event that it does not work for me with the field that I created in the sellers registry, could the code be modified a little to obtain the number of billing_whatsapp?

    … as you told me there is no error but you do not get the phone, I show you how it looks when you click on the link:

    https://ibb.co/Hqv2WtX

    thanks for your attention!

    Plugin Author WC Lovers

    (@wclovers)

    $store_id – product’s vendor user id

    I also told you this. But you didn’t fetch $store_id before adding that line.

    Thread Starter ashop1

    (@ashop1)

    sorry for asking, entocness in addition to:
    $ phone = get_user_meta ($ store_id, ‘whatsapp’, true);

    do I have to add another line for the link to work? If so, could you tell me how, please?

    I do not have knowledge, I only collect information from the internet and I am understanding what to do to launch my website.

    sorry to bother.

    Thread Starter ashop1

    (@ashop1)

    Hello, I see that my problem is that I do not even know how to obtain data or metadata from fields, in this case custom fields. I will have to learn that, but could you give me for this whatsapp code what I am missing please?

    thank you for your answer.

    Plugin Author WC Lovers

    (@wclovers)

    Your code should be like this –

    add_action ('woocommerce_share', 'dcms_question_whatsapp');
    function dcms_question_whatsapp() {
    global $post;
    $store_id =  $post->post_author;
    $phone = get_user_meta( $store_id, 'whatsapp', true );
    if( $phone ) {
    $message = 'I want product information:' . get_the_title();
    $text = 'Ask for WhatsApp';
    $ico = '';
    
    $url = 'https://api.whatsapp.com/send?phone='.$phone.'&text='.str_replace (' ','%20', $message);
    $link = $ico. '<span>'. $text. '</span>';
    
    echo '<div class = "dc-whatsapp-container">'. $link. '</div>';
    }
    };
    Thread Starter ashop1

    (@ashop1)

    it works perfectly, I really appreciate it. I hope you have an excellent day !!

Viewing 7 replies - 16 through 22 (of 22 total)
  • The topic ‘get whatsapp field data from sellers registration for link on product page’ is closed to new replies.