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 Dispensary</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-phone-wrapper {
- text-align: center;
- }
- #wcfmmp-store-phone-wrapper .elementor-button {
- font-size: 24px;
- background-color: #46BBFF;
- border-radius: 10px 10px 10px 10px;
- }
- #wcfmmp-store-phone-wrapper .elementor-button:hover,
- #wcfmmp-store-phone-wrapper .elementor-button:focus {
- background-color: #FFA600;
- }
- </style>
- <div id="wcfmmp-store-phone-wrapper" class="elementor-button-wrapper">
- <a class="elementor-button elementor-size-sm" title="<?php _e( 'Phone', 'wc-frontend-manager-ultimate' ); ?>" href="<?php echo "tel:{$phone}"; ?>">
- <span class="elementor-button-content-wrapper">
- <span class="elementor-button-icon elementor-align-icon-left">
- <i aria-hidden="true" class="fas fa-phone-square"></i>
- </span>
- <span class="elementor-button-text">Call Dispensary</span>
- </span>
- </a>
- </div>
- <?php
- }
- });
Add Comment
Please, Sign In to add comment