Advertisement
Guest User

Vendor Call button

a guest
May 26th, 2021
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.09 KB | None | 0 0
  1. add_action('wcfm_after_product_catalog_enquiry_button', function() {
  2.     global $product;
  3.     if( is_product() && $product && method_exists( $product, 'get_id' ) ) {
  4.         $product_id = $product->get_id();
  5.         $store_id = wcfm_get_vendor_id_by_post( $product_id );
  6.         $store_user = wcfmmp_get_store( $store_id );
  7.         $store_info = $store_user->get_shop_info();
  8.         $phone = $store_user->get_phone();
  9.         if( $phone && ( $store_info['store_hide_phone'] == 'no' ) && wcfm_vendor_has_capability( $store_user->get_id(), 'vendor_phone' ) ) {
  10.             echo "<a href='tel:{$phone}' class='wcfm_vendor_phone wcfm_chat_now_button' data-number='{$phone}'><span class='wcfmfa fa-phone'></span>&nbsp;&nbsp;<span class='add_enquiry_label'>Call</span></a>";
  11.         }
  12.     }
  13. });
  14.  
  15. add_action( 'wcfmmp_store_after_follow_me', function($store_id) {
  16.     echo do_shortcode("[wcfmmp_vendor_phone id='{$store_id}']");
  17. });
  18.  
  19. add_shortcode('wcfmmp_vendor_phone', function($attr) {
  20.     global $post, $WCFM;
  21.     $vendor_id = '';
  22.     if ( isset( $attr['id'] ) && !empty( $attr['id'] ) ) {
  23.         $vendor_id = absint($attr['id']);
  24.     }elseif (  wcfm_is_store_page() ) {
  25.         $wcfm_store_url = get_option( 'wcfm_store_url', 'store' );
  26.         $store_name = apply_filters( 'wcfmmp_store_query_var', get_query_var( $wcfm_store_url ) );
  27.         if ( !empty( $store_name ) ) {
  28.             $store_user = get_user_by( 'slug', $store_name );
  29.             $vendor_id = $store_user->ID;
  30.         }
  31.     }elseif( is_product() ) {
  32.         $vendor_id = $post->post_author;
  33.     }
  34.     if( !$vendor_id && is_single() && $post && is_object( $post ) && wcfm_is_vendor( $post->post_author ) ) {
  35.         $vendor_id = $post->post_author;
  36.     }
  37.     if(!$vendor_id) return;
  38.     $store_user = wcfmmp_get_store( $vendor_id );
  39.     $phone = $WCFM->wcfm_vendor_support->wcfm_vendor_has_capability( $vendor_id, 'vendor_phone' ) ? $store_user->get_phone() : '';
  40.     if($phone) {
  41.         ?>
  42.         <style>
  43.         #wcfmmp-store .bd_icon_box #wcfm_phone_link {
  44.             min-width: 50px;
  45.             width: auto;
  46.             padding: 0 15px;
  47.             height: 30px;
  48.             background: #fff;
  49.             color: #17a2b8;
  50.             border-radius: 5px;
  51.             display: inline-block;
  52.             cursor: pointer;
  53.         }
  54.         #wcfmmp-store .bd_icon_box #wcfm_phone_link span {
  55.             cursor: pointer;
  56.             color: #17a2b8;
  57.             margin-left: 0;
  58.             line-height: 30px;
  59.             display: inline-block;
  60.             font-size: 13px;
  61.             position: relative;
  62.             top: inherit;
  63.             left: inherit;
  64.             transform: translateX(0);
  65.             -moz-transform: translateX(0);
  66.             -ms-transform: translateX(0);
  67.             -o-transform: translateX(0);
  68.             -webkit-transform: translateX(0);
  69.             opacity: 1;
  70.         }
  71.         </style>
  72.         <div class="lft bd_icon_box"><a id="wcfm_phone_link" title="<?php _e( 'Phone', 'wc-frontend-manager-ultimate' ); ?>" href="<?php echo "tel:{$phone}"; ?>"><i class="wcfmfa fa-phone"></i>&nbsp;<span>Call</span></a></div>
  73.         <?php
  74.     }
  75. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement