Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'wcfm_marketplace_settings_fields_general', function( $setting_fields, $vendor_id ) {
- if( isset($setting_fields['store_name']) ) {
- $whatsapp = get_user_meta( $vendor_id, '_wcfm_vendor_whatsapp', true );
- $vendor_whatsapp = array(
- "_wcfm_vendor_whatsapp" => array( 'label' => __( 'Whatsapp', 'wc-frontend-manager' ), 'type' => 'text', 'class' => 'wcfm-text wcfm_ele', 'label_class' => 'wcfm_title wcfm_ele', 'value' => $whatsapp ),
- );
- $setting_fields = array_merge( $setting_fields, $vendor_whatsapp );
- }
- return $setting_fields;
- }, 50, 2 );
- add_action( 'wcfm_vendor_settings_update', function( $vendor_id, $wcfm_settings_form ) {
- if ( isset( $wcfm_settings_form['_wcfm_vendor_whatsapp'] ) ) {
- $vendor_whatsapp = wc_clean($wcfm_settings_form['_wcfm_vendor_whatsapp']);
- update_user_meta( $vendor_id, '_wcfm_vendor_whatsapp', $vendor_whatsapp );
- }
- }, 500, 2 );
- add_action('after_wcfmmp_store_header_info', function ($store_id) {
- $vendor_whatsapp = get_user_meta($store_id, '_wcfm_vendor_whatsapp', true);
- if (!empty($vendor_whatsapp)) {
- $whatsapp_link = "https://wa.me/{$vendor_whatsapp}";
- ?>
- <div class="store_info_parallal wcfmmp_store_header_custom">
- <i class="wcfmfa fab fa-whatsapp" aria-hidden="true"></i>
- <a href="<?php echo esc_url($whatsapp_link); ?>" target="_blank"><span><?php echo $vendor_whatsapp; ?></span></a>
- </div>
- <?php
- }
- });
- add_shortcode( 'vendor_whatsapp', function($attr) {
- global $post;
- if ( wcfm_is_store_page() ) {
- $wcfm_store_url = get_option( 'wcfm_store_url', 'store' );
- $store_name = apply_filters( 'wcfmmp_store_query_var', get_query_var( $wcfm_store_url ) );
- if ( !empty( $store_name ) ) {
- $store_user = get_user_by( 'slug', $store_name );
- $vendor_id = $store_user->ID;
- }
- } elseif( is_product() ) {
- $vendor_id = $post->post_author;
- }
- if( !$vendor_id && is_single() && $post && is_object( $post ) && wcfm_is_vendor( $post->post_author ) ) {
- $vendor_id = $post->post_author;
- }
- if(!$vendor_id || !wcfm_is_vendor($vendor_id) ) return '';
- $vendor_whatsapp = get_user_meta( $vendor_id, '_wcfm_vendor_whatsapp', true );
- if(!$vendor_whatsapp) return;
- $whatsapp_link = "https://wa.me/{$vendor_whatsapp}";
- return "<a href='" . esc_url($whatsapp_link) . "' target='_blank'><i class='wcfmfa fab fa-whatsapp' aria-hidden='true'></i> <span>" . $vendor_whatsapp ."</span></a>";
- } );
Advertisement
Comments
-
- Tem como colocar máscara no telefone celular do Brasil? Pra funcionar tá exigindo incluir código +55
Add Comment
Please, Sign In to add comment
Advertisement