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://api.whatsapp.com/send?phone={$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) {
- if ( ! wcfm_is_store_page() ) return;
- $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 ) ) return;
- $store_user = get_user_by( 'slug', $store_name );
- $store_id = $store_user->ID;
- $vendor_whatsapp = get_user_meta( $store_id, '_wcfm_vendor_whatsapp', true );
- if(!$vendor_whatsapp) return;
- return "https://api.whatsapp.com/send?phone={$vendor_whatsapp}";
- } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement