Skip to content

Instantly share code, notes, and snippets.

/* Remove certain boxes from add item for sellers */
function is_not_admin(){
global $current_user;
get_currentuserinfo();
if ($current_user->user_level < 7) {
return true;
}
else{
return false;
}
@bentasm1
bentasm1 / gist:9692548
Created March 21, 2014 18:23
BuddyPress Private Messaging with Matt Gates Product Vendors for WooCommerce
This will allow your customers to send your vendors private messages from the single product view. It will not reveal their email. It is free and requires no purchase.
It requires BuddyPress with the component "Private Messaging" to be enabled in order to work. You dont need any of the other components enabled, just this one. And this component comes with BuddyPress for free, as well.
-----
*Note* I'm an amateur. I'm not a coding pro. This code was hacked and put together from a dozen different websites offering snippets that eventually brought me the solution. If it doesnt work for you, I really probably have no idea why. As of writing, this works with mgates Product Vendor 1.5.0.2, WooCommerce 2.1.5, and WordPress 3.8.1.
There are 2 files to edit. Your themes functions.php (first). Next, is creating a file called bp-custom.php in your plugins directory (NOT THE BUDDYPRESS DIRECTORY, IN THE PLUGIN DIRECTORY WHICH LOOKS OUT OF PLACE BUT THATS HOW BUDDYPRESS WORKS ./wp-content/plugins/bp-custom.p
@bentasm1
bentasm1 / functions.php
Last active June 8, 2017 01:04
Add custom fields to shop settings
add_action('wcvendors_settings_after_paypal', 'pv_add_custom_merchant_id_field');
function pv_add_custom_merchant_id_field() {
?>
<div class="pv_merchant_id_container">
<p><b><?php _e( 'Merchant ID', 'wc_product_vendor' ); ?></b><br/>
<?php _e( 'Your Checkout.fi merchant ID.', 'wc_product_vendor' ); ?><br/>
<input type="text" name="pv_merchant_id" id="pv_merchant_id" placeholder="1234" value="<?php echo get_user_meta( get_current_user_id(), 'pv_merchant_id', true ); ?>" />
</p>
</div>
@bentasm1
bentasm1 / price.php
Created August 24, 2014 01:09
Change price font to h2 and green - /wp-content/themes/YOURTHEME/woocommerce/single-product/price.php
<?php
/**
* Single Product Price, including microdata for SEO
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 1.6.4
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@bentasm1
bentasm1 / archive-product.php
Last active October 13, 2016 14:56
For archive-product.php and specific vendor info
<?php
/* This goes somewhere in your archive-product.php template. This will check if the URL they are on is a vendor store,
* and if it is, do something, if it isn't, do something else. Writhing the somethings is up to you. :)
*/
$vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
$vendor_id = WCV_Vendors::get_vendor_id( $vendor_shop );
if ( $vendor_id ) {
// Do something
} elseif {
@bentasm1
bentasm1 / gist:45e11b2f39b8a5ae403f
Created October 15, 2014 19:15
Vendor Dashboard Redirect after Login
add_filter('woocommerce_login_redirect', 'login_redirect', 10, 2);
function login_redirect( $redirect_to, $user ) {
if ( WCV_Vendors::is_vendor( $user->id ) ) {
$redirect_to = '/seller_dashboard';
return $redirect_to;
} else {
$redirect_to = 'my-account';
return $redirect_to;
}
@bentasm1
bentasm1 / functions.phop
Last active September 22, 2016 16:30
Basic integration with BuddyPress & WC Vendors Free
//THIS IS FOR WC VENDORS FREE ONLY. See KnowledgeBase @ wcvendors.com for Pro instructions.
// CHANGE /members/ to your BuddyPress Members Permalink. (/members/ is the BuddyPress Default)
// CHANGE /vendors/ to your WC Vendors Store Permalink (/vendors/ is the WC Vendors Default)
add_action('bp_member_header_actions', 'wcv_bp_member_header_actions');
function wcv_bp_member_header_actions() {
$wcv_profile_id = bp_displayed_user_id();
$wcv_profile_info = get_userdata( bp_displayed_user_id() );
$wcv_profile_role = implode( $wcv_profile_info->roles );
/* Adds Stories & Blogs links to profile pages */
function authorposts_onprofile() {
global $bp;
?>
<li id="activity-reshares"><a href="<?php echo home_url(). '/author/' . bp_get_displayed_user_username(). '/'; ?>" title="<?php bp_displayed_user_fullname(); ?>'s Stories and Blogs">Stories & Blogs</a></li>
<?php
}
add_action('bp_member_options_nav', 'authorposts_onprofile');
@bentasm1
bentasm1 / functions.php
Created October 21, 2014 00:38
Add extra fields to WooCommerce @ registration from /my-account/
/* BEGIN REGISTRATION FIELDS */
function cs_wc_extra_register_fields() {
?>
<p class="form-row form-row-first">
<label for="reg_billing_first_name"><?php _e( 'First Name', 'textdomain' ); ?> <span class="required">*</span></label>
<input type="text" class="input-text" name="billing_first_name" id="reg_billing_first_name" value="<?php if ( ! empty( $_POST['billing_first_name'] ) ) esc_attr_e( $_POST['billing_first_name'] ); ?>" />
</p>
<p class="form-row form-row-last">
<label for="reg_billing_last_name"><?php _e( 'Last Name', 'textdomain' ); ?> <span class="required">*</span></label>
<input type="text" class="input-text" name="billing_last_name" id="reg_billing_last_name" value="<?php if ( ! empty( $_POST['billing_last_name'] ) ) esc_attr_e( $_POST['billing_last_name'] ); ?>" />
@bentasm1
bentasm1 / functions.php
Created October 23, 2014 17:26
For vdirects customization of WC Vendors
// ---- SHOW ALL VENDORS--WITH LIMIT ---- //
add_action('woo_vendor_list_shortcode', 'WCV_Vendors');
if (class_exists('WCV_Vendors')) {
function pv_vendors( $atts ){
//BASIC CODE FOR SETTING SHORTCODE ATTRIBUTES/PARAMETERS--default at 100 gets overwritten
extract( shortcode_atts( array(
'limit' => '100',
), $atts ) );