Skip to content

Instantly share code, notes, and snippets.

View fervous's full-sized avatar

Anna fervous

View GitHub Profile
@fervous
fervous / gist:edf62e52f71aa0182d01972fbbc481f0
Created September 3, 2016 04:23 — forked from bentasm1/gist:058fb9c5591e2545e97d
WC Vendors Pro & BuddyPress Widget
<?php
/**
* Plugin Name: WC Vendors Pro Widgets
* Plugin URI: https://www.wcvendors.com
* Description: Does Widget Stuff
* Author: WC Vendors
* Author URI: https://www.wcvendors.com
*
* Version: 1.0.0
* Requires at least: 4.0.0
@fervous
fervous / vendor-list.php
Created September 3, 2016 04:24 — forked from bentasm1/vendor-list.php
Customizing [wcv_vendorslist] for WC Vendors Pro
/* These functions will provide the WC Vendors Pro fields on your /themes/yourtheme/wc-vendors/front/vendor-list.php template - Thanks @jarvo! */
<?php
$all_meta_for_user = get_user_meta( $vendor_id );
#print_r( $all_meta_for_user );
$shop_name = get_user_meta( $vendor_id, 'pv_shop_name', true );
echo 'Shop Name: '.$shop_name.'<br/>';
$shop_description = get_user_meta( $vendor_id, 'pv_shop_description', true );
@fervous
fervous / gist:fefb0712c20e958b294c04b58928acbb
Created September 3, 2016 04:25 — forked from bentasm1/gist:73ab12a2b2cb060bae1c
Show Vendors Products to Customers Following a Vendor
/* https://www.wcvendors.com/help/reply/20920/ */
function recent_products_test( ) {
$user_followings = bp_follow_get_following();
foreach ($user_followings as $user_following ) {
$wcv_users[]= get_userdata( $user_following );
@fervous
fervous / gist:abfdbcbbb9b759506fbbed8785419db5
Created September 3, 2016 04:26 — forked from bentasm1/gist:293eb4673179a5f34c7c
BuddyPress Show if User has New Private Messages
/* This code goes into one of the WC Vendors Templates. Which one? Depends where you want to show it on the dashboard. :) */
/* Shows unread messages button */
$unread = bp_get_total_unread_messages_count();
$current_user = wp_get_current_user();
if ( $unread > 0 ) {
echo '<a href="/members/' . $current_user->user_login . '/messages/">You have ' . $unread . ' Unread Private Messages</a>';
}
@fervous
fervous / functions.php
Created September 3, 2016 04:26 — forked from bentasm1/functions.php
WC Vendors Notify Vendor when Product is Approved
/* WC Vendors Pro - Notify Vendor when Product is Approved */
add_action( 'pending_to_publish', 'wcv_notify_vendor_on_publish' );
function wcv_notify_vendor_on_publish( $post_id ) {
global $post;
if ( $post->post_author != get_current_user_id() ) {
$author = new WP_User( $post->post_author );
$email_data = array(
'to' => $author->user_email,
'subject' => sprintf( __( 'Your post on %1$s has been published!', 'email_author_on_publish' ), get_bloginfo('name') ),
'message' => sprintf( __( 'Your post "%1$s" on %2$s has been published: %3$s', 'email_author_on_publish' ), $post->post_title, get_bloginfo( 'name' ), get_permalink( $post->ID ) ),
@fervous
fervous / product-edit.php
Created September 3, 2016 04:27 — forked from bentasm1/product-edit.php
WC Vendors Pro Form Input Type Examples
<?php
/**
* Example text input with validation
*/
WCVendors_Pro_Form_Helper::input(
array(
'post_id' => $object_id,
'id' => '_wcv_custom_product_example_text_input',
'label' => __( 'Product Meta Text Input', 'wcvendors-pro' ),
@fervous
fervous / product-edit.php
Created September 3, 2016 04:27 — forked from bentasm1/product-edit.php
WC Vendors Pro - Adding a custom field to your add/edit product page
---- The code below goes in your product-edit.php template as outline in the KnowledgeBase Article ----
<?php
WCVendors_Pro_Form_Helper::textarea( array(
'post_id' => $object_id,
'id' => 'wcv_custom_product_ingredients',
'label' => __( 'Ingredients', 'wcvendors-pro' ),
'placeholder' => __( 'Ingredients', 'wcvendors-pro' ),
'desc_tip' => 'true',
'description' => __( 'The product ingredients', 'wcvendors-pro' ),
) );
@fervous
fervous / gist:d541738368191bc9ac2855c84f57c77c
Last active September 10, 2016 15:46 — forked from bentasm1/gist:bf0093c1348f761fdcb5
WooCommerce Order Amount Minimum
/* Minimum Purchase Price */
add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' );
add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' );
function wc_minimum_order_amount() {
$minimum = 5.99;
if ( WC()->cart->total < $minimum ) {
if( is_cart() ) {
wc_print_notice(
sprintf( 'Please add more itmes to your cart. The site minimum is %s.' ,
@fervous
fervous / functions.php
Created September 3, 2016 04:29 — forked from bentasm1/functions.php
Add custom link to pro dashboard navigation tabs
/* WC Vendors Pro - Add a custom link to your Pro Dashboard navigation bar */
add_filter( 'wcv_pro_dashboard_urls', 'custom_menu_link' );
function custom_menu_link( $pages ) {
$pages[ 'custom_link' ] = array(
'slug' => 'http://yoursite.com/customlink/here', // Change this to whatever you like, it must be a full URL
'label' => __('My Custom Link', 'wcvendors-pro' ),
'actions' => array()
);
return $pages;
}
@fervous
fervous / functions.php
Created September 3, 2016 04:30 — forked from bentasm1/functions.php
WC Vendors - Shows a slider while browsing categories
/* WC Vendors - Shows a slider while browsing categories */
add_action('woocommerce_before_shop_loop', 'wcvendors_slider');
function wcvendors_slider() {
$vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
$vendor_id = WCV_Vendors::get_vendor_id( $vendor_shop );
if ( !$vendor_id ) {
echo do_shortcode( '[rev_slider YOURSLIDERNAME]' ); // change YOURSLIDERNAME, of course ;)
echo '<br>';
}
}