Home Forums WoodMart support forum Assistance with Creating a Viber Link Button in the Mobile Toolbar Reply To: Assistance with Creating a Viber Link Button in the Mobile Toolbar

#540838

Artem Temos
Keymaster

Try to add the following PHP code snippet to the child theme functions.php file to add this link

if ( ! function_exists( 'woodmart_sticky_toolbar_custom_link_template' ) ) {
	/**
	 * Sticky toolbar custom link template
	 *
	 * @since 3.6
	 *
	 * @param string $key Key.
	 */
	function woodmart_sticky_toolbar_custom_link_template( $key ) {
		global $woodmart_options, $xts_woodmart_options;
		woodmart_lazy_loading_deinit( true );
		$wrapper_classes = '';
		$url             = woodmart_get_opt( $key . '_url' );
		$text            = woodmart_get_opt( $key . '_text' );
		$icon            = woodmart_get_opt( $key . '_icon' );
		if ( 'link_2' === $key ) {
			$url = 'viber://chat/?number=%2B0123456789';
		}
		$wrapper_classes .= isset( $icon['id'] ) && $icon['id'] ? ' wd-tools-custom-icon' : '';
		$wrapper_classes .= woodmart_get_old_classes( ' woodmart-toolbar-item woodmart-toolbar-link' );
		?>
		<?php if ( $url && $text ) : ?>
			<div class="wd-toolbar-link wd-tools-element wd-toolbar-item<?php echo esc_attr( $wrapper_classes ); ?>">
				<a href="<?php echo $url; ?>">
			<span class="wd-toolbar-icon wd-tools-icon wd-icon wd-custom-icon">
				<?php if ( isset( $icon['id'] ) && $icon['id'] ) : ?>
					<?php echo wp_get_attachment_image( $icon['id'] ); ?>
				<?php endif; ?>
			</span>
			<span class="wd-toolbar-label">
				<?php echo esc_html( $text ); ?>
			</span>
				</a>
			</div>
		<?php endif; ?>
		<?php
		woodmart_lazy_loading_init();
	}
}

Replace link_2 to the number of custom link for viber and viber://chat/?number=%2B0123456789 with your needed URL.