Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Membership › Display "Country" + "State/County" + "City/Town" in single product page.
- This topic has 8 replies, 3 voices, and was last updated 4 years, 8 months ago by Sushobhan.
- AuthorPosts
- April 23, 2020 at 3:14 pm #122157ing.rappariniParticipant
I need to display “Country” + “State/County” + “City/Town” of the vendor in single product page “woocommerce_product_meta_end” position.
(These values are those that the seller entered during registration).
How can I get it?
Thanks
Attachments:
You must be logged in to view attached files. - April 24, 2020 at 4:40 am #122350CraigParticipant
I vote for this as well.
it would be good to display the location in addition to the shop name on the product page
- April 24, 2020 at 2:12 pm #122478SushobhanKeymaster
Hello,
You can use the following snippet (do changes as per your need)-add_action('woocommerce_product_meta_end', function() { global $product; $vendor_id = wcfm_get_vendor_id_by_post($product->get_id()); ?> <div class="vendor_singleline_address"><?php echo wcfm_get_vendor_store_address_by_vendor($vendor_id); ?></div> <?php });
Add this code to your child theme’s functions.php
In case you do not have child theme then add code using this plugin – https://wordpress.org/plugins/code-snippets/
Let me know how this goes.
Thanks! - April 24, 2020 at 3:26 pm #122498ing.rappariniParticipant
This show ALL the address!!!
And is not good for privacy…Can you do what I m asking in my previous pic (also with the same pagination)?
Thanks
- April 24, 2020 at 4:22 pm #122501SushobhanKeymaster
Kindly use this updated snippet-
add_action( 'woocommerce_product_meta_end', function() { global $product; $vendor_id = wcfm_get_vendor_id_by_post( $product->get_id() ); $store_user = wcfmmp_get_store( $vendor_id ); $store_info = $store_user->get_shop_info(); if ( $store_info['store_hide_address'] == 'yes' || ! wcfm_vendor_has_capability( $vendor_id, 'vendor_address' ) ) return; if ( ! empty( $store_info['address'] ) ) { $addr_arr = array(); $all_countries = WC()->countries->get_countries(); if ( ! empty( $store_info['address']['country'] ) && ! empty( $all_countries[$store_info['address']['country']] ) ) { array_push( $addr_arr, $all_countries[$store_info['address']['country']] ); if ( ! empty( $store_info['address']['state'] ) ) array_push( $addr_arr, $store_info['address']['state'] ); if ( ! empty( $store_info['address']['city'] ) ) array_push( $addr_arr, $store_info['address']['city'] ); ?> <p class="vendor_singleline_address"><span>Country: </span><?php _e( implode( ", ", $addr_arr ) ); ?></p> <?php } } } );
Add this code to your child theme’s functions.php
In case you do not have child theme then add code using this plugin – https://wordpress.org/plugins/code-snippets/
Let me know how this goes.
Thanks! - April 24, 2020 at 5:38 pm #122528ing.rappariniParticipant
THAT IS AWESOME!
THANK YOU VERY MUCH!!!
- April 24, 2020 at 6:56 pm #122558SushobhanKeymaster
You are always welcome 🙂
Let me know if there’s anything else we can help you with.
Can we ask for a favor? Would you mind taking a few minutes to review our plugin at https://wordpress.org/support/plugin/wc-multivendor-marketplace/reviews/ and let others know about your 5 Star experience with WCFM Marketplace. Also, follow us on Twitter https://twitter.com/wcfmmp for more exciting news, important updates, and irresistible offers. - April 25, 2020 at 12:43 am #122698ing.rappariniParticipant
Yes…you can do something else :-)))
I have a filter that can filter for “META”. (Product Filter by XforWoocommerce)
What is the “meta” I can use for “country”?
- April 25, 2020 at 1:02 pm #122831SushobhanKeymaster
Country is not stored as an individual meta. You can get complete vendor setting fields using ‘wcfmmp_profile_settings’ meta like this-
$shop_info = get_user_meta( $vendor_id, 'wcfmmp_profile_settings', true );
It return an array with key name ‘address’, which is again an array stored in the following format-[address] => Array ( [street_1] => [street_2] => [city] => [zip] => [country] => IN [state] => WB )
Hope it clarifies everything!
- AuthorPosts
- You must be logged in to reply to this topic.