Skip to content

Instantly share code, notes, and snippets.

@bentasm1
Created October 28, 2014 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bentasm1/56a56f8996b289c076f8 to your computer and use it in GitHub Desktop.
Save bentasm1/56a56f8996b289c076f8 to your computer and use it in GitHub Desktop.
Customizing the Vendor Header
Copy archive-product.php from WooCommerce into /wp-content/YOURTHEME/woocommerce/archive-product.php
Around line 23 or so, ***ABOVE*** the line that says:
<?php if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?>
....enter your custom code.
Let's include a sample that checks if the page being loaded is for a vendor, and then do some stuff. Customize as you need for your own purposes. The sample below was written for a BuddyPress site that has private messages and profiles. The [button] shortcode is instead of just displaying text. Again, modify to your own desires :)
<?php
$vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
$vendor_id = WCV_Vendors::get_vendor_id( $vendor_shop );
if ( $vendor_id ) {
?>
<center>
<?php
$vendor_name_message = get_userdata($vendor_id);
$current_user = wp_get_current_user();
if ( is_user_logged_in() ) {
echo do_shortcode( '[button link="/members/'.$current_user->user_login.'/messages/compose/?r='.$vendor_name_message->user_login.'"]SEND ME A PRIVATE MESSAGE[/button]' );
} else {
echo do_shortcode( '[button link="/my-account/"]LOGIN TO SEND ME A PRIVATE MESSAGE[/button]' );
};
echo do_shortcode( '[button link="/members/'.$vendor_name_message->user_login.'"]VIEW MY PROFILE[/button]' );
?>
</center>
<?php
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment