Plugin Author
Creame
(@creapuntome)
Adapting this snippet a bit, you can use custom fields to modify the button.
In this example, use the custom fields '_joinchat_woo_btn_view' and '_joinchat_woo_btn_text' to change the behavior of the Product Button:
/**
* Change Joinchat product button with custom fields
*/
function joinchat_woobtn_custom_setting( $settings, $obj ) {
// Exit if not is product.
if ( ! is_singular( 'product' ) ) return $settings;
$visibility = get_post_meta( $obj->ID, '_joinchat_woo_btn_view', true );
$text = get_post_meta( $obj->ID, '_joinchat_woo_btn_text', true );
if ( 'yes' === $visibility ) {
$settings['woo_btn_position'] = 'woocommerce_after_add_to_cart_button';
}
if ( 'no' === $visibility ) {
$settings['woo_btn_position'] = 'none';
}
if ( $text ) {
$settings['woo_btn_text'] = $text;
}
return $settings;
}
add_filter( 'joinchat_get_settings_site', 'joinchat_woobtn_custom_setting', 10, 2 );
Hi,
Thanks for your attempt to help me. I really appreciate it. Perhaps my request was not clear.
Let me try again
I am trying to change the button near Add to Cart as seen here

And replace this Button Text and Number with changes made in Edit Product as seen here

But the change is ONLY seen at the bottom of the page as seen here

Can you please help so that the change is seen NEAR Add to Cart?
Thanks a lot
Plugin Author
Creame
(@creapuntome)
Ok,
“Telephone” and “Message” from Joinchat metabox will be the same for product button. “Call to Action” it’s only for Joinchat chatbox, as you said but whit this code metabox CTA text will be used for product button (you can even hide Joinchat floating button and leave only product button):
/**
* Change Joinchat product button text with metabox CTA
*/
function joinchat_woobtn_text_from_metabox_cta( $settings, $obj ) {
$obj_settings = '';
if ( is_singular( 'product' ) ) {
$obj_settings = get_post_meta( $obj->ID, '_joinchat', true );
}
if ( is_array( $obj_settings ) && isset( $obj_settings['message_text'] ) ) {
$settings['woo_btn_text'] = $obj_settings['message_text'];
}
return $settings;
}
add_filter( 'joinchat_get_settings_site', 'joinchat_woobtn_text_from_metabox_cta', 9, 2 );
@creapuntome Thanks a lot. This is getting closer.
Would you help with some changes to the code so that Joinchat floating button shows the ORIGINAL number / text as defined globally?
I want ONLY the product button to show different number / message as defined in individual product.
Thanks again for taking some time to help me here. God bless you!
Plugin Author
Creame
(@creapuntome)
I’m sorry, as the plugin is currently designed, it is complicated to put a different number to the product button and mantain global phone.
The most viable option is to use the code above and hide the floating button for products that have a number other than the general one.
@creapuntome Thank you for your prompt response.
I will mark this as resolved for later use.