Skip to content

Instantly share code, notes, and snippets.

View fervous's full-sized avatar

Anna fervous

View GitHub Profile
@fervous
fervous / functions.php
Created September 3, 2016 04:17 — forked from bentasm1/functions.php
WC Vendors Pro - Add another file uploader to the add/edit product form
/* WC Vendors Pro - Add another file uploader to upload a file with the ID in a meta key */
function custom_wcv_file_uploader( ){
$value = get_user_meta( get_current_user_id(), 'wcv_custom_product_file1', true ); // Must match meta key used in line 8
WCVendors_Pro_Form_Helper::file_uploader( array(
'header_text' => __('File uploader', 'wcvendors-pro' ),
'add_text' => __('Add file', 'wcvendors-pro' ),
'remove_text' => __('Remove file', 'wcvendors-pro' ),
'image_meta_key' => 'wcv_custom_product_file1', // Must match meta key used in line 3
'save_button' => __('Add file', 'wcvendors-pro' ),
'window_title' => __('Select an Image', 'wcvendors-pro' ),
@fervous
fervous / gist:fbda9ce3245da6caa555cda212e14d58
Created September 3, 2016 04:17 — forked from bentasm1/gist:b55ed2807c64d8954fb4
WC Vendors Pro - Gift Wrap by Vendors
Gives vendors an option to allow gift wrapping. Requires https://wordpress.org/plugins/woocommerce-product-gift-wrap/
// Goes in your product-edit.php template, anywhere you see fit for it
WCVendors_Pro_Form_Helper::input(
array(
'post_id' => $object_id,
'id' => 'wcv_custom_product_gift_wrapper_enable',
'label' => __( 'Let buyer choose product to be wrapped?', 'wcvendors-pro' ),
'type' => 'checkbox'
@fervous
fervous / functions.php
Created September 3, 2016 04:18 — forked from bentasm1/functions.php
WC Vendors Pro - Commission Rate depending on how much a product sells for
/* WC Vendors Pro -- No % for commission, just a tiered fee structure */
add_filter( 'wcv_commission_rate', 'my_wcv_commission_rate', 10, 5 );
function my_wcv_commission_rate( $commission, $product_id, $product_price, $order, $qty ) {
// First, reduce price to qty1 to do calculations
$product_price = $product_price / $qty;
// Second, run through the price and apply the right commission fee
if ( $product_price > 48.99 ) {
$commission_fee = 3.36;
@fervous
fervous / functions.php
Created September 3, 2016 04:18 — forked from bentasm1/functions.php
WC Vendors Pro - Quick n Dirty Terms Page for Customers
/* WC Vendors Pro - A quick action for showing a string of text on the
* my account page for a general terms and conditions for all users
* not just vendors. */
add_action( 'woocommerce_register_form', 'wcvendors_extra_myaccount_text' );
function wcvendors_extra_myaccount_text() {
echo '<strong>Important</strong> -- By registering to this site you agree to our <a href="/whatever/" target="top">General Terms and Conditions</a>.';
}
@fervous
fervous / functions.php
Created September 3, 2016 04:22 — forked from bentasm1/functions.php
WC Vendors Pro - Function to output vendor ratings/feedback in side bar
// Put this in your themes function.php
function vendor_feedback_sidebar() {
if ( is_shop() ) {
$vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
$vendor_id = WCV_Vendors::get_vendor_id( $vendor_shop );
if ( ! WCVendors_Pro::get_option( 'ratings_management_cap' ) ) echo WCVendors_Pro_Ratings_Controller::ratings_link( $vendor_id, true );
}
} // vendor_feedback_sidebar()
// call this in your side bar
@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 ) ),