Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action('wcfm_after_product_catalog_enquiry_button', function() {
- global $product;
- if( is_product() && $product && method_exists( $product, 'get_id' ) ) {
- $product_id = $product->get_id();
- $store_id = wcfm_get_vendor_id_by_post( $product_id );
- $store_user = wcfmmp_get_store( $store_id );
- $store_info = $store_user->get_shop_info();
- $phone = $store_user->get_phone();
- if( $phone && ( $store_info['store_hide_phone'] == 'no' ) && wcfm_vendor_has_capability( $store_user->get_id(), 'vendor_phone' ) ) {
- echo "<a href='tel:{$phone}' class='wcfm_vendor_phone wcfm_chat_now_button' data-number='{$phone}'><span class='wcfmfa fa-phone'></span> <span class='add_enquiry_label'>Call</span></a>";
- }
- }
- });
- add_action( 'wcfmmp_store_after_follow_me', function($store_id) {
- echo do_shortcode("[wcfmmp_vendor_phone id='{$store_id}']");
- });
- add_shortcode('wcfmmp_vendor_phone', function($attr) {
- global $post, $WCFM;
- $vendor_id = '';
- if ( isset( $attr['id'] ) && !empty( $attr['id'] ) ) {
- $vendor_id = absint($attr['id']);
- }elseif ( 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) return;
- $store_user = wcfmmp_get_store( $vendor_id );
- $phone = $WCFM->wcfm_vendor_support->wcfm_vendor_has_capability( $vendor_id, 'vendor_phone' ) ? $store_user->get_phone() : '';
- if($phone) {
- ?>
- <style>
- #wcfmmp-store .bd_icon_box #wcfm_phone_link {
- min-width: 50px;
- width: auto;
- padding: 0 15px;
- height: 30px;
- background: #fff;
- color: #17a2b8;
- border-radius: 5px;
- display: inline-block;
- cursor: pointer;
- }
- #wcfmmp-store .bd_icon_box #wcfm_phone_link span {
- cursor: pointer;
- color: #17a2b8;
- margin-left: 0;
- line-height: 30px;
- display: inline-block;
- font-size: 13px;
- position: relative;
- top: inherit;
- left: inherit;
- transform: translateX(0);
- -moz-transform: translateX(0);
- -ms-transform: translateX(0);
- -o-transform: translateX(0);
- -webkit-transform: translateX(0);
- opacity: 1;
- }
- </style>
- <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> <span>Call</span></a></div>
- <?php
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement