• 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 15 replies - 1 through 15 (of 22 total)
  • Plugin Author WC Lovers

    (@wclovers)

    I understand your requirements but what issue you are getting with this snippet?

    Thread Starter ashop1

    (@ashop1)

    I have to adapt the code so that it works with the number of the provider that published the product, that is, to obtain your phone number from woocommerce billing_whatsapp that I already created or to obtain it from the wcfm sellers registration field which would be ideal.

    As well as it is now, the code fragment only works with a number that I write manually, and for my marketplace with its wcfm complement it must work with the number of the provider that published the product.

    the unique phone goes after $ phone = ”

    but in my case I couldn’t adapt it, so I ask for help if possible, I saw that a website already has it implemented as I mentioned.

    Thread Starter ashop1

    (@ashop1)

    The fragment like this works only with a number and no more. but in a marketplace with wcfm there are more than one number of course so I have to adapt that code and even more so that I saw that a website already has it in use and with its wcfm complement as I showed you.

    Thread Starter ashop1

    (@ashop1)

    hello, could you see this?

    Plugin Author WC Lovers

    (@wclovers)

    to obtain your phone number from woocommerce billing_whatsapp that I already created or to obtain it from the wcfm sellers registration field which would be ideal.

    Have you created such a vendor registration custom field?

    Thread Starter ashop1

    (@ashop1)

    If I have a billing_Whatsapp field in the user record and that the data is saved in the administration panel and is visible in the checkout.

    I also added a field in the wcfm sellers registration that is also called whatsapp although I don’t know what code it has because I didn’t create it myself but I did it from the wcfm plugin from its panel for creating additional fields for the sellers registration

    Plugin Author WC Lovers

    (@wclovers)

    Show me registration custom field settings screenshot.

    Thread Starter ashop1

    (@ashop1)

    Plugin Author WC Lovers

    (@wclovers)

    Thanks.

    You may fetch this information using this function – get_user_meta( $store_id, ‘whatsapp’, true )

    $store_id – product’s vendor user id

    Thread Starter ashop1

    (@ashop1)

    thanks, one more thing.

    Could you please explain to me where to put this? Why after $ phone = it gives me an error, I think because there it only allows number, could you tell me if you are so kind where to locate what you just informed me within the code I have for this function?

    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>’;
    };
    Plugin Author WC Lovers

    (@wclovers)

    It would be like this –

    $phone = get_user_meta( $store_id, 'whatsapp', true );

    Thread Starter ashop1

    (@ashop1)

    well, does that get the field data from the wcfm sellers registration or woocommerce registration?

    Plugin Author WC Lovers

    (@wclovers)

    From WCFM registration.

    Thread Starter ashop1

    (@ashop1)

    Thank you very much for your excellent attention, I am already testing it in a moment and I confirm it.

    Thread Starter ashop1

    (@ashop1)

    Excuse me, it’s not working for me.

    I put WhatsApp with a capital letter as it was seen in inspect and also change it to billing_whatsapp that I had commented on but it does not take the data.

    What could it be?

    this is the code:

    add_action (‘woocommerce_before_add_to_cart_form’, ‘dcms_question_whatsapp’);

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

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

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

    };

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